|
|
|
@ -1,10 +1,15 @@
|
|
|
|
|
|
|
|
//安装DHT11库 DHT sensor library
|
|
|
|
|
|
|
|
//安装mqtt客户端 PubSubClient 库
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <DHT.h>//调用dht11驱动库
|
|
|
|
#include <DHT.h>//调用dht11驱动库
|
|
|
|
#include <ESP8266WiFi.h>
|
|
|
|
#include <ESP8266WiFi.h>
|
|
|
|
#include <ESP8266WebServer.h>
|
|
|
|
#include <ESP8266WebServer.h>
|
|
|
|
#include <ESP8266HTTPClient.h>
|
|
|
|
#include <ESP8266HTTPClient.h>
|
|
|
|
#include <PubSubClient.h>
|
|
|
|
#include <PubSubClient.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "SSD1306Wire.h"
|
|
|
|
//oled头文件
|
|
|
|
|
|
|
|
// #include "SSD1306Wire.h"
|
|
|
|
|
|
|
|
|
|
|
|
// const int I2C_ADDR = 0x3c; // oled屏幕的I2c地址
|
|
|
|
// const int I2C_ADDR = 0x3c; // oled屏幕的I2c地址
|
|
|
|
// #define SDA_PIN D4 // SDA引脚,默认gpio4(D2)
|
|
|
|
// #define SDA_PIN D4 // SDA引脚,默认gpio4(D2)
|
|
|
|
@ -22,10 +27,8 @@ float Humidity;
|
|
|
|
//定义WIFI信息
|
|
|
|
//定义WIFI信息
|
|
|
|
const char* ssid = "iStoreOS_2.4G"; // Enter SSID here
|
|
|
|
const char* ssid = "iStoreOS_2.4G"; // Enter SSID here
|
|
|
|
const char* password = "452131wW"; //Enter Password here
|
|
|
|
const char* password = "452131wW"; //Enter Password here
|
|
|
|
|
|
|
|
|
|
|
|
const char* host = "192.168.3.26:8873";
|
|
|
|
const char* host = "192.168.3.26:8873";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// MQTT代理
|
|
|
|
// MQTT代理
|
|
|
|
const char *mqtt_broker = "47.242.184.139";
|
|
|
|
const char *mqtt_broker = "47.242.184.139";
|
|
|
|
const char *topic = "/device/esp8266/001";
|
|
|
|
const char *topic = "/device/esp8266/001";
|
|
|
|
|