• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

esp_now and web server

Q&A Forum › Category: Questions › esp_now and web server
0 Vote Up Vote Down
Michel Tremblay asked 3 years ago

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

Question Tags: esp_now and web server
4 Answers
0 Vote Up Vote Down
Jader Rosa answered 3 years ago

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.

0 Vote Up Vote Down
Michel Tremblay answered 3 years ago

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

0 Vote Up Vote Down
Michel Tremblay answered 3 years ago

Hello again
I forgot to mention that the esp_now and Wifi receiver is an esp32
 
michel

0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Hi Michel.
Were you able to solve the issue, then?
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.