当前位置:网站首页>FPGA collects DHT11 temperature and humidity
FPGA collects DHT11 temperature and humidity
2022-06-22 15:20:00 【Struggling Xiaopeng】
One . brief introduction
In the temperature and humidity sensor ,dht11 Is the most used one , In many classes , It is the first choice . Only one... Is needed IO mouth , Temperature and humidity collection can be completed . Share and use here FPGA To complete DHT11 A collection of temperature and humidity demo Share .
You can pay attention to WeChat official account if you need complete code. FPGA The journey reply DHT11-FPGA obtain
Two . Temperature and humidity collection
- The data transmission process includes the following three parts : Acquisition start , Collect data , End of collection .
- Acquisition start ,FPGA Pull down the data line , Then release , wait for dht11 Respond to .
- The collected data is 40bit, Respectively ( High to the end ) 8bit Humidity integer ,8bit Humidity decimal places ,8bit Temperature integer ,8bit Temperature decimal places ,8bit The checksum .
- The verification sum is the sum of temperature and humidity data 8 position .
- End of collection , Pull down the data cable from the machine .
The data transmission process is relatively easy , Let's elaborate on the continuity of each part .
(1) Acquisition start
- FPGA Pull down the data cable at least 18ms, recommend 20ms. Release the bus , Wait for the slave to pull down the bus response . After the response is received , The bus is released . The detailed process is as follows .

(2) Collect data
The data shows : data 0 : 50us Low level plus 26us~28us High level of . data 1:50us Low level plus 70us High level of 
(3) End of collection
Pull down the bus from the slave 50us.
The time here can be adjusted according to the actual test results . It's important , Otherwise, the collected data may be inaccurate .
3、 ... and . Code implementation
You can pay attention to WeChat official account if you need complete code. FPGA The journey reply DHT11-FPGA obtain
Here, a three-stage state machine is used to realize , It's more convenient . It can be easily determined by the transmission process that the entire acquisition process is determined by four states .
The following is the acquisition results obtained by the logic analyzer , You can see in the S_OVER in , A complete data has been collected .
By calculation 42 + 05 + 1D + 03 = 67 ( Hexadecimal ) It can be determined that the collected data is completely correct .
module DTH11(
input clk,
input rst,
inout dht11,
input dht11_req, // Data collection request
output dht11_down, // Data acquisition complete
output[7:0] tempH, // Temperature data integer
output[7:0] tempL, // Temperature data decimal
output[7:0] humidityH, // Temperature data integer
output[7:0] humidityL // Temperature data decimal
);
localparam S_IDLE = 'd0; // Idle state
localparam S_START = 'd1; // Start collecting data
localparam S_DATA = 'd2; // Receive the collected data
localparam S_OVER = 'd3; // Data acquisition complete
State transition process
- S_START: When the collection request comes , Enter the start state
- S_DATA:step Express start The four parts of the State , Pull down the main engine , Start and end of slave response and start of data transmission .
- S_OVER:step Indicates the number of received data , When the received data is 40 When , Get into S_OVER state
- S_IDLE : timeCount Lower the time to end and enter S_IDLE state .
[email protected](*)
begin
case(state)
S_IDLE:
if(dht11_req == 1'b1)
next_state <= S_START;
else
next_state <= S_IDLE;
S_START:
if(step == 'd4)
next_state <= S_DATA;
else
next_state <= S_START;
S_DATA:
if(step == 'd40)
next_state <= S_OVER;
else
next_state <= S_DATA;
S_OVER:
if(timeCount == Time50us)
next_state <= S_IDLE;
else
next_state <= S_OVER;
default:
next_state <= S_IDLE;
endcase
end
边栏推荐
- Go all out to implement the flood control and disaster relief measures in detail and in place, and resolutely protect the safety of people's lives and property
- 极致效率,云原生数据库TDSQL-C安身立命的根本
- 同花顺如何开户?在线开户安全么?
- flutter video_player实现监听和自动播放下一首歌曲
- A thorough understanding of singleton
- U++ programming array learning notes
- OpenVINO CPU加速调研
- Fight, programmer -- Chapter 42 will draw a bow like a full moon, look northwest and shoot Sirius
- Show me my personal work list for the past two years. I earn 6K a month in my spare time. It's so delicious to have a sideline
- Front and back management system of dessert beverage store based on SSM framework dessert mall cake store [source code + database]
猜你喜欢

RealNetworks vs. 微软:早期流媒体行业之争

擴散模型又殺瘋了!這一次被攻占的領域是...

Is the encryption market a "natural disaster" or a "man-made disaster" in the cold winter?

数据库连接池:压力测试

What happened to those who didn't go to college

时隔17年,刘亦菲再次刷屏式爆红:普通人不想被淘汰,也要懂得这件事

拜登签署两项旨在加强政府网络安全的新法案

What is the value of a website? Why build an independent station

专业“搬砖”老司机总结的 12 条 SQL 优化方案,非常实用!

The diffusion model is crazy again! This time the occupied area is
随机推荐
What happened to those who didn't go to college
Redistemplate serialization
网络安全的五大特点有哪些?五大属性是什么?
Go all out to implement the flood control and disaster relief measures in detail and in place, and resolutely protect the safety of people's lives and property
Thoroughly understand the factory mode
剑指Offer46——把数字翻译成字符串
Method of using inout signal in Verilog
RealNetworks vs. Microsoft: the battle in the early streaming media industry
U++ iterative Sorting Query learning notes
Fluentd is easy to get started. Combined with the rainbow plug-in market, log collection is faster
C # WinForm photo album function, picture zooming, dragging, preview Pagination
同花顺开户难么?网上开户安全么?
Countdown to the conference - Amazon cloud technology innovation conference invites you to build a new AI engine!
口令安全是什么意思?等保2.0政策中口令安全标准条款有哪些?
同花顺如何开户?在线开户安全么?
PowerPoint 教程,如何在 PowerPoint 中添加水印?
bochs 软件使用记录
那些令人懵逼的用户态&内核态
Random forest of machine learning
网站存在的价值是什么?为什么要搭建独立站