Raspberry Pi 1-Wire Sensor

enable 1-Wire

sudo raspi-config

5 Interfacing Options -> P7 1-Wire -> enable

connect your 1-Wire device (here DS18b20)
Pin 1 (black) GND
Pin 2 (yellow) DATA (RPi GPIO 4 / Pin 7)
Pin 3 (red) VCC(+3.3V)
Connect Pin 2 & Pin 3 with 4,7 kOhm resistor (compare)

search for your device

ls /sys/bus/w1/devices/

e.g. 28-041650c7e4ff

get sensor value

temparray=($(cat /sys/bus/w1/devices/28-041650c7e4ff/w1_slave)) && echo ${temparray[21]} | cut -c3-7

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.