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