• 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

ESP32 wifi multisensor

Q&A Forum › Category: ESP32 › ESP32 wifi multisensor
0 Vote Up Vote Down
Yves BOURDON asked 5 years ago

Hello Sara and Rui ,

I’m new to this forum and I’m French, so forgive my bad English!

I am trying to make the ESP32_WiFi_Multisensor project work.

I use an ESP32 dev standard kit, W10, Chrome for browser.

Here is the problem:

When I choose for example the manual mode, I am obliged to start or close a reading of the sensors before each ON OFF command.

Indeed if I do not do it, the relay does not switch systematically, as if the header variable was not updated.

I know that my explanation is not very clear, but I have spent hours and hours finding a solution and I have not succeeded!

Can you help me ?

Thanks in advance.

Best regards.

Yves

Serial output

6 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 5 years ago

Hi Yves.
I think what is happening is that Google Chromes lefts one connection open and only on the second attempt, you are able to get things working.
Can you try following the suggestions in this post and see if it solves your problem: https://rntlab.com/question/solved-esp32-web-server-drops-connection-crashes/?
That explanation is for other web server example, but it can also be applied to that web server.
Regards,
Sara

0 Vote Up Vote Down
Yves BOURDON answered 5 years ago

Hi Sara,
Thank you so much for your answer.
I have tried your suggestion but unfortunately it doesn’t work.
I have tried with Opera , same issue.
I really thing that the problem lies in the code.
When I trie your WiFi_Wen_Server_Relays everything works like a charm whatever the internet explorer.
After checking the code difference I think the issue is in this part, that to be honest I don’t understand (you haven’t comment this part of code). Can you quickly explain it to me ?
client.println(“<script> function setMode(value) { var xhr = new XMLHttpRequest();”);
client.println(“xhr.open(‘GET’, \”/?mode=\” + value + \”&\”, true);”);
client.println(“xhr.send(); location.reload(true); } “);
client.println(“function setTimer(value) { var xhr = new XMLHttpRequest();”);
client.println(“xhr.open(‘GET’, \”/?timer=\” + value + \”&\”, true);”);
client.println(“xhr.send(); location.reload(true); } “);
client.println(“function setThreshold(value) { var xhr = new XMLHttpRequest();”);
client.println(“xhr.open(‘GET’, \”/?ldrthreshold=\” + value + \”&\”, true);”);
client.println(“xhr.send(); location.reload(true); } “);
client.println(“function outputOn() { var xhr = new XMLHttpRequest();”);
client.println(“xhr.open(‘GET’, \”/?state=on\”, true);”);
client.println(“xhr.send(); location.reload(true); } “);
client.println(“function outputOff() { var xhr = new XMLHttpRequest();”);
client.println(“xhr.open(‘GET’, \”/?state=off\”, true);”);
client.println(“xhr.send(); location.reload(true); } “);
client.println(“function updateSensorReadings() { var xhr = new XMLHttpRequest();”);
client.println(“xhr.open(‘GET’, \”/?sensor\”, true);”);
client.println(“xhr.send(); location.reload(true); }</script></body></html>”);
Thank you so much for your support.
Yves
 
 
 

0 Vote Up Vote Down
Steph answered 5 years ago

Hi Yves,

Sara sent you a very detailed reply on your other post “Project 1 : need somme help to understand !“. Maybe it would be better not to multiply posts that deal with the same subject 😉

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

Hi Yves.
I’ve tested the example again, and it is not working appropriately. It was working fine in the past.
What is happening is that the ESP32 is trying to update the state and reloading the page and the same time, which is causing the issues.
You were right, the issue was on those lines. You can check a working version of the code here: https://github.com/RuiSantosdotme/ESP32-Course/blob/master/code/ESP32_WiFi_Multisensor/ESP32_WiFi_Multisensor.ino
Now, you need to wait 1.5 seconds until the webpage uploads. This ensures that we don’t miss requests.
Thanks for pointing that issue.
Regards,
Sara
 
 

0 Vote Up Vote Down
Yves BOURDON answered 5 years ago
Hi Sara,
First of all thank you for your quick response!
I tried the new code, and everything works fine. Well done !!!!
On the other hand I would like to apologize for having opened 2 posts for the same subject (thank you for pointing it Stéphane).
I just saw your explanation of the Javascript code and it is now perfectly clear to me.
Your support is fantastic and your books very educational!
I will finish my temperature and humidity regulation project and as soon as I finish it I will send you some pictures and the code!
Sincerely.
Yves

 

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

Hi Yves.
I’m glad it is working now.
No need to apologize. But, next time try to keep everything related to the same subject on the same question. Otherwise, it is difficult for us to keep track of everything.
Thank you for your nice feedback! I’m really happy that you like our resources 😀
And don’t forget to share your project when it’s finished.
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

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 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.