Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize temperature and humidity Sensor DHT11 by Raspberry Pie

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report