ajout print connection wifi

This commit is contained in:
habsinn 2021-11-30 12:27:35 +01:00
parent 45b659f593
commit 33af2705ab

View file

@ -30,8 +30,9 @@ void setupWIFI(const char *wifi_name, const char *password)
Serial.print("Connecting to "); Serial.print("Connecting to ");
Serial.print(wifi_name); Serial.print(wifi_name);
while (WiFi.status() != WL_CONNECTED) while ((WiFi.status() != WL_CONNECTED) && (millis() <= 60000))
{ {
Serial.println("Nouvelle tentative de connexion...");
delay(500); delay(500);
Serial.print('.'); Serial.print('.');
} }
@ -47,7 +48,7 @@ void reconnect(void)
while (!MqttClient.connected()) while (!MqttClient.connected())
{ {
Serial.print("."); Serial.print(".");
if (MqttClient.connect(ESPNAME, MQTT_USER, MQTT_PWD)) if (MqttClient.connect(ESPNAME, MQTT_USER, MQTT_MDP))
{ {
Serial.println("Connected."); Serial.println("Connected.");
} }
@ -132,7 +133,7 @@ void writeMessage(char *txt, float *temp, float *hum, int number)
void setup() void setup()
{ {
Serial.begin(9600); Serial.begin(9600);
setupWIFI(SSID, MQTT_PWD); setupWIFI(SSID, SSID_PWD);
setupMQTT(MQTT_ADDRESS, MQTT_PORT); setupMQTT(MQTT_ADDRESS, MQTT_PORT);
initSensors(sensors, SENSORS_NUMBER); initSensors(sensors, SENSORS_NUMBER);
TimeClient.begin(); TimeClient.begin();
@ -157,6 +158,9 @@ void loop()
readSensors(sensors, temp, hum, SENSORS_NUMBER); readSensors(sensors, temp, hum, SENSORS_NUMBER);
writeMessage(msg, temp, hum, SENSORS_NUMBER); writeMessage(msg, temp, hum, SENSORS_NUMBER);
Serial.print("une trame de data : ");
Serial.println(msg);
TimeClient.update(); TimeClient.update();
TimeClient.getFormattedTime().toCharArray(time, 30); TimeClient.getFormattedTime().toCharArray(time, 30);
@ -167,6 +171,7 @@ void loop()
MqttClient.publish(TOPIC, date); MqttClient.publish(TOPIC, date);
delay(2000); delay(2000);
Serial.println("Extinction de l'ESP ! ");
sleep(); sleep();
} }