這是 dht 1.2.3 的範例

// Example testing sketch for various DHT humidity/temperature sensors

// Written by ladyada, public domain

#include "DHT.h"

#define DHTPIN 2     // what digital pin we're connected to

// Uncomment whatever type you're using!

//#define DHTTYPE DHT11   // DHT 11

#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321

//#define DHTTYPE DHT21   // DHT 21 (AM2301)

// Connect pin 1 (on the left) of the sensor to +5V

// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1

// to 3.3V instead of 5V!

// Connect pin 2 of the sensor to whatever your DHTPIN is

// Connect pin 4 (on the right) of the sensor to GROUND

// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

// Initialize DHT sensor.

// Note that older versions of this library took an optional third parameter to

// tweak the timings for faster processors.  This parameter is no longer needed

// as the current DHT reading algorithm adjusts itself to work on faster procs.

DHT dht(DHTPIN, DHTTYPE);

void setup() {

Serial.begin(9600);

Serial.println("DHTxx test!");

dht.begin();

}

void loop() {

// Wait a few seconds between measurements.

delay(2000);

// Reading temperature or humidity takes about 250 milliseconds!

// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)

float h = dht.readHumidity();

// Read temperature as Celsius (the default)

float t = dht.readTemperature();

// Read temperature as Fahrenheit (isFahrenheit = true)

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("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("Humidity: ");

Serial.print(h);

Serial.print(" %\t");

Serial.print("Temperature: ");

Serial.print(t);

Serial.print(" *C ");

Serial.print(f);

Serial.print(" *F\t");

Serial.print("Heat index: ");

Serial.print(hic);

Serial.print(" *C ");

Serial.print(hif);

Serial.println(" *F");

}

php DHT22,很奇怪,IDE版本导致DHT22输出异常相关推荐

  1. log4j和logback的冲突导致日志输出异常

    2019独角兽企业重金招聘Python工程师标准>>> 前一阵在在项目中碰到一个日志问题.工程使用的是log4j,log4j.xml中也配置了工程日志路径和策略,并把日志级别定为wa ...

  2. 女朋友天天气我怎么办_关于我的天气很奇怪

    女朋友天天气我怎么办 带有扭曲的天气应用 (A Weather App with a Twist) Is My Weather Weird?™ is a weather app with a twis ...

  3. 网页服务器卡是什么原因吗,网速很快但打开网页速度很慢什么原因导致的

    我们使用电脑和手机时候最不能忍受就是设备又卡又慢了,严重影响我们工作或者游戏体验.有时用户打开网页的速度慢,是因为其中某个环节出了问题,或者不够优化.下面笔者整理简要总结下网页打开速度慢的原因,主要有 ...

  4. 记录安装torchtext会自动更新pytorch版本导致gpu加速失效问题

    1.配置描述 OS:win10 显卡:Nvidia GeForce MX150 版本426.00 cuda:cuda 10.1 且无法升级到10.1之后的版本 python:3.9.7 原torch版 ...

  5. 发现一个很奇怪的现象,MyBaits 的 insert方法一直返回-2147482646

    点击关注公众号,Java干货及时送达来源:cnblogs.com/wyq178/p/8652443.html 前几天在做项目demo的时候,发现有一个很奇怪的现象: 就是MyBatis发现更新和插入返 ...

  6. QT中关于头文件一个很奇怪的问题

    最近在用QT Creator时候遇上一个很奇怪的问题,以往添加头文件使用#include<QStringListModel>这样的格式就可以,但是现在有时候却编译通不过,报了一大堆的错误, ...

  7. 一个很奇怪的 OpenCV出错:resize的坑

    简 介: 在cv2.resize中会存在很多"坑".但对象的数据格式不是"float"造成出错,给出的提示非常具有迷惑性.注意这一点会使得后面的编程更加的愉快. ...

  8. AttributeError: module 'tensorflow' has no attribute 'placeholder'等一系列tensorflow版本导致的问题

    新人tensorflow2.1版本导致程序我无法运行最简单的办法 法1 tensorflow.compat.v1 import tensorflow.compat..v1 as tf tf.disab ...

  9. LINQ是死是活?——很奇怪为什么会有这样的话题?

    LINQ是死是活??? 如果我问您:机器代码死了吗?汇编死了吗?C死了吗?VB6.0死了吗?Delphi死了吗?您可能会觉得我很无聊.所以我觉得"LINQ是死是活"的说法也很奇怪? ...

最新文章

  1. Java项目:在线点餐系统(java+Springboot+Maven+mybatis+Vue+mysql+Redis)
  2. WPF加载相对路径的图片的解决方法
  3. What is Wiki?
  4. V神以太坊:Casper 权益证明与分片技术最新进展
  5. 案例39-后台查询订单详情代码实现
  6. pyltp在ubuntu20.04下面的安装办法
  7. day53-Django之路由系统
  8. 信息学奥赛一本通(1125:矩阵乘法)
  9. 如何用孩子兄弟表示法存储树c语言,C语言,数据结构,树的孩子兄弟表示法,程序一切正常,但是有个问题不太懂了,园豆不多,帮帮忙,求助一下....
  10. Git 不能只会 pull 和 push,试试这5条提高效率的命令吧!
  11. webpack资源管理
  12. 那个说技术本身并不可耻的快播王欣回来了!
  13. Python第二天(字典)
  14. UIApplication keyWindow rootViewController 为 nil 的
  15. 在Ubuntu 20.04(Linux Mint 各衍生版)上安装使用国金证券 通达信 客户端软件。
  16. 都2022了,我为什么还要写博客?
  17. android设置透明主题后背景为黑色,android – 活动应该是透明的,但有黑色背景
  18. 调用win api将指定名称的打印机设置为默认打印机
  19. 初探强化学习(11)Dyna类型的强化学习
  20. 用vue简单写一个音乐播放器

热门文章

  1. display:grid 网格布局的基础使用
  2. 哲学书籍推荐,一生不可不读的10本哲学书籍
  3. 接手别人维护的网吧注意事项
  4. 2022-03-03 html网页布局练习(二):使用float浮动+html5新增标签进行网页布局
  5. C#笔记进阶篇06 委托
  6. 华清远见 day02
  7. 【Ubuntu 篇】关于Ubuntu启动报错“hdaudio hdaudioC0D2: unable to bind codec”
  8. 域名解密 商家联盟会员消费管理系统_连锁店会员积分系统 带微信(域名加密的) aqinxiaodian
  9. 第 11 章 Scrapy - Python web scraping and crawling framework
  10. 大学英语口语测试软件,大学英语口语测试技巧