Help Needed: Building an Autonomous Pool Management System with ESP32 Ethernet and ESP Easy
Moderators: grovkillen, Stuntteam, TD-er
Help Needed: Building an Autonomous Pool Management System with ESP32 Ethernet and ESP Easy
Hello everyone,
First, let me apologize for any language mistakes as I’m French and relying on a translator.
I’m currently working on an autonomous pool management system using an ESP32 ETH01 running ESP Easy. Here's an overview of my project:
Components and Setup
ESP32 ETH01: Serves as the core of the system.
Relays (x4):
Pool filtration.
Pool lighting.
Heat pump control (dry contact switch for remote).
Reserved for future use.
Relays are powered at 5V, with 3.3V control signals from the ESP32.
Optocouplers (x3):
Monitor the state of the pool filtration, heat pump, and submersible pump in the decompression well.
Connected to a PCF8574 module due to GPIO limitations caused by Ethernet usage.
PCF8574 Module:
Handles GPIO extension for the optocouplers.
Includes a 2-position ON/OFF switch for manual/automatic filtration management and a 3-position ON/OFF/ON switch for filtration modes:
Forced ON.
OFF.
Back to manual/automatic.
OLED SH1106 Display: Shows key information:
Pool water temperature.
Filtration state.
Current mode (manual, automatic, forced, stop, or winter).
ADS1115: Prepares for future pH measurement.
Temperature Sensors (x3): DS18B20 for water, outdoor, and pool house temperatures.
Power: The system is powered by a PoE USB-C adapter:
ESP32, relays, and optocouplers use 5V.
I2C devices and temperature sensors are powered by 3.3V from the ESP32.
Electrical Precautions
The filtration relay controls a Schneider Electric dry-contact relay, which isolates the ESP32 from high voltage and provides protection against voltage spikes (using a snubber). This prevents damage and wear on the relay due to the inductive load from the pool pump.
Current Status
I’ve successfully wired all components and confirmed compatibility:
GPIO2: Pool filtration (device: Filtration, values: EtatFiltration).
GPIO4: Pool lighting (device: Eclairage, values: EtatEclairage).
GPIO12: Heat pump (device: PAC, values: EtatPAC).
GPIO14: Reserved for future use.
GPIO15: Temperature sensors (values: Pool, Outdoor, PoolHouse).
I2C (SDA/SCL): Connected to the ADS1115, PCF8574, and OLED display.
The system is integrated with Jeedom via the ESPEasy and Piscine plugins for automatic management. However, the ESP32 is designed to remain fully functional as a standalone system in case Jeedom fails.
Currently, I use an Arduino controlled by Jeedom, but this ESP32-based system will eventually replace it.
Challenges
Rules:
I’m struggling to save rules when using Ethernet mode on ESP Easy.
I’ve posted about this issue viewtopic.php?t=10532: Ethernet Rules Saving Problem.
HTML Dashboard:
I want to create an HTML interface to monitor temperatures and relay states via my iPhone. I’ve tried the fetch.html tool but face stability issues. I also attempted my own code with ChatGPT's help, but I’m unable to fetch temperatures successfully.
Automation Modes:
I still need to program the rules for filtration modes (manual, automatic, forced, stop, winter).
Future Plans
In the future, I would like to replace my current prototype PCB with a real, properly designed PCB. However, that will be another story . For now, this remains a prototype.
Photos and Request
I’ve attached photos showing my progress. I would greatly appreciate any advice, especially for resolving the rules-saving issue and developing a stable HTML interface.
Edit: The PCF8574 module has been flipped and connected (just like the ESP32) to female header pins for easy replacement in case of failure.
Thank you all for your time and support!
First, let me apologize for any language mistakes as I’m French and relying on a translator.
I’m currently working on an autonomous pool management system using an ESP32 ETH01 running ESP Easy. Here's an overview of my project:
Components and Setup
ESP32 ETH01: Serves as the core of the system.
Relays (x4):
Pool filtration.
Pool lighting.
Heat pump control (dry contact switch for remote).
Reserved for future use.
Relays are powered at 5V, with 3.3V control signals from the ESP32.
Optocouplers (x3):
Monitor the state of the pool filtration, heat pump, and submersible pump in the decompression well.
Connected to a PCF8574 module due to GPIO limitations caused by Ethernet usage.
PCF8574 Module:
Handles GPIO extension for the optocouplers.
Includes a 2-position ON/OFF switch for manual/automatic filtration management and a 3-position ON/OFF/ON switch for filtration modes:
Forced ON.
OFF.
Back to manual/automatic.
OLED SH1106 Display: Shows key information:
Pool water temperature.
Filtration state.
Current mode (manual, automatic, forced, stop, or winter).
ADS1115: Prepares for future pH measurement.
Temperature Sensors (x3): DS18B20 for water, outdoor, and pool house temperatures.
Power: The system is powered by a PoE USB-C adapter:
ESP32, relays, and optocouplers use 5V.
I2C devices and temperature sensors are powered by 3.3V from the ESP32.
Electrical Precautions
The filtration relay controls a Schneider Electric dry-contact relay, which isolates the ESP32 from high voltage and provides protection against voltage spikes (using a snubber). This prevents damage and wear on the relay due to the inductive load from the pool pump.
Current Status
I’ve successfully wired all components and confirmed compatibility:
GPIO2: Pool filtration (device: Filtration, values: EtatFiltration).
GPIO4: Pool lighting (device: Eclairage, values: EtatEclairage).
GPIO12: Heat pump (device: PAC, values: EtatPAC).
GPIO14: Reserved for future use.
GPIO15: Temperature sensors (values: Pool, Outdoor, PoolHouse).
I2C (SDA/SCL): Connected to the ADS1115, PCF8574, and OLED display.
The system is integrated with Jeedom via the ESPEasy and Piscine plugins for automatic management. However, the ESP32 is designed to remain fully functional as a standalone system in case Jeedom fails.
Currently, I use an Arduino controlled by Jeedom, but this ESP32-based system will eventually replace it.
Challenges
Rules:
I’m struggling to save rules when using Ethernet mode on ESP Easy.
I’ve posted about this issue viewtopic.php?t=10532: Ethernet Rules Saving Problem.
HTML Dashboard:
I want to create an HTML interface to monitor temperatures and relay states via my iPhone. I’ve tried the fetch.html tool but face stability issues. I also attempted my own code with ChatGPT's help, but I’m unable to fetch temperatures successfully.
Automation Modes:
I still need to program the rules for filtration modes (manual, automatic, forced, stop, winter).
Future Plans
In the future, I would like to replace my current prototype PCB with a real, properly designed PCB. However, that will be another story . For now, this remains a prototype.
Photos and Request
I’ve attached photos showing my progress. I would greatly appreciate any advice, especially for resolving the rules-saving issue and developing a stable HTML interface.
Edit: The PCF8574 module has been flipped and connected (just like the ESP32) to female header pins for easy replacement in case of failure.
Thank you all for your time and support!
Re: Help Needed: Building an Autonomous Pool Management System with ESP32 Ethernet and ESP Easy
I think you have to use the Custom webUI. Here you can upload your own HTML file
https://letscontrolit.com/forum/viewtopic.php?t=8461
https://letscontrolit.com/forum/viewtopic.php?t=8461
Re: Help Needed: Building an Autonomous Pool Management System with ESP32 Ethernet and ESP Easy
Thank you for the information.
I quickly skimmed through it, but since I’m using a translator and I’m a beginner, it’s not very clear.
I see it mentions .css and not .html. What’s the difference?
I had already done something similar, but in .html. It works, but I don’t know how to handle the temperatures.
Thanks to chromo23, who helped me a lot with this code on my other post.
In any case, thanks again, and I’ll take a closer look as soon as I have some time.
I quickly skimmed through it, but since I’m using a translator and I’m a beginner, it’s not very clear.
I see it mentions .css and not .html. What’s the difference?
I had already done something similar, but in .html. It works, but I don’t know how to handle the temperatures.
Thanks to chromo23, who helped me a lot with this code on my other post.
Code: Select all
<!DOCTYPE html>
<html lang="fr">
<meta charset="UTF-8">
<body onload="getTemperature()">
<h1>Gestion Piscine</h1>
<button id="light-btn" class="off" onclick="toggleLight()">Éclairage : OFF</button>
<p id="temp-display">Température Cabanon : -- °C</p>
<script>
const btn = document.getElementById('light-btn');
const tempDisplay = document.getElementById('temp-display');
let isOn = false; // État initial pour le relais
// Fonction pour récupérer la température
async function getTemperature() {
try {
const response = await fetch('/json');
const data = await response.json();
console.log(data); // Affiche les données reçues
// Extraction de la valeur pour "TempCabanon" (adapter en fonction de votre configuration ESP-Easy)
const temp = data.Sensors[9].TaskValues[0].Value; // Vérifiez bien l'index correspondant à votre sonde
tempDisplay.textContent = `Température Cabanon : ${temp.toFixed(1)} °C`; // Affiche avec une décimale
} catch (error) {
tempDisplay.textContent = "Température Cabanon : Erreur";
console.error("Erreur de récupération de la température :", error);
}
}
</script>
</body>
</html>
In any case, thanks again, and I’ll take a closer look as soon as I have some time.
Re: Help Needed: Building an Autonomous Pool Management System with ESP32 Ethernet and ESP Easy
The issue seems related to the /json endpoint and its response structure.Test if the ESP32 /json endpoint works by navigating to it in your browser (e.g., http://<ESP32_IP>/json). Verify its structure and update your code accordingly. HTML handles the structure and content of your page (e.g., buttons, paragraphs, etc.). CSS defines how the HTML elements look (e.g., colors, fonts, spacing). The <style> section at the bottom provides CSS styling to make your page more visually appealing.
For Custom WebUI, you would likely combine your .html and .css files to build a fully custom interface.
For Custom WebUI, you would likely combine your .html and .css files to build a fully custom interface.
Re: Help Needed: Building an Autonomous Pool Management System with ESP32 Ethernet and ESP Easy
Since there is no error, it seems that the indexes for the temperature value are wrong. What is the output of your browser console?
Re: Help Needed: Building an Autonomous Pool Management System with ESP32 Ethernet and ESP Easy
Here’s the translation of your text into English:
"I am really sorry, but I can't do it. No matter how hard I try to search/replace the values in the code line (const temp = data.Sensors[9].TaskValues[0].Value; // Make sure to check the index corresponding to your sensor), nothing works. I can't find the explicit values in the /json."
Part of the /json
this?
I’ll send you a screenshot of my device under ESPEasy.
"I am really sorry, but I can't do it. No matter how hard I try to search/replace the values in the code line (const temp = data.Sensors[9].TaskValues[0].Value; // Make sure to check the index corresponding to your sensor), nothing works. I can't find the explicit values in the /json."
Part of the /json
Code: Select all
"TaskInterval":0,
"Type":"Switch input - PCF8574",
"TaskName":"ModeAUTO",
"TaskDeviceNumber":19,
"TaskEnabled":"true",
"TaskNumber":9
},
{
"TaskValues": [
{"ValueNumber":1,
"Name":"Piscine",
"NrDecimals":2,
"Value":20.56
}],
"DataAcquisition": [
{"Controller":1,
"IDX":0,
"Enabled":"true"
},
{"Controller":2,
"IDX":0,
"Enabled":"false"
},
{"Controller":3,
"IDX":0,
"Enabled":"false"
}],
"TaskInterval":30,
"Type":"Environment - 1-Wire Temperature",
"TaskName":"Température",
"TaskDeviceNumber":4,
"TaskDeviceGPIO1":15,
"TaskEnabled":"true",
"TaskNumber":10
},
{
"TaskValues": [
{"ValueNumber":1,
"Name":"EtatStatutFiltration",
"NrDecimals":0,
"Value":0
I didn’t understand.
this?
I’ll send you a screenshot of my device under ESPEasy.
Re: Help Needed: Building an Autonomous Pool Management System with ESP32 Ethernet and ESP Easy
Ok...different approach. Copy your whole /json output and paste it here: https://jsonviewer.stack.hu/
Click an the "viewer tab" and find your sensor and the value
I my screenshot you can see, that my temperature value can be found at: "data.Sensors[6].TaskValues[0].Value". (in my case the value is zero)
Re: Help Needed: Building an Autonomous Pool Management System with ESP32 Ethernet and ESP Easy
Just as a tip, there are also extensions for your browser to help validate and inspect JSON.
Typically these also color code your JSON so you can easily see what is a key and what is a value.
These also can indent and fold sections in the JSON to make it easier to understand.
Typically these also color code your JSON so you can easily see what is a key and what is a value.
These also can indent and fold sections in the JSON to make it easier to understand.
Re: Help Needed: Building an Autonomous Pool Management System with ESP32 Ethernet and ESP Easy
Thanks !!!!
Great, I managed to get it working. I don’t understand why it wasn’t working before, but oh well.
As you know, I’m slowly starting with a code that includes a relay button and a temperature sensor. So far, this works... almost . The problem now is that I no longer have the status feedback. That means if my relay is on and I open my .html page, the relay shows as OFF.
I had three codes.
One with the relay and status feedback functional (occasionally getting a message saying "Unable to communicate with ESP-Easy" but it updated after a few seconds).
Another with just the temperature sensor, which also worked.
And a third with the mix of both, where everything is functional except for the status feedback.
Sorry, but not being an expert in this field, I have tested several different AIs and none solve the problem. As soon as the code is modified, I end up with an error for the temperature sensor and errors in the /json console. In summary, either status feedback but no temperature, or functional temperature and relay but without status feedback. I’m stuck.
Great, I managed to get it working. I don’t understand why it wasn’t working before, but oh well.
As you know, I’m slowly starting with a code that includes a relay button and a temperature sensor. So far, this works... almost . The problem now is that I no longer have the status feedback. That means if my relay is on and I open my .html page, the relay shows as OFF.
I had three codes.
One with the relay and status feedback functional (occasionally getting a message saying "Unable to communicate with ESP-Easy" but it updated after a few seconds).
Another with just the temperature sensor, which also worked.
Code: Select all
<!DOCTYPE html>
<html lang="fr">
<meta charset="UTF-8">
<body onload="getTemperature()">
<h1>Gestion Piscine</h1>
<p id="temp-display">Température Piscine : -- °C</p>
<script>
const tempDisplay = document.getElementById('temp-display');
// Fonction pour récupérer la température
async function getTemperature() {
try {
const response = await fetch('/json');
const data = await response.json();
console.log(data); // Affiche les données reçues
// Extraction de la valeur pour "TempPiscine" (adapter en fonction de votre configuration ESP-Easy)
const temp = data.Sensors[9].TaskValues[0].Value; // Vérifiez bien l'index correspondant à votre sonde
tempDisplay.textContent = `Température Piscine : ${temp.toFixed(1)} °C`; // Affiche avec une décimale
} catch (error) {
tempDisplay.textContent = "Température Cabanon : Erreur";
console.error("Erreur de récupération de la température :", error);
}
}
</script>
</body>
</html>
Code: Select all
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gestion Piscine</title>
<style>
body { font-family: Arial, sans-serif; text-align: center; margin-top: 50px; }
button {
font-size: 20px;
padding: 15px 30px;
border: none;
border-radius: 5px;
cursor: pointer;
}
.on { background-color: rgb(63, 219, 246); color: white; }
.off { background-color: red; color: white; }
</style>
</head>
<body>
<h1>Gestion Piscine</h1>
<button id="light-btn" class="off" onclick="toggleLight()">Éclairage : OFF</button>
<script>
const btn = document.getElementById('light-btn');
let isOn = false; // État initial (éteint)
// Fonction pour récupérer l'état du relais au démarrage de la page
async function getRelayState() {
try {
const response = await fetch('http://192.168.1.177/control?cmd=status,G,4');
const data = await response.json();
// Vérification de l'état du GPIO 4 (state: 1 = ON, state: 0 = OFF)
if (data.state === 1) {
isOn = true;
} else {
isOn = false;
}
updateButtonState(); // Met à jour l'état du bouton
} catch (error) {
alert("Impossible de récupérer l'état du relais");
}
}
// Fonction pour mettre à jour l'état du bouton
function updateButtonState() {
btn.textContent = `Éclairage : ${isOn ? 'ON' : 'OFF'}`;
btn.className = isOn ? 'on' : 'off';
}
// Fonction pour basculer l'état du relais
async function toggleLight() {
const gpioState = isOn ? 0 : 1; // 0 pour OFF, 1 pour ON
const url = `http://192.168.1.177/control?cmd=GPIO,4,${gpioState}`;
try {
const response = await fetch(url);
if (response.ok) {
isOn = !isOn; // Inverse l'état
updateButtonState(); // Met à jour l'état du bouton
} else {
alert("Erreur lors de la requête");
}
} catch (error) {
alert("Impossible de communiquer avec ESP-Easy");
}
}
// Récupère l'état du relais au chargement de la page
window.onload = getRelayState;
</script>
<body onload="getTemperature()">
<h1>Températures</h1>
<p id="temp-display">Piscine : -- °C</p>
<script>
const tempDisplay = document.getElementById('temp-display');
// Fonction pour récupérer la température
async function getTemperature() {
try {
const response = await fetch('/json');
const data = await response.json();
console.log(data); // Affiche les données reçues
// Extraction de la valeur pour "TempPiscine" (adapter en fonction de votre configuration ESP-Easy)
const temp = data.Sensors[9].TaskValues[0].Value; // Vérifiez bien l'index correspondant à votre sonde
tempDisplay.textContent = `Piscine : ${temp.toFixed(1)} °C`; // Affiche avec une décimale
} catch (error) {
tempDisplay.textContent = "Température Piscine : Erreur";
console.error("Erreur de récupération de la température :", error);
}
}
</script>
</body>
</html>
</body>
</html>
Sorry, but not being an expert in this field, I have tested several different AIs and none solve the problem. As soon as the code is modified, I end up with an error for the temperature sensor and errors in the /json console. In summary, either status feedback but no temperature, or functional temperature and relay but without status feedback. I’m stuck.
Re: Help Needed: Building an Autonomous Pool Management System with ESP32 Ethernet and ESP Easy
My .html page is progressing well
Buttons for activating my relays.
Status feedback from my filtration pump (currently simulated using a light bulb) when the Filtration relay activates it.
Display of temperatures (only one available for now).
Potential evolution to display pH levels.
Display of Modes based on the activation of the switches on the control box.
I struggled quite a bit, but with your valuable information on using JSON and the help of AI, it’s turning out exactly the way I want.
Now I can start working on the rules!
Buttons for activating my relays.
Status feedback from my filtration pump (currently simulated using a light bulb) when the Filtration relay activates it.
Display of temperatures (only one available for now).
Potential evolution to display pH levels.
Display of Modes based on the activation of the switches on the control box.
I struggled quite a bit, but with your valuable information on using JSON and the help of AI, it’s turning out exactly the way I want.
Now I can start working on the rules!
Re: Help Needed: Building an Autonomous Pool Management System with ESP32 Ethernet and ESP Easy
Last edited by Neoseb38 on 24 Dec 2024, 16:14, edited 1 time in total.
Re: Help Needed: Building an Autonomous Pool Management System with ESP32 Ethernet and ESP Easy
Looking good
NB: You might want to use the Attachments tab below the Post a reply field to attach your images, as external image hosters tend to remove these images after a couple of months/weeks, rendering your message useless
NB: You might want to use the Attachments tab below the Post a reply field to attach your images, as external image hosters tend to remove these images after a couple of months/weeks, rendering your message useless
/Ton (PayPal.me)
Re: Help Needed: Building an Autonomous Pool Management System with ESP32 Ethernet and ESP Easy
That’s great.
Thanks again.
I just corrected
Thanks again.
I just corrected
Re: Help Needed: Building an Autonomous Pool Management System with ESP32 Ethernet and ESP Easy
Hello everyone,
I am encountering an issue with ESPEasy rules for controlling my pool filtration system. Here is a summary of the situation:
Rappel:
I am using an ESP32 to manage my pool filtration based on water temperature.
The system includes:
An anti-freeze protection that activates filtration if the temperature ≤ 0°C.
An automatic filtration system that activates based on temperature and time.
A forced mode (via a switch or an app) to manually activate filtration.
A stop mode to deactivate filtration.
Problem:
When the temperature is above 0°C and forced mode is activated (via GPIO2), the filtration is immediately deactivated as soon as the temperature is checked. This seems to be due to the anti-freeze rule, which deactivates filtration even if forced mode is active.
Initial Code:
Here is the initial code I am using for Rule 4 (anti-freeze and automatic filtration):
This rule works perfectly without the winter mode. Since I added it, the filtration automatically turns off above 0°C.
Note: The values in seconds in the code (30, 60, 90, etc.) are temporary and used for testing. They will be adjusted once the issue is resolved.
Other Rules:
Here are my other rules for OLED display and mode management. These rules (Rules Set 1, 2, and 3) work perfectly:
Rules Set 1:
Rules Set 2:
Rules Set 3:
What I have tried:
I added variables (Var#1 for anti-freeze and Var#2 for forced mode) to manage priorities.
I modified the rules to give forced mode priority over anti-freeze.
I added logs to track rule execution.
Result:
Despite these changes, the filtration is still deactivated as soon as the temperature is checked, even if forced mode is active.
Request for help:
I am looking to resolve this issue so that forced mode takes priority over anti-freeze and automatic filtration. Any help or suggestions would be greatly appreciated!
Note: I am a beginner in ESPEasy programming and have tried to solve this issue on my own using various AI tools, but without success. I hope you can help me understand what is not working.
Thank you in advance for your help!
I am encountering an issue with ESPEasy rules for controlling my pool filtration system. Here is a summary of the situation:
Rappel:
I am using an ESP32 to manage my pool filtration based on water temperature.
The system includes:
An anti-freeze protection that activates filtration if the temperature ≤ 0°C.
An automatic filtration system that activates based on temperature and time.
A forced mode (via a switch or an app) to manually activate filtration.
A stop mode to deactivate filtration.
Problem:
When the temperature is above 0°C and forced mode is activated (via GPIO2), the filtration is immediately deactivated as soon as the temperature is checked. This seems to be due to the anti-freeze rule, which deactivates filtration even if forced mode is active.
Initial Code:
Here is the initial code I am using for Rule 4 (anti-freeze and automatic filtration):
This rule works perfectly without the winter mode. Since I added it, the filtration automatically turns off above 0°C.
Code: Select all
// On boot
On System#Boot do
Let,1,0 // Reset filtration authorization
// === ANTI-FREEZE PROTECTION (PRIORITY) ===
On Température#Piscine do
if [Température#Piscine]<=0
Let,1,1 // Activate anti-freeze flag
GPIO,2,1 // Force filtration on
oledframedcmd,5,"Safety: ANTI-FREEZE"
else
Let,1,0
GPIO,2,0 // Stop filtration
oledframedcmd,5,"Mode: Auto"
endif
endon
// === DAILY FILTRATION ===
// Start at 9:00 AM
On Clock#Time=All,09:00 do
if [ModeAUTO#EtatModeAUTO]=1
if [Température#Piscine]<=10
timerSet,1,30 // 2h (7200)
GPIO,2,1
elseif [Température#Piscine]<=15
timerSet,1,60 // 4h (14400)
GPIO,2,1
elseif [Température#Piscine]<=20
timerSet,1,90 // 7h (25200)
GPIO,2,1
elseif [Température#Piscine]<=25
timerSet,1,120 // 10h (36000)
GPIO,2,1
elseif [Température#Piscine]<=28
timerSet,1,150 // 12h (43200)
GPIO,2,1
else
timerSet,1,180 // 14h (50400)
GPIO,2,1
endif
endif
endon
On Rules#Timer=1 do
GPIO,2,0
endon
// === SAFETY // END OF DAY ===
// Automatic filtration shutdown at 10:00 PM
On Clock#Time=All,22:00 do
if [ModeAUTO#EtatModeAUTO]=1
if [Température#Piscine]>0
GPIO,2,0
endif
endif
endon
Other Rules:
Here are my other rules for OLED display and mode management. These rules (Rules Set 1, 2, and 3) work perfectly:
Rules Set 1:
Code: Select all
//Boot
On System#Boot do
oledframedcmd,6,"Filtration: OFF"
oledframedcmd,7,"Lighting: OFF"
oledframedcmd,8,"Heat Pump: OFF"
endon
Code: Select all
// Display Filtration status on the screen
On Filtration#EtatFiltration do
if [Filtration#EtatFiltration]=1
oledframedcmd,6,"Filtration: ON"
else
oledframedcmd,6,"Filtration: OFF"
endif
endon
// Display Lighting status on the screen
On Eclairage#EtatEclairage do
if [Eclairage#EtatEclairage]=1
oledframedcmd,7,"Lighting: ON"
else
oledframedcmd,7,"Lighting: OFF"
endif
endon
// Display Heat Pump status on the screen
On PAC#EtatPAC do
if [PAC#EtatPAC]=1
oledframedcmd,8,"Heat Pump: ON"
else
oledframedcmd,8,"Heat Pump: OFF"
endif
endon
Code: Select all
// Auto/Manual Mode
On ModeAuto#EtatModeAUTO do
// Do nothing if in Forced or Stop mode
if ([InterON#EtatInterON]=0 and [InterOFF#EtatInterOFF]=0)
if [ModeAuto#EtatModeAUTO]=1
oledframedcmd,5,"Mode: Auto"
else
oledframedcmd,5,"Mode: Manual"
endif
endif
endon
// Forced Mode (InterON)
On InterON#EtatInterON do
if [InterON#EtatInterON]=1
oledframedcmd,5,"Mode: Forced"
gpio,2,1 // Activate filtration
endif
if [InterON#EtatInterON]=0 and [InterOFF#EtatInterOFF]=0
// Return to previous mode (Auto or Manual), but do not deactivate filtration
if [ModeAuto#EtatModeAUTO]=1
oledframedcmd,5,"Mode: Auto"
else
oledframedcmd,5,"Mode: Manual"
endif
endif
endon
// Stop Mode (InterOFF)
On InterOFF#EtatInterOFF do
if [InterOFF#EtatInterOFF]=1
oledframedcmd,5,"Mode: Stop"
gpio,2,0 // Deactivate filtration
endif
if [InterON#EtatInterON]=0 and [InterOFF#EtatInterOFF]=0
// Return to previous mode (Auto or Manual)
if [ModeAuto#EtatModeAUTO]=1
oledframedcmd,5,"Mode: Auto"
else
oledframedcmd,5,"Mode: Manual"
endif
// Deactivate filtration only in Stop mode
gpio,2,0 // Deactivate filtration
endif
endon
I added variables (Var#1 for anti-freeze and Var#2 for forced mode) to manage priorities.
I modified the rules to give forced mode priority over anti-freeze.
I added logs to track rule execution.
Result:
Despite these changes, the filtration is still deactivated as soon as the temperature is checked, even if forced mode is active.
Request for help:
I am looking to resolve this issue so that forced mode takes priority over anti-freeze and automatic filtration. Any help or suggestions would be greatly appreciated!
Note: I am a beginner in ESPEasy programming and have tried to solve this issue on my own using various AI tools, but without success. I hope you can help me understand what is not working.
Thank you in advance for your help!
Re: Help Needed: Building an Autonomous Pool Management System with ESP32 Ethernet and ESP Easy
Code: Select all
// On boot
On System#Boot do
Let,1,0 // Reset filtration authorization
//missing an "endon"
Not sure if those accented characters are parsed OK, as ESPEasy is not using WString, so you can easily have characters which look the same but are not the same. Like this: "On Température#Piscine do"
The e-accent can be ALT-137, but can also be its unicode variant.
Best not to use accents.
And just as a tip, see this section:
Code: Select all
On Température#Piscine do
if [Température#Piscine]<=0
Better to do it like this:
Code: Select all
On Température#Piscine do
if %eventvalue1%<=0
To debug your rules, I strongly suggest sending things to the log, so you know what values are being processed and even if your event is being processed.
Code: Select all
On Température#Piscine do
if %eventvalue1%<=0
logentry,"Température#Piscine below 0, actual temperature %eventvalue1%"
Now where probably your problem is being caused, in "On Clock#Time=All,09:00 do"
Just take a look at the first temperature check: if [Température#Piscine]<=10
Please note that below freezing point also matches this.
So maybe you should add your first check to see if it is freezing.
Re: Help Needed: Building an Autonomous Pool Management System with ESP32 Ethernet and ESP Easy
Having multiple "on System#Boot do" events won't work, as only the first one encountered will be executed, so that partial rule in the Rules4 file will be ignored (and also because it's incomplete, as already noted).
/Ton (PayPal.me)
Re: Help Needed: Building an Autonomous Pool Management System with ESP32 Ethernet and ESP Easy
Thank you again for your invaluable help.
I am a beginner, so I apologize if I made any mistakes.
Regarding variables, I must admit that I don’t fully understand them.
Here is my code:
The problem remains unchanged: as soon as I activate my GPIO2 relay remotely via my HTML page (mentioned earlier in this post) or via my physical switch, the relay turns on and then automatically turns off.
It’s worth noting that when I had only this code (without the anti-freeze protection), everything worked perfectly:
I have renamed my device from Température to Temperature (without the accent).
Thank you for your help.
I am a beginner, so I apologize if I made any mistakes.
Regarding variables, I must admit that I don’t fully understand them.
Here is my code:
Code: Select all
// On boot
On System#Boot do
Let,1,0 // Reset filtration authorization
endon
// === ANTI-FREEZE PROTECTION (PRIORITY) ===
On Temperature#Piscine do
if %eventvalue1% <= 5
logentry,"Temperature#Piscine below 0, actual temperature %eventvalue1%"
Let,1,1 // Activate anti-freeze flag
GPIO,2,1 // Force filtration on
oledframedcmd,5,"Safety: ANTI-FREEZE"
else
logentry,"Anti-freeze deactivated"
Let,1,0
GPIO,2,0 // Stop filtration
oledframedcmd,5,"Mode: AUTO"
endif
endon
// === DAILY FILTRATION ===
// Start at 9:00 AM
On Clock#Time=All,09:00 do
logentry,"Start automatic filtration"
if [ModeAUTO#EtatModeAUTO] = 1
if %eventvalue1% > 5 and %eventvalue1% <= 10
timerSet,1,30 // 2h (7200)
GPIO,2,1
logentry,"Filtration activated for 30 seconds"
elseif %eventvalue1% > 10 and %eventvalue1% <= 15
timerSet,1,60 // 4h (14400)
GPIO,2,1
logentry,"Filtration activated for 60 seconds"
elseif %eventvalue1% > 15 and %eventvalue1% <= 20
timerSet,1,90 // 7h (25200)
GPIO,2,1
logentry,"Filtration activated for 90 seconds"
elseif %eventvalue1% > 20 and %eventvalue1% <= 25
timerSet,1,120 // 10h (36000)
GPIO,2,1
elseif %eventvalue1% > 25 and %eventvalue1% <= 28
timerSet,1,150 // 12h (43200)
GPIO,2,1
logentry,"Filtration activated for 150 seconds"
else
timerSet,1,180 // 14h (50400)
GPIO,2,1
logentry,"Filtration activated for 180 seconds"
endif
endif
endon
On Rules#Timer=1 do
GPIO,2,0
endon
// === SAFETY // END OF DAY ===
// Automatic filtration shutdown at 10:00 PM
On Clock#Time=All,22:00 do
if [ModeAUTO#EtatModeAUTO] = 1
if %eventvalue1% > 0
GPIO,2,0
endif
endif
endon
It’s worth noting that when I had only this code (without the anti-freeze protection), everything worked perfectly:
Code: Select all
// On boot
On System#Boot do
Let,1,0 // Reset filtration authorization
if [Temperature#Piscine] <= 2
GPIO,2,1 // Activate filtration if freezing
endif
endon
// Start of the day
On Clock#Time=All,09:00 do
Let,1,1 // Authorize filtration
if [ModeAUTO#EtatModeAUTO] = 1
if [Temperature#Piscine] <= 2
GPIO,2,1 // Freeze protection
elseif [Temperature#Piscine] <= 10
timerSet,1,7200 // 2h
GPIO,2,1
elseif [Temperature#Piscine] <= 15
timerSet,1,14400 // 4h
GPIO,2,1
elseif [Temperature#Piscine] <= 20
timerSet,1,25200 // 7h
GPIO,2,1
elseif [Temperature#Piscine] <= 25
timerSet,1,36000 // 10h
GPIO,2,1
elseif [Temperature#Piscine] <= 28
timerSet,1,43200 // 12h
GPIO,2,1
else
timerSet,1,50400 // 14h
GPIO,2,1
endif
endif
endon
// End of the day
On Clock#Time=All,22:00 do
if [Temperature#Piscine] > 2
Let,1,0 // Disable authorization
GPIO,2,0 // Stop filtration
endif
endon
Thank you for your help.
Re: Help Needed: Building an Autonomous Pool Management System with ESP32 Ethernet and ESP Easy
Well, after testing everything you told me, trying with the logs, etc., I couldn’t resolve my issue.
However, I found this (simple and effective) that works perfectly.
It even resumes the timer and stops the filtration after simulating a power outage by unplugging my ESP32. (I’ve tested it several times, and it seems fine).
RULES 1:
I agree that there are no variables (I don’t know how to use them), and it’s far from perfect… I’m fully aware of that. :/
The only problem I’m stuck with now is lines 9, 10, 11, and 12 on my screen, which shouldn’t appear in the first place (only 8 lines are registered on my screen device). When they do show up after the 2-minute timer starts (in my test), once the timer ends, I would have liked them to disappear.
What do you think?
Rappel:
RULES 2:
RULES 3:
I will refine this code by adding information for logs now and look for other possible improvements.
However, I found this (simple and effective) that works perfectly.
It even resumes the timer and stops the filtration after simulating a power outage by unplugging my ESP32. (I’ve tested it several times, and it seems fine).
RULES 1:
Code: Select all
//Boot
On System#Boot do
oledframedcmd,6,"Filtration: OFF"
oledframedcmd,7,"Eclairage: OFF"
oledframedcmd,8,"PAC: OFF"
endon
// Sécurité ANTI-GEL
On Temperature#Piscine do
if [ModeAUTO#EtatModeAUTO]=1 And [InterOFF#EtatInterOFF]=0 And [Temperature#Piscine]<=2
GPIO,2,1 // Filtration on
timerSet,1,30 // Test 30 secondes
oledframedcmd,5,"Sécurité ANTI-GEL" // Affichage de la sécurité anti-gel
endif
endon
// Début journée
On Clock#Time=All,19:23 do
if [ModeAUTO#EtatModeAUTO]=1
if [Temperature#Piscine]>2 and [Temperature#Piscine]<=10 // Correction ici
timerSet,1,30 // test 30 secondes
GPIO,2,1
elseif [Temperature#Piscine]<=15
timerSet,1,60 // test 1 minute
GPIO,2,1
elseif [Temperature#Piscine]<=20
timerSet,1,90 // test 1 minute 30
GPIO,2,1
elseif [Temperature#Piscine]<=25
timerSet,1,120 // test 2 minutes
GPIO,2,1
oledframedcmd,9,"Filtration AUTO" // Test: nouvel affichage ligne 9
oledframedcmd,10,"de 9h à 11h" // Test: nouvel affichage ligne 10
oledframedcmd,11,"Total:" // Test: nouvel affichage ligne 11
oledframedcmd,12,"2 heures" // Test:nouvel affichage ligne 12
elseif [Temperature#Piscine]<=28
timerSet,1,150 // test 2 minutes 30
GPIO,2,1
elseif [Temperature#Piscine]>28
timerSet,1,180 // test 3 minutes
GPIO,2,1
endif
endif
endon
// Fin du timer
On Rules#Timer=1 do
GPIO,2,0 // Arrêt filtration
oledframedcmd,5,"Mode: AUTO" // retour affichage mode: AUTO
endon
// Sécurité - Fin de journée
On Clock#Time=All,22:00 do
if [ModeAUTO#EtatModeAUTO]=1
if [Temperature#Piscine]>2
GPIO,2,0 // Arrêt filtration
endif
endif
endon
The only problem I’m stuck with now is lines 9, 10, 11, and 12 on my screen, which shouldn’t appear in the first place (only 8 lines are registered on my screen device). When they do show up after the 2-minute timer starts (in my test), once the timer ends, I would have liked them to disappear.
What do you think?
Rappel:
RULES 2:
Code: Select all
// Affichage Filtration sur l'ecran
On Filtration#EtatFiltration do
if [Filtration#EtatFiltration]=1
oledframedcmd,6,"Filtration: ON"
else
oledframedcmd,6,"Filtration: OFF"
endif
endon
// Affichage Eclairage sur l'ecran
On Eclairage#EtatEclairage do
if [Eclairage#EtatEclairage]=1
oledframedcmd,7,"Eclairage: ON"
else
oledframedcmd,7,"Eclairage: OFF"
endif
endon
//Affichage PAC sur l'ecran
On PAC#EtatPAC do
if [PAC#EtatPAC]=1
oledframedcmd,8,"PAC: ON"
else
oledframedcmd,8,"PAC: OFF"
endif
endon
Code: Select all
// Mode Auto/Manuel
On ModeAuto#EtatModeAUTO do
// Ne change rien si en mode Forcé ou Arrêt
if ([InterON#EtatInterON]=0 and [InterOFF#EtatInterOFF]=0)
if [ModeAuto#EtatModeAUTO]=1
oledframedcmd,5,"Mode : Auto"
else
oledframedcmd,5,"Mode : Manuel"
endif
endif
endon
// Mode Forcé (InterON)
On InterON#EtatInterON do
if [InterON#EtatInterON]=1
oledframedcmd,5,"Mode : Forcé"
gpio,2,1 // Active la filtration
endif
if [InterON#EtatInterON]=0 and [InterOFF#EtatInterOFF]=0
// Retour au mode précédent (Auto ou Manuel), mais ne désactive pas la filtration
if [ModeAuto#EtatModeAUTO]=1
oledframedcmd,5,"Mode : Auto"
else
oledframedcmd,5,"Mode : Manuel"
endif
endif
endon
// Mode Arrêt (InterOFF)
On InterOFF#EtatInterOFF do
if [InterOFF#EtatInterOFF]=1
oledframedcmd,5,"Mode : Arrêt"
gpio,2,0 // Désactive la filtration
endif
if [InterON#EtatInterON]=0 and [InterOFF#EtatInterOFF]=0
// Retour au mode précédent (Auto ou Manuel)
if [ModeAuto#EtatModeAUTO]=1
oledframedcmd,5,"Mode : Auto"
else
oledframedcmd,5,"Mode : Manuel"
endif
// Désactive la filtration uniquement en mode Arrêt
gpio,2,0 // Désactive la filtration
endif
endon
Re: Help Needed: Building an Autonomous Pool Management System with ESP32 Ethernet and ESP Easy
Well, in the end, in case of a power outage, it’s not really working as expected...
I wanted to create two dummy devices to save the state of GPIO2 (filtration) and the timer so I could use them on boot, but I can't manage to make it work.
I wanted to create two dummy devices to save the state of GPIO2 (filtration) and the timer so I could use them on boot, but I can't manage to make it work.
Re: Help Needed: Building an Autonomous Pool Management System with ESP32 Ethernet and ESP Easy
On power loss no Task values are restored. (on a regular reboot they are restored where possible & supported)
Except, with the "Regulator - Level control" (P021) you can store a single value persistently, but it has to be used carefully, as saving to flash too often will eventually damage the flash memory. (See the documentation for an explanation on how to use it best.)
Except, with the "Regulator - Level control" (P021) you can store a single value persistently, but it has to be used carefully, as saving to flash too often will eventually damage the flash memory. (See the documentation for an explanation on how to use it best.)
/Ton (PayPal.me)
Re: Help Needed: Building an Autonomous Pool Management System with ESP32 Ethernet and ESP Easy
Thank you for the information. For my filtration project, what would you recommend in case of a power outage? Should I turn off the filtration, do nothing on boot (currently, during a simulated power outage, it restarts normally with the timer, and sometimes it leaves the relay off), or create a Dummy Device?
Regarding the creation of a Dummy Device, if it doesn’t make sense or has no utility, I won’t bother with it. For testing purposes, I created one in Task 15, but no matter what I try, I can’t retrieve the value of my GPIO 2 or the timer. Here’s what I tried:
Thank you again.
PS: When I replace [Temperature#Piscine] with %eventvalue1% as you suggested, I get yellow errors in the logs. Is this a serious issue if I leave my code as it is since it’s working?
Regarding the creation of a Dummy Device, if it doesn’t make sense or has no utility, I won’t bother with it. For testing purposes, I created one in Task 15, but no matter what I try, I can’t retrieve the value of my GPIO 2 or the timer. Here’s what I tried:
Code: Select all
On Filtration#EtatFiltration do
TaskValueSet,15,1,[Filtration#EtatFiltration] // Save the filtration state in Task 15, value 1
endon
On Rules#Timer=1 do
// Save the remaining timer time in Task 15
TaskValueSet,15,2,%eventvalue1% // %eventvalue1% contains the remaining timer time
logentry,"Timer 1 saved: %eventvalue1% seconds remaining"
endon
PS: When I replace [Temperature#Piscine] with %eventvalue1% as you suggested, I get yellow errors in the logs. Is this a serious issue if I leave my code as it is since it’s working?
Who is online
Users browsing this forum: No registered users and 4 guests