On 10/04/2022 11:30, Andy Burns wrote:
zeneca wrote:
I have it running, but I wonder if there is somewhere a config file, a
cron ..
How does it run
You have to have something that will scan your 1-wire bus, detect and
read your temperatue sensor(s) ... no doubt something already exists
that can run on a Pi
Try this:
#!/bin/bash
# get a list (array) of all devices
shopt -s nullglob
devices=(/sys/bus/w1/devices/w1_bus_master1/28*)
[ ${#devices[@]} -eq 0 ] && {
printf 'No device files found. Investigate.'
exit 1
}
shopt -u nullglob
printf '%s\n' "${devices[@]}"
while true; do # repeat forever
unset temp # new array
for d in ${!devices[@]}; do # for each device
unset t # new temperature value
# at odd times we get -015 for reading; ignore it
while [[ ! "$t" || "$t" -lt 0 ]]; do
# getting temp can take a couple of seconds
t=$(<"${devices[d]}/temperature") # get reading
done
p="${devices[d]##*-}" # probe serial number
# reading is in millidegrees
t=$(bc <<<"scale=3; $t/1000")
temp+=("P-$p ${t}") # now degrees
done
printf '%(%Y-%m-%d %H:%M:%S)T ' # date and time
printf '%s %1.3f ' ${temp[@]} # probe data
printf '\n' # newline
sleep 10
done
--
Chris Elvidge
England
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)