Last active
August 29, 2015 13:55
-
-
Save VaclavSynacek/8769665 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# script which reads and outputs DS18S20 temperature reading | |
# assuming: | |
# modules w1-gpio and w1-therm loaded into kernel | |
# | |
# example - if your DS18S20 id is 28-000001b451d9, then | |
# to get it's temperature reading in Celsius use: | |
# DS18S20 28-000001b451d9 | |
# | |
if [ -z "$1" ]; then | |
echo usage: $0 DS_id | |
exit | |
fi | |
FILE="/sys/bus/w1/devices/$1/w1_slave" | |
AWKPRG='BEGIN { FS="=| "}; /NO/ {INVALID=1} // {SUM += $NF} END {if(INVALID){exit 1} else {print SUM/1000}}' | |
timeout 5s sh <<hereDocument | |
until awk '$AWKPRG' $FILE; do : nothing ; done | |
hereDocument |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# simple script to upload temperature from DS18B20 http://xively.com | |
# assuming: | |
# xively script is on the path (https://gist.github.com/VaclavSynacek/8766523) | |
# channel "room-temperature" had been created on xively | |
# DS18B20 script (above) is on the path | |
# DS18B20 id is 28-000001b451d9 (to find yours 'ls /sys/bus/w1/devices') | |
# | |
# just put this to /etc/cron.minutely or /etc/cron.hourly and be happy | |
# | |
# | |
DS18B20 28-000001b451d9 | xargs xively room-temperature |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment