Skip to content

Instantly share code, notes, and snippets.

@RussellSenior
Created August 1, 2017 01:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RussellSenior/27f103f8f2a737bff48d8bfc3c677850 to your computer and use it in GitHub Desktop.
Save RussellSenior/27f103f8f2a737bff48d8bfc3c677850 to your computer and use it in GitHub Desktop.
exporting temperature data from beagle bone black
#!/bin/bash
bus=$1
while true ; do
slaves=$(cat /sys/bus/w1/devices/w1_bus_master${bus}/w1_master_slaves | sed 's/^not found.//')
if [ -z "${slaves}" ] ; then
echo -- bus ${bus} empty, sleeping
sleep 1;
else
for slave in ${slaves} ; do
cat /sys/bus/w1/devices/${slave}/w1_slave > /tmp/temp-${slave}.txt
if grep -q YES /tmp/temp-${slave}.txt ; then
echo "INSERT INTO temps VALUES ('"${slave}"'," $(date +%s) "," $(awk 'NR==2 { print $10 }' /tmp/temp-${slave}.txt | awk -F= '{ print $2 }') ");"
fi
done
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment