We change the directory and print the files cd /sys/bus/w1/devices/ If you plan to connect several in series, it is best to test each one individually and make a note of the ID so that you do not confuse it later. So that the modules are loaded at every start, we enter them into the file /etc/modules: sudo nano /etc/modulesĪnd last add the following two lines: w1_gpioįor the next step, we first need the ID of the sensor. The modules should now be listed, if not a GPIO pin other than 4 is used or an error occurred while activating. We can find out if it worked by entering the following: lsmod If everything is wired accordingly, we can enable the 1-Wire protocol with it: sudo modprobe w1-gpio Shown is the wiring of or DS18B20 temperature sensor, including a resistor. But you can also switch several sensors in series (because it is based on the 1-Wire protocol). However, this is (so far) only possible on GPIO pin 4 (pin 7). The temperature sensor returns a 9 to 12 bit long value which can be read and converted. If you want a more advanced sensor, which can measure also humidity, you should take a look at the DHT11 or DHT22 sensor, which measures both – temperature and humidity.ĭescription of the 1-Wire Raspberry Pi Temperature Sensor The temperature sensor DS18B20 is also available as a waterproof version. In other projects, you could use this sensor even as a trigger for cooling your Raspberry Pi case and turning a fan on.įor this tutorial I have used the following parts: Temperature script for system lens how to#In this tutorial it is described how to use the DS18B20 Raspberry Pi temperature sensor and what software you will need. Using a 1-Wire Raspberry Pi temperature sensor makes it very easy to read it out and you will only need one GPIO pin. In projects like weather stations you want to know the exact value. One of the many applications of a Raspberry Pi is measuring the temperature.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |