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

边栏推荐
- The wechat installation package has expanded 575 times in 11 years, and the up owner: "98% of the documents are garbage"; Apple App store was exposed to a large number of pornographic apps; Four techn
- What are the advantages of Tita's OKR system over other similar products or shared documents?
- "The faster the code is written, the slower the program runs."
- Deploy dolphin scheduler high availability cluster based on rainbow
- 360入选中国安全产业全景图63个领域 ISC2022共话安全服务方向
- Tita 的OKR系统与其他同类型产品,或者是共享文档等相比,有什么优势?
- Application skills of AWS dynamodb
- Harmonyos third operation
- LANproxy mapping local development environment
- Containerd CTR run the ansible container and execute the complete command of ansible playbook task
猜你喜欢
![[soft test software evaluator] 2014 comprehensive knowledge over the years](/img/85/46c8fc696ae5249a9aca22b50493f0.jpg)
[soft test software evaluator] 2014 comprehensive knowledge over the years

简单实用的数据可视化案例

怎么使用C# Winform实现复制文件显示进度

Vulnhub range double trouble

Huawei Hongmeng 3 was officially released, and this security feature has solved a major pain point

记录一下使用R语言中关于formatC的错误

Visual display method of machine learning project

Flink怎么使用Savepoint

Deploy dolphin scheduler high availability cluster based on rainbow

Application of user portrait in precise push of wechat official account of scientific journals
随机推荐
Helm chart explanation and common commands: helm template / package / plugin
毕设-基于SSM高校后勤管理系统
携手长江存储,江波龙推出全球最小扩展卡
Exercise --- BFS
Dry goods semantic web, Web3.0, Web3, metauniverse, these concepts are still confused? (medium)
在所有浏览器中禁用带有元 HTML 标记的缓存
Jsonpath: a powerful rule parsing and parameter lookup tool for JSON
Bi Shi - University Logistics Management System Based on SSM
Nature review: preferential effects in the formation of microbial communities
【数字识别】基于Hopfield神经网络识别0-9数字附Matlab代码
Preliminary understanding of Panda3D audio and advanced interactive components
[soft test software evaluator] 2014 comprehensive knowledge over the years
The print version of imeta | international standard ISSN is officially confirmed, and the application for dual ISSN is completed
Xu Jinbo: AI protein prediction and design
Blood spitting finishing nanny level series tutorial - playing Fiddler bag capturing tutorial (5) - detailed explanation of fiddler monitoring panel
NDK 系列(6):说一下注册 JNI 函数的方式和时机
[stonedb fault diagnosis] database instance crash
[C language] simulate and implement string functions (Part 1)
并发和并行有什么区别?
See how Gan controls the image generation style step by step? Explain the evolution process of stylegan in detail