Skip to content

Instantly share code, notes, and snippets.

@pingec
Last active March 22, 2017 19:52
Show Gist options
  • Save pingec/5f91a617aad229bfce85f1c0fa2943cf to your computer and use it in GitHub Desktop.
Save pingec/5f91a617aad229bfce85f1c0fa2943cf to your computer and use it in GitHub Desktop.
Reporting temperatures from openwrt router
#!/bin/sh
# Gets temperature from 1wire sensor with specified address and posts it to specified url (teste on openwrt@wr1043nd)
SENSR_ADDR="28DD70770200009C"
SENSR_NUM=$(/usr/bin/digitemp_DS9097 -s /dev/ttyUSB0 -i -q | grep $SENSR_ADDR | grep ROM | cut -c6)
TEMP=$(/usr/bin/digitemp_DS9097 -t$SENSR_NUM -q -o"%.2C")
$(wget -q "http://***/temp.php?temp=$TEMP" -O /dev/null)
if [ $? -ne 0 ];
then echo "FAILED TO SEND"
else echo "OK"
fi
SENSR_ADDR="282C57CD0400002B"
SENSR_NUM=$(/usr/bin/digitemp_DS9097 -s /dev/ttyUSB0 -i -q | grep $SENSR_ADDR | grep ROM | cut -c6)
TEMP=$(/usr/bin/digitemp_DS9097 -t$SENSR_NUM -q -o"%.2C")
$(wget -q "http://***/temp.php?temp=$TEMP" -O /dev/null)
if [ $? -ne 0 ];
then echo "FAILED TO SEND"
else echo "OK"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment