Types for output, DeepSleep

This commit is contained in:
Paul Warren 2022-07-01 19:06:28 +10:00
parent 249f0a11a0
commit 638d50c78b
1 changed files with 8 additions and 7 deletions

View File

@ -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);
}