Skip to content

Instantly share code, notes, and snippets.

@sourceperl
Created June 1, 2017 17:29
Show Gist options
  • Save sourceperl/ab5b8d5596a8d7eedc416908ff5e0e2d to your computer and use it in GitHub Desktop.
Save sourceperl/ab5b8d5596a8d7eedc416908ff5e0e2d to your computer and use it in GitHub Desktop.
Temperature from DS18B20 on a Raspberry Pi
#!/bin/bash
# read DS18B20 (default is data connect on GPIO4)
# add 'dtoverlay=w1-gpio' to /boot/config.txt to load one-wire device tree and reboot
# test on Rpi with Raspbian Jessie
while [ true ]
do
cat /sys/bus/w1/devices/28-0000040de8f8/w1_slave | grep 't=' | awk -F 't=' '{printf("%.2f\n", $2/1000)}'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment