当前位置:网站首页>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"));
}
仿真

边栏推荐
- Pro multi store version system, versatile is it!
- Desai wisdom number - other charts (parallel coordinate chart): family's willingness to allocate assets in the future
- 使用灰度滤镜
- 软件测试功能测试全套常见面试题【功能测试】面试总结4-2
- [elm classification] classification of UCI data sets based on nuclear limit learning machine and limit learning machine, with matlab code
- CaEGCN: Cross-Attention Fusion based Enhanced Graph Convolutional Network for Clustering 2021
- NDK series (6): let's talk about the way and time to register JNI functions
- Harmonyos third operation
- LANproxy mapping local development environment
- Jupyter notebook solves the problem that printing information cannot be viewed after closing the browser
猜你喜欢
软件测试功能测试全套常见面试题【功能测试】面试总结4-2

Normality of confidence interval

寻找和利用 XXE – XML 外部实体注入

NDK series (6): let's talk about the way and time to register JNI functions

机器学习项目可视化展示方法

Lianmai live broadcast system software - voice chat system

Preliminary understanding of Panda3D audio and advanced interactive components

Cloudcompare & PCL point cloud equally spaced slices

Starfish Os X MetaBell战略合作,元宇宙商业生态更进一步

Desai wisdom number - other charts (parallel coordinate chart): family's willingness to allocate assets in the future
随机推荐
软件测试功能测试全套常见面试题【功能测试】面试总结4-2
用户画像在科技期刊微信公众号精准推送中的应用
NDK 系列(6):说一下注册 JNI 函数的方式和时机
What are the advantages of Tita's OKR system over other similar products or shared documents?
Www 2019 | Han: heterograph attention network
[soft test software evaluator] 2014 comprehensive knowledge over the years
【图像检测】基于Combined Separability Filter实现鼻孔和瞳孔等圆检测matlab源码
[signal denoising] signal denoising based on Kalman filter with matlab code
QT with OpenGL(Shadow Mapping)(平行光篇)
Lianmai live broadcast system software - voice chat system
WWW 2019 | HAN:异质图注意力网络
Introduction to the paper | language model for long text under transformer architecture
Application of user portrait in precise push of wechat official account of scientific journals
2022/7/26
After returning to mixlab for three days, "creative team" cured my spiritual internal friction
Google executives: 40% of "generation Z" are more willing to use tiktok to cannibalize Google's core products
记录一下使用R语言中关于formatC的错误
XML 外部实体 (XXE) 漏洞及其修复方法
Pentium快速系统调用学习
Bi Shi - University Logistics Management System Based on SSM