当前位置:网站首页>Arduino read temperature
Arduino read temperature
2022-06-25 19:54:00 【JINYUBAOO】
1、 Installation temperature and humidity DHT11 library
step : project -》 Load the library -》 add to .ZIP Load the library ( Select to put your own compressed file )
2、 Physical connection
There are two different temperature and humidity modules
| Temperature and humidity module | Development board |
|---|---|
| VCC | 3.3V |
| GND | GND |
| DAT | Pin ( Self determination ) |
3、 Run code
// introduce DHT The library files , without , Download it from the Internet first , stay Arduino Import
#include <dht11.h>
dht11 DHT11;
// Set up DHT Pin by Pin 8, This is what I define
#define DHT11PIN 8
void setup() {
Serial.begin(9600);
Serial.println("DHT11 TEST PROGRAM");
Serial.print("LIBRARY");
// Output DHT The version number of the library
Serial.println();
}
void loop() {
Serial.println("\n");
int chk = DHT11.read(DHT11PIN);
// test DHT Whether it is connected correctly
Serial.print("Read sensor: ");
switch (chk)
{
case DHTLIB_OK:
Serial.println("OK");
break;
case DHTLIB_ERROR_CHECKSUM:
Serial.println("Checksum error");
break;
case DHTLIB_ERROR_TIMEOUT:
Serial.println("Time out error");
break;
default:
Serial.println("Unknown error");
break;
}
// Obtain measurement data
Serial.print("Humidity (%): ");
Serial.println((float)DHT11.humidity, 2);
Serial.print("Temperature °C): ");
Serial.println((float)DHT11.temperature, 2);
delay(2000);
}
4、 Exhibition

边栏推荐
- Automatic fitting when the applet reaches the top
- JS asynchronism (I. asynchronous concept, basic use of web worker)
- Vulnhub range the planes:earth
- Mail monitoring cloud script execution progress
- Vulnhub range - correlation:2
- Solve the problem that sublime Text3 package control cannot install plug-ins
- One night I worked as an XPath Terminator: XPath Helper Plus
- Force wechat page font size to be 100%
- Case: count the most characters and times
- ECS 7-day practical training camp (Advanced route) -- day01 -- setting up FTP service based on ECS
猜你喜欢

Use of serialize() and serializearray() methods for form data serialization
![QQ robot: self forbidden words management of group members [latest beta2 version]](/img/1b/7dcc8ed344c9f62870d76f16b99f1d.png)
QQ robot: self forbidden words management of group members [latest beta2 version]

JS asynchronism (I. asynchronous concept, basic use of web worker)

Vulnhub range - the planes:venus

rmi-registry-bind-deserialization

Why are life science enterprises on the cloud in succession?

Cutting feet to fit shoes - talking about the ramp reconstruction on the track

Google cloud SSH enable root password login

Apifox simple understanding -- the integrator of web side testing

Combing the latest Data Mining Event Scheme!
随机推荐
Electronic basic project construction & communication between main thread and rendering thread
Network security detection and prevention exercises (III)
Uni app through uni Navigateto failed to pass parameter (pass object)
Vulnhub range - the planes:venus
Vulnhub range the planes: mercury
Network security detection and prevention test questions (V)
Web container basic configuration
The meanings of /32, /48, /64 in IPv6 addresses
Why are life science enterprises on the cloud in succession?
Google cloud SSH enable root password login
Using flex to implement the Holy Grail layout is as simple as that
Applet canvas generate sharing Poster
Tcp/ip test questions (I)
Case: count the most characters and times
Guangzhou Sinovel interactive creates VR Exhibition Hall panoramic online virtual exhibition hall
Database data type design (the most detailed in the whole network)
What is an operator?
The functions in the applet page are better than those in app JS first execution solution
Many varieties of EA can be used
RPM package installation command