Created
November 5, 2013 16:06
-
-
Save aguegu/7321376 to your computer and use it in GitHub Desktop.
get temperature from ds18b20 on RPi in Bash
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 | |
modprobe w1-gpio | |
modprobe w1-therm | |
if [ -d /sys/bus/w1/devices ]; then | |
id=$(ls /sys/bus/w1/devices/ | head -n 1); | |
temperature=$(tail -n 1 /sys/bus/w1/devices/$id/driver/$id/w1_slave | grep -o "[-0-9]*$") | |
echo "scale=3;" $temperature "/ 1000.0" | bc | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment