Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to realize temperature and humidity Sensor DHT11 by Raspberry Pie

Shulou Source: shulou.com Published: 2022-06-01 22:57:07 10月04日 Update

This article mainly shows you "raspberry pie how to achieve temperature and humidity sensor DHT11", the content is easy to understand, clear, hope to help you solve your doubts, let the editor lead you to study and learn how to achieve temperature and humidity sensor DHT11 "this article.

1. Connect the line

I bought this DHT11 is rather depressed, three pins, did not indicate which is VCC, which is GND, searched a bunch on the Internet, marked for other sensors are clearly marked, mine only marked a plus or minus sign, and then consulted with a treasure boss, confirmed that it is + is VCC,- is GND, the middle is Data (maybe because I am a rookie in telecommunications, do not understand these jargon)

1-> 3.3v connect the first GPIO pin on the left

2-> GPIO data interface, you can connect one GPIO pin at will (the seventh pin corresponds to GPIO Pin # 4, corresponding to the following code)

3-> GND ground (6th pin or other GND)

2. Install the gpio driver (let's call it the driver, the principle is not clear)

Sudo apt-get install wiringpi

3. Run the example (C code)

# include # define MAX_TIME 100#define DHT11PIN 7 / / read data pin # define ATTEMPTS 5 / / retry 5 times when no responseint dht11_val [5] = {0meme0 0re0re0}; int dht11_read_val () {uint8_t lststate=HIGH; / / last state uint8_t counter=0; uint8_t jigsaw 0PowerI; for

Tags: Sensor pin raspberry clear code content article run data learn help drive depressed professional example reason principle that is interface easy to understand Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Redmi vpn Apple Docker