Nuffnang Ads

Sunday, 16 November 2014

Raspberry Pi with DS18B20 temperature sensor (part 1)

1. Hardware needed in this tutorial:-
     a) raspberry pi,
     b) DS18B20 sensor,
     c) 4.7k Ohm resistor
     d) some wires
     e) breadboard (optional)

2. Connect DS18B20 sensor to PIN7 (GPIO 4), the connection actually same as this post.

3. To read the data from sensor, some of the modules need to be loaded first. Run the following command:-
  modprobe w1-gpio
  modprobe w1-therm

4. Check whether raspberry pi can detect DS18B20 or not. Access to the /sys/bus/w1/devices. Then, run "ls" command. If the sensor is detected by raspberry pi, there will be an output start with 28....



5. Use "cat" command to display the temperature. The full command will be "cat /sys/bus/w1/devices/28*/w1_slave. See 't' value. In picture below, t=28437 means current temperature is 28.437 degree celcius.



No comments:

Post a Comment