|
|
|
@ -28,9 +28,9 @@ void setup() {
|
|
|
|
|
|
|
|
|
|
Serial.println("DHT MQTT Logger:" + nodeID + " Starting\n");
|
|
|
|
|
|
|
|
|
|
dht.setup(D4, DHTesp::DHT22);
|
|
|
|
|
dht.setup(D4, DHTesp::DHT11);
|
|
|
|
|
|
|
|
|
|
wifi_set_sleep_type(LIGHT_SLEEP_T);
|
|
|
|
|
//wifi_set_sleep_type(LIGHT_SLEEP_T);
|
|
|
|
|
wifi();
|
|
|
|
|
|
|
|
|
|
if (client.connect((char*) nodeID.c_str())) {
|
|
|
|
@ -60,14 +60,14 @@ void wifi() {
|
|
|
|
|
Serial.println(WiFi.localIP()); // Show device's IP address
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
|
void publish(const char * topic, T msg)
|
|
|
|
|
//template <typename T>
|
|
|
|
|
void publish(const char * topic, float msg)
|
|
|
|
|
{
|
|
|
|
|
if (!client.connected()) {
|
|
|
|
|
client.connect((char*) nodeID.c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
client.publish(nodeID + "/" + topic, String(msg));
|
|
|
|
|
client.publish(String(nodeID + "/" + topic), String(msg));
|
|
|
|
|
Serial.println(nodeID + "/" + topic + ": " + String(msg));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -88,8 +88,9 @@ void loop() {
|
|
|
|
|
|
|
|
|
|
publish("temp", t);
|
|
|
|
|
publish("relative_humidity", h);
|
|
|
|
|
publish("heat_index", String(hic));
|
|
|
|
|
publish("heat_index", hic);
|
|
|
|
|
|
|
|
|
|
delay(SLEEP_MINUTES * 60 * 1000L);
|
|
|
|
|
//delay(SLEEP_MINUTES * 60 * 1000L);
|
|
|
|
|
ESP.deepSleep(SLEEP_MINUTES * 60 * 1e6);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|