当前位置:网站首页>proteus仿真arduino中调用DHT11/22温湿度传感器
proteus仿真arduino中调用DHT11/22温湿度传感器
2022-07-27 20:43:00 【河西石头】
获取驱动库
首先,我们利用arduino的IDE获取温湿度传感器的驱动库,库管理器中搜索dht11即可。
如果发现有其他依赖的库需要安装,也一起安装吧!
测试驱动库
安装好了之后,我们就可以在IDE的实例库中找到测试实例
打开实例,编译一次,发现没有问题,那么说明我们的驱动库下载好了。接下来我们就可以打开proteus绘制电路图,来仿真了。
proteus仿真
绘制电路图

代码
代码为测试dht11的代码,即驱动实例库中自带:
#include "DHT.h"
#define DHTPIN 8 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT11 // DHT 22 (AM2302), AM2321
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
Serial.println(F("DHTxx test!"));
dht.begin();
}
void loop() {
// Wait a few seconds between measurements.
delay(2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
// Compute heat index in Fahrenheit (the default)
float hif = dht.computeHeatIndex(f, h);
// Compute heat index in Celsius (isFahreheit = false)
float hic = dht.computeHeatIndex(t, h, false);
Serial.print(F("Humidity: "));
Serial.print(h);
Serial.print(F("% Temperature: "));
Serial.print(t);
Serial.print(F("°C "));
Serial.print(f);
Serial.print(F("°F Heat index: "));
Serial.print(hic);
Serial.print(F("°C "));
Serial.print(hif);
Serial.println(F("°F"));
}
仿真

边栏推荐
- Blood spitting finishing nanny level series tutorial - playing Fiddler bag capturing tutorial (5) - detailed explanation of fiddler monitoring panel
- Security-001
- Keming food: the average increase in the sales price of various series of products is about 5%
- Interviewer: I can't carry a backpack at all. Are you going by yourself or I'll give you a lift?
- VIM editor tutorial
- 疫情之下,台积电一季度增长超预期,7nm占比35%!二季度或创新高
- Disable caching with meta HTML tags in all browsers
- Learn more about xxE injection
- Blender plug-in of 2022
- Tita 的OKR系统与其他同类型产品,或者是共享文档等相比,有什么优势?
猜你喜欢
编辑复制粘贴判定问题(bug?),所见即所得显示符号问题反馈。

NDK 系列(6):说一下注册 JNI 函数的方式和时机

Find and leverage xxE – XML external entity injection

Nature review: preferential effects in the formation of microbial communities
![[signal processing] weak signal detection in communication system based on the characteristics of high-order statistics with matlab code](/img/a7/8f0d929457d285adc8020c7f5d33ea.png)
[signal processing] weak signal detection in communication system based on the characteristics of high-order statistics with matlab code

营收、利润两位数增长,华润怡宝悄悄打造了这些过亿新品

用户画像在科技期刊微信公众号精准推送中的应用

CaEGCN: Cross-Attention Fusion based Enhanced Graph Convolutional Network for Clustering 2021

一篇文章读懂人工神经网络

Introduction to the paper | distributed graph simulation
随机推荐
NDK 系列(6):说一下注册 JNI 函数的方式和时机
怎么使用xshell免费版
Application of user portrait in precise push of wechat official account of scientific journals
Deploy dolphin scheduler high availability cluster based on rainbow
突发,微信重要通知
Excel VBA finds out the maximum and minimum values of a column of time, and repeatedly pastes multiple values according to the actual situation
MapReduce(三)
Huawei Hongmeng 3 was officially released, and this security feature has solved a major pain point
深入了解 XXE 注射
用户画像在科技期刊微信公众号精准推送中的应用
Node-RED系列(三十):使用持久化ui-table 刷新页面不清空上一次的table数据
360入选中国安全产业全景图63个领域 ISC2022共话安全服务方向
Find and leverage xxE – XML external entity injection
【信号处理】基于高阶统计量特征的通信系统中微弱信号检测附matlab代码
Flink怎么使用Savepoint
WWW 2019 | HAN:异质图注意力网络
[stonedb fault diagnosis] database instance crash
Google executives: 40% of "generation Z" are more willing to use tiktok to cannibalize Google's core products
回Mixlab三天,“创造力团队”治好了我的精神内耗
Blood spitting finishing nanny level series tutorial - playing Fiddler bag capturing tutorial (5) - detailed explanation of fiddler monitoring panel