November 15, 2017

One-Wire Temperature collection, publishing to EmonCMS using OmegaOnion

I needed a quick solution to log the temperature of my hot water cylinder at home, had an Omega Onion lying about so used that.

OmegaOnion EXP Dock
2 x DS18B20 Sensors, wired together with a 5K7 pull-up resistor

From a factory reset:

  • echo "w1-gpio-custom bus0=0,19,0" > /etc/modules.d/55-w1-gpio-custom
  • reboot
  • Find the names of the sensors, "ls /sys/devices/w1_bus_master1/
  • opkg install curl
  • opkg install nano
  • nano
temp1=$(awk -F= '/t=/ {printf "%.03f\n", $2/1000}' /sys/devices/w1_bus_master1/28-000006560975/w1_slave)
temp2=$(awk -F= '/t=/ {printf "%.03f\n", $2/1000}' /sys/devices/w1_bus_master1/28-0000065711e6/w1_slave)
curl --data "data={temp1:$temp1,temp2:$temp2}" ""
printf "\n"$temp1"\t"$temp2

  • Then all you need is to create a cron job, crontab -e
*/5 * * * * /root/ >/dev/null

No comments: