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
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 temp.sh
#!/bin/ash
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}" "http://192.168.1.129/emoncms/input/post.json?node=55&apikey=xxxxxxxxxxxx"
printf "\n"$temp1"\t"$temp2

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

No comments: