The Component
Wiring it Up
The little breakout board that the chip is attached to has three pins labeled 'G', 'R', and 'Y'. The 'G' pin goes to ground, the 'R' pin goes to +5V DC, and the 'Y' pin goes to Signal. In my case, the signal is pin 7 on the Raspberry Pi.Enable 1-Wire
From what I have been able to learn the sensor uses 1-Wire for the communications.I am running DietPi on the Raspberry Pi so I could not use the standard 'raspi-config' or the 'Raspberry Pi Configuration' in Raspbian. This left me with the option of adding
dtoverlay=w1-gpio
to the '/boot/config.txt' file. Just a quick edit of a file and I should be good to go. It turns out that on DietPi you need to edit the file '/DietPi/config.txt' in order to have the change survive a reboot.
Once dtoverlay is added to 'DietPi/config.txt' file, the Rasberry Pi will start communicating with the device. Take a look in the folder '/sys/bus/w1/devices'. One of the folders will start with '28-' that folder will contain a file name 'w1-slave' if you read the content of that file you will get something like
72 01 4b 46 7f ff 0e 10 57 : crc=57 YES
72 01 4b 46 7f ff 0e 10 57 t=23125
Notice the 't=' at near the end of the second line. This is the temperature in Celsius. This temperature is also missing a decimal point.
Go Code
Misc
The RW1820 is very similar to the DS18B20. There is a lot more information about the DS18B20.
Resources
Rayway International - ChineseRW1820 Datasheet - English
1-Wire
Enable 1-Wire Interface on the Raspberry Pi
DietPi
W1-GPIO - One-Wire Interface
Introduction to DS18B20
No comments:
Post a Comment