Good morning all.
If we take the program as it is:
https://randomnerdtutorials.com/esp32-esp-now-wi-fi-web-server/
I have two relays to add to this program. One for board 1 and the other for board 2
If I want to activate a relay if my temperature of board 1 is smaller and equal to ‘x’ and the second board is not connected.
I placed my if after this line
events.send(jsonString.c_str(), “new_readings”, millis());
My ‘if’ command works very well except that when I have the transmitter disconnected, the relay of this board is ‘on’ whereas as a precaution it should be off.
Someone has already tried to do something similar. If you have an example that would be great.
I am also trying to put my relays in the web page but I do not have much experience yet. I read my book and search
P.S. Not easy to explain. If you have any questions do not hesitate .
Thank you for your help
Hi Michel,
You should implement the heartbeat or keep it alive. if your system doesn’t respond either due to disconnection or any other problem then turn off the output.
hello,
I found my problem. Bad nesting with the if command. I reduced by putting the switch-case command with if commands inside. I modified part of the program to make it a watering system. 4 esp_now transmitter (esp8286) and an esp_now receiver and wifi page which activates valves at the same time. All I have to do is put the button valves that we can manually activate and where to see it if they are activated
switch(myData.id) {
box 1:
// statements
break;
box 2:
if ( myData.Moisture_Sol <= 40 )
{
digitalWrite(relay2, LOW);
Serial. println(“valve2 off”);
} else
{
digitalWrite(relay2, HIGH);
Serial. println(“valve2 on”);
}
break;
box 3:
if ( myData.Moisture_Sol <= 40 )
{
digitalWrite(relay3, LOW);
Serial. println(“valve3 off”);
}
else
{
digitalWrite(relay3, HIGH);
Serial. println(“valve3 on”);
}
break;
box 4:
if ( myData.Moisture_Sol <= 40 )
{
digitalWrite(relay4, LOW);
Serial. println(“valve4 off”);
}
else
{
digitalWrite(relay4, HIGH);
Serial. println(“valve4 on”);
}
break;
box 5:
if ( myData.Moisture_Sol <= 40 )
{
digitalWrite(relay5, LOW);
Serial.println(“valve5 off”);
}
else
{
digitalWrite(relay5, HIGH);
Serial.println(“valve5 on”);
}
break;
default:
// statements
break;
}
thanks and problem solved
Michael
Hello again
I forgot to mention that the esp_now and Wifi receiver is an esp32
michel