ESP32 Thermostat


WiFi thermostat developed around an ESP32 circuit + OLED display. Particular attention has been paid to the WEB interface (thanks to my friend Stéphane Calderoni for his help) compatible with all web browsers and smartphones.
If you are interested in buying this project as a kit of parts please go to its Elektor Jumpstarter page. There you'll find a slightly improved & extended version of this project renamed to 'Automator'. If enough people sign up for a kit, Elektor will launch its production.
It was while making the excellent Elektor Wifi Thermostat that I came up with the idea for this achievement..
Roy Aarts & Clemens Valens of Lab Elektor have been able to optimize the use of ESP8266
I tried porting their software to an ESP32, but gave up in the face of the work it took.
So I decided to start from scratch, taking inspiration from what had already been done (Web interface, NTP clock, regulation with programmable hysteresis, etc.), but by significantly improving the Web interface and its shortcomings at the time ( in particular the Java script did not allow a real real-time refresh of the user interface).
I have also decided to add a small OLED screen, which is very practical and which allows this thermostat to be used even if the WiFi connection is interrupted (degraded mode).
It was while making the excellent Elektor Wifi Thermostat that I came up with the idea for this achievement..
Roy Aarts & Clemens Valens of Lab Elektor have been able to optimize the use of ESP8266
I tried porting their software to an ESP32, but gave up in the face of the work it took.
So I decided to start from scratch, taking inspiration from what had already been done (Web interface, NTP clock, regulation with programmable hysteresis, etc.), but by significantly improving the Web interface and its shortcomings at the time ( in particular the Java script did not allow a real real-time refresh of the user interface).
I have also decided to add a small OLED screen, which is very practical and which allows this thermostat to be used even if the WiFi connection is interrupted (degraded mode).
Updates from the author
ybourdon 3 years ago
You can find it under the file Other.
Regards.
Yves
ElektorLabs 3 years ago
ybourdon 3 years ago
Heinz2 3 years ago
When I remove the USB connector from ESP32, the wifi connection is interrupted.
If I re-establish the connection between ESP and PC, the connection to wifi is re-established.
I would be glad to get an answer.
Thanks
ybourdon 3 years ago
TIMER OFF is correct. It only means that the relay always stays to OFF. So you don't have any regulation.
Perhaps I have to find another sentence . Instead of "Timer disabled", I could write "Don't care Timer".
My English is not so good, perhaps you have another idea ?
Thank you for your reply.
HaSch 3 years ago
ybourdon 3 years ago
I don't have this strange issue.
Also try to clear the cache of your browser to be sure to use the last js update.
Sorry if you have a bug I have never seen !
Regards.
Yves
HaSch 3 years ago
Regards,
Hans
HaSch 3 years ago
Why is that line necessary? I passed the variable mesureT to web interface but it wasn't handled correctly. The issue seems to be in this line in thermostat.html: %TEMP% contains the value of mesureT with 2 places after decimal point but shown in web server is "temperature" as integer. I didn't figured out why. Maybe you have an idea...
ElektorLabs 3 years ago
webserver.ino String(mesureT) converts float to string with 2 decimals (default) (provided by ESP32 boards package)
thermostat.js The last line replaces the string in the webpage "%TEMP%" by t (converted to string with one decimal).
As we see, there are many places where things can go wrong. Furthermore, the value displayed on the OLED is obtained in another way, which explains why the two values may be different.
screen.ino
I don't know where things go wrong, but a good fix would be to convert mesureT to a string that is used by both screen.ino and webserver.ino:
Thermostat.ino webserver.ino thermostat.js screen.ino
Untested! After this line mesureT is rounded and has only one decimal.
HaSch 3 years ago
Of course mesureT_str needs to be defined: After that it compiles without an error but the result is the same: OLED showing 1 decimal and in web interface the decimal is always 0.
Of course I uploaded changes in web interface to the board.
ElektorLabs 3 years ago
The substring boundaries 11 & 15 are wrong, they should be 12 & 16. The same is probably true for the relay className indexes, they should be moved to the right too.
Actually, this whole function is unsafe and should use string splitting instead of substring extraction. Also it would be much easier if the separators used by webserver.ino were not double spaces but just a single special character like '|'. Then the javascript parser could be something like this:
Untested!
ybourdon 3 years ago
I will check tomorrow.
ybourdon 3 years ago
I have added an OTA facility.
I will published the whole code tomorrow (version 1.50).
I have checked and rechecked without any issue.
Can you check again your hardware Hans ? Did you put pull up as explained ?
HaSch 3 years ago
If you would like I can return my (working) version of the software with all comments completely translated into English language and the changes Clemens (ElektorLabs) suggested. But I did not yet build in splitting with '|'.
HaSch 3 years ago
ybourdon 3 years ago
I have also corrected minor bugs and included Clemens "splitting" suggestion !
If everything is correct I will include Hans translation in a next revision. Thank you so much !
HaSch 3 years ago
Edit: Maybe this idea is not so good. I will think about it.
ybourdon 3 years ago
It seems to me that you forgot to solder R14 witch is a pull up for IO22.
The OLED screen indicates TIMER OFF when no Timer condition is reached (either always ON or no selection on a particular day).
That seems correct to me !
Relay is OFF because TIMER is OFF.
tressieres 3 years ago
Thanks,
Laurent
tressieres 3 years ago
Thanks,
Laurent
ybourdon 3 years ago
https://www.elektormagazine.com/magazine/elektor-183/59826.
Please forget any previous software as many issues (including this solved by HaSch : thank you !) have been solved.
Enjoy !
HaSch 3 years ago
in web interface temperature is only shown as integer, it should be shown with 1 decimal place. I didn't find yet where to correct.
If "Timer Disabled" has NOT a check mark and NO weekday has a check mark the OLED is showing "Timer OFF". Is that correct? Any other combinations showing "Manual".
Best regards,
Hans
ybourdon 3 years ago
Is it possible you forgot to update SPIFF files ?
They must be in data folder.
Regards.
Yves
HaSch 3 years ago
img-2268.jpg (758kb)