dth11 使用
直接获取温湿度代码
#include <DHTesp.h>
DHTesp DHT;//对象
void setup() {
Serial.begin(9600);
DHT.setup(2,DHT.DHT11);
}
void loop() {
Serial.print("Temperature = "); //温度
Serial.println(DHT.getTemperature());
Serial.print("Humidity = "); //湿度
Serial.println(DHT.getHumidity());
delay(3000);
}
post 到乐为物联
/*
http post DHT11
*/
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <DHTesp.h>
DHTesp DHT;
#define DHT11_PIN 2
const char* ssid = "Mar9le";
const char* password = "HHX88S";
const char* host = "http://www.lewei50.com/api/v1/gateway/updatesensors/01";
void setup() {
Serial.begin(115200);
delay(100);
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() !