Skip to content

Commit

Permalink
Merge pull request #37 from Loic74650/develop
Browse files Browse the repository at this point in the history
V6.0 version
  • Loading branch information
Loic74650 authored Jul 25, 2023
2 parents bc79310 + 9486f0d commit a093277
Show file tree
Hide file tree
Showing 13 changed files with 151 additions and 286 deletions.
Binary file modified Nextion/PoolMaster.HMI
Binary file not shown.
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<h2>PoolMaster 5.0.0</h2>
<h2>PoolMaster 6.0.0</h2>
<h2>Ph/Orp (Chlorine) regulation system for home pools</h2>

<br />
<p align="center"> <img src="/docs/PoolMaster_2.jpg" width="802" title="Overview"> </p> <br /><br />
<p align="center"> <img src="/docs/PoolMaster_3.jpg" width="802" title="Overview"> </p> <br /><br />

<br />
<p align="center"> <img src="/docs/Grafana.png" width="802" title="Dashboard"> </p> <br /><br />
<p align="center"> <img src="/docs/PoolMasterIntegration.png" width="802" title="Dashboard"> </p> <br /><br />

<br />
<p align="center"> <img src="/docs/Nextion.png" width="802" title="Nextion 3.5" touch screen"> </p> <br /><br />
Expand All @@ -19,7 +19,7 @@
<p>Four main metrics are measured and periodically reported over MQTT and a 3.5" Nextion touch screen: water temperature and pressure, pH and ORP values.<br />
Pumps states, tank-levels estimates and other parameters are also periodically reported<br />
Two PID regulation loops are running in parallel: one for PH, one for ORP<br />
An additional simple (on/off) regulation loop is haling the water temperature (it starts/stops the house-heating system circulator which brings heat to a heat exchanger mounted on the pool water pipes)<br />
An additional simple (on/off) regulation loop is handling the water temperature (it starts/stops the house-heating system circulator which brings heat to a heat exchanger mounted on the pool water pipes)<br />
pH is regulated by injecting Acid from a tank into the pool water (a relay starts/stops the Acid peristaltic pump)<br />
ORP is regulated by injecting Chlorine from a tank into the pool water (a relay starts/stops the Chlorine peristaltic pump)<br />
Defined time-slots and water temperature are used to start/stop the filtration pump for a daily given amount of time (a relay starts/stops the filtration pump)<br />
Expand Down Expand Up @@ -123,7 +123,7 @@ Experimentally I measured that in my case it can take up to 30minutes and theref
So in my case I setlled for a safe one hour WINDOW SIZE (ie. 3600000ms) <br /><br />


<p align="center"> <img src="/docs/PoolMaster.jpg" width="702" title="Overview"> </p> <br /><br />
<p align="center"> <img src="/docs/PoolMaster_3.jpg" width="702" title="Overview"> </p> <br /><br />
<p align="center"> <img src="/docs/PoolMasterBox_pf.jpg" width="702" title="Overview"> </p> <br /><br />

<h4>MQTT API</h4>
Expand Down Expand Up @@ -175,8 +175,7 @@ Below are the Payloads/commands to publish on the "PoolTopicAPI" topic (see hard
<p>
<ul>
<li><a title="https://www.controllino.biz/product/controllino-maxi/" href="https://www.controllino.biz/product/controllino-maxi/">x1 CONTROLLINO MAXI (ATmega2560)</a> or Arduino Mega 2560 + Ethernet shield + relay shield + RTC module</li>
<li><a title="https://www.phidgets.com/?tier=3&catid=11&pcid=9&prodid=103" href="https://www.phidgets.com/?tier=3&catid=11&pcid=9&prodid=103">x2 Phidgets PH/ORB amplifier modules</a></li>
<li><a title="https://www.dfrobot.com/product-1621.html" href="https://www.dfrobot.com/product-1621.html">x2 Galvanic isolator for the pH and Orp probes</a></li>
<li><a title="https://github.com/Loic74650/pH_Orp_Board" href="https://github.com/Loic74650/pH_Orp_Board">x1 pH_Orp_Board (digital interface to the pH and Orp probes with galavanic isolation)</a></li>
<li><a title="https://www.dosita.it/en/shop/fixed-displacement-peristaltic-pump-mp2-p-230-vac-power-supply/" href="https://www.dosita.it/en/shop/fixed-displacement-peristaltic-pump-mp2-p-230-vac-power-supply/">x2 Peristaltic pumps, suction lances for tanks, pH and Orp probes</a></li>
<li><a title="http://electrolyseur.fr/pool-terre.html" href="http://electrolyseur.fr/pool-terre.html">x1 Water grounding</a></li>
<li><a title="http://electrolyseur.fr/kit-sonde-DS18B20-filtration-piscine.html" href="http://electrolyseur.fr/kit-sonde-DS18B20-filtration-piscine.html">x1 Water temperature probe (DS18B20)</a></li>
Expand Down Expand Up @@ -204,7 +203,7 @@ See NodeRed folder for more info and code
<h4>Non-cloud home automation integration example (Node-Red + InfluxDB + Grafana)</h4>
<p>
See the NodeRed folder for more info and this <a title="https://www.youtube.com/watch?v=JdV4x925au0" href="https://www.youtube.com/watch?v=JdV4x925au0">tutorial</a> on how to create a Grafana dashboard from MQTT data.<br />
<p align="center"> <img src="/docs/Grafana.png" width="702" title="Overview"> </p> <br />
<p align="center"> <img src="/docs/PoolMaster_3.jpg" width="702" title="Overview"> </p> <br />
<p align="center"> <img src="/docs/NodeRedDashboard.png" width="702" title="Overview"> </p> <br />

</p>
Expand Down
Binary file added docs/CONTROLLINO_MAXI_Pinout_Table.pdf
Binary file not shown.
Binary file added docs/PoolMasterIntegration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/PoolMaster_3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/Probes cross-talk test.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/Reaction_to_pH_plus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/Wiring.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 13 additions & 36 deletions source/PoolMaster/Config.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "OneWire.h"

#define DEBUG ->comment this line to prevent code from writing debug messages to serial port
//#define DEBUG ->comment this line to prevent code from writing debug messages to serial port
#define pHOrpBoard //->comment this line if your setup is using the Phidget boards ((PoolMaster V5.0 and earlier) as interface to the pH and Orp probes instead of the default pHOrpBoard(https://github.com/Loic74650/pH_Orp_Board)

#include "DebugUtils.h"

#if defined(CONTROLLINO_MAXI) //Controllino Maxi board specifics
Expand Down Expand Up @@ -32,11 +34,6 @@
//Analog input pin connected to pressure sensor
#define PSI_MEASURE CONTROLLINO_A9 //CONTROLLINO_A9 pin A9 on pin header connector, not on screw terminal (/!\)

//Front panel push button switch
#define PUSH_BUTTON_PIN CONTROLLINO_A5 //CONTROLLINO_A5 pin A5. Connect a button switch from this pin to ground
#define GREEN_LED_PIN CONTROLLINO_D0 //CONTROLLINO_D0). Digital output pin to switch ON/OFF Green LED of push button
#define RED_LED_PIN CONTROLLINO_D2 //CONTROLLINO_D2). Digital output pin to switch ON/OFF Red LED of push button

#else //Mega2560 board specifics

#include <Wire.h>
Expand Down Expand Up @@ -75,11 +72,6 @@ RTC_DS3231 rtc;
//Analog input pin connected to pressure sensor
#define PSI_MEASURE A10

//Front panel push button switch
#define PUSH_BUTTON_PIN A12 //Connect a button switch from this pin to ground
#define GREEN_LED_PIN 2 //Digital output pin to switch ON/OFF Green LED of push button
#define RED_LED_PIN 5 //Digital output pin to switch ON/OFF Red LED of push button

#endif

//One wire bus for the water temperature measurement
Expand All @@ -106,7 +98,7 @@ String sArduinoMac;

//Version of config stored in Eeprom
//Random value. Change this value (to any other value) to revert the config to default values
#define CONFIG_VERSION 122
#define CONFIG_VERSION 120

//interval (in miilisec) between MQTT publishes of measurement data
#define PublishInterval 30000
Expand All @@ -120,7 +112,7 @@ struct StoreStruct
unsigned long PhPumpUpTimeLimit, ChlPumpUpTimeLimit;
unsigned long PhPIDWindowSize, OrpPIDWindowSize, PhPIDwindowStartTime, OrpPIDwindowStartTime;
double Ph_SetPoint, Orp_SetPoint, PSI_HighThreshold, PSI_MedThreshold, WaterTempLowThreshold, WaterTemp_SetPoint, TempExternal, pHCalibCoeffs0, pHCalibCoeffs1, OrpCalibCoeffs0, OrpCalibCoeffs1, PSICalibCoeffs0, PSICalibCoeffs1;
double Ph_Kp, Ph_Ki, Ph_Kd, Orp_Kp, Orp_Ki, Orp_Kd, PhPIDOutput, OrpPIDOutput, TempValue, PhValue, OrpValue, PSIValue;
double Ph_Kp, Ph_Ki, Ph_Kd, Orp_Kp, Orp_Ki, Orp_Kd, PhPIDOutput, OrpPIDOutput, TempValue, PhValue, OrpValue, PSIValue, PhValue2, OrpValue2;
double AcidFill, ChlFill, pHTankVol, ChlTankVol, pHPumpFR, ChlPumpFR;
byte ip[4], subnet[4], gateway[4], dnsserver[4], mac[6];
bool ipConfiged;
Expand All @@ -131,35 +123,20 @@ struct StoreStruct
8, 13, 21, 20, 120,
900, 2500,
3000000, 3600000, 0, 0,
#if defined(pHOrpBoard) //using the I2C pHOrpBoard as interface to the pH and Orp probes
7.4, 750.0, 0.5, 0.25, 10.0, 27.0, 3.0, 1.15, 6.97, 244.42, -18.15, 1.11, 0.00,
#else
7.4, 750.0, 0.5, 0.25, 10.0, 27.0, 3.0, 4.78, -2.54, -1291, 2580, 1.11, 0.0,
2000000.0, 0.0, 0.0, 4500.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.4,
#endif
2000000.0, 0.0, 0.0, 4500.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.4, 0.0, 0.0,
100.0, 100.0, 20.0, 20.0, 1.5, 3.0,
{192, 168, 0, 188}, {255, 255, 255, 0}, {192, 168, 0, 254}, {8, 8, 8, 8}, {0xA8, 0x61, 0x0A, 0xAE, 0x2C, 0x68},
0
};

// MAC address of Ethernet shield (in case of Controllino board, set an arbitrary MAC address)
byte mac[] = { 0xA8, 0x61, 0x0A, 0xAE, 0x65, 0x04}; //-> Mega2560 dev setup with Ethernet shield
/*
//MQTT stuff including local broker/server IP address, login and pwd
MQTTClient MQTTClient;
const char* MqttServerIP = "192.168.0.38";
//const char* MqttServerIP = "broker.mqttdashboard.com";//cloud-based MQTT broker to test when node-red and MQTT broker are not installed locally (/!\ public and unsecure!)
const char* MqttServerClientID = "ArduinoPoolTest"; // /!\ choose a client ID which is unique to this Arduino board
const char* MqttServerLogin = nullptr; //replace by const char* MqttServerLogin = nullptr; in case broker does not require a login/pwd
const char* MqttServerPwd = nullptr; //replace by const char* MqttServerPwd = nullptr; in case broker does not require a login/pwd
const char* PoolTopicMeas1 = "Home/PoolTest/Meas1";
const char* PoolTopicMeas2 = "Home/PoolTest/Meas2";
const char* PoolTopicSet1 = "Home/PoolTest/Set1";
const char* PoolTopicSet2 = "Home/PoolTest/Set2";
const char* PoolTopicSet3 = "Home/PoolTest/Set3";
const char* PoolTopicSet4 = "Home/PoolTest/Set4";
const char* PoolTopicSet5 = "Home/PoolTest/Set5";
const char* PoolTopicAPI = "Home/PoolTest/API";
const char* PoolTopicStatus = "Home/PoolTest/status";
const char* PoolTopicError = "Home/PoolTest/Err";
*/
// MAC address of Ethernet shield (in case of Controllino board, set an arbitrary MAC address)
byte mac[] = { 0xA8, 0x61, 0x0A, 0xAE, 0x65, 0x04}; //-> Mega2560 dev setup with Ethernet shield

//MQTT stuff including local broker/server IP address, login and pwd
MQTTClient MQTTClient;
const char* MqttServerIP = "192.168.0.38";
Expand Down
54 changes: 32 additions & 22 deletions source/PoolMaster/Nextion.ino
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ void UpdateTFT()
{
myNex.NextionListen();

sprintf(HourBuffer, "%02d:%02d:%02d", hour(), minute(), second());
myNex.writeStr("page0.vaTime.txt", HourBuffer);
// sprintf(HourBuffer, "%02d:%02d:%02d", hour(), minute(), second());
// myNex.writeStr("page0.vaTime.txt", HourBuffer);

if (Firmw != TFTStruc.FW)
{
Expand Down Expand Up @@ -364,26 +364,28 @@ void UpdateTFT()
myNex.writeStr(F("page0.vapHUTErr.val=0"));
}

//update time at top of displayed page
switch (CurrentPage)
{
case 0: {
myNex.writeStr(F("p0Time.txt"), HourBuffer);
break;
}
case 1: {
myNex.writeStr(F("p1Time.txt"), HourBuffer);
break;
}
case 2: {
myNex.writeStr(F("p2Time.txt"), HourBuffer);
break;
}
case 3: {
myNex.writeStr(F("p3Time.txt"), HourBuffer);
break;
}
}
/*
//update time at top of displayed page
switch (CurrentPage)
{
case 0: {
myNex.writeStr(F("p0Time.txt"), HourBuffer);
break;
}
case 1: {
myNex.writeStr(F("p1Time.txt"), HourBuffer);
break;
}
case 2: {
myNex.writeStr(F("p2Time.txt"), HourBuffer);
break;
}
case 3: {
myNex.writeStr(F("p3Time.txt"), HourBuffer);
break;
}
}
*/
}

//reset TFT at start of controller
Expand Down Expand Up @@ -568,3 +570,11 @@ void trigger12()
String Cmd = F("{\"Clear\":1}");
queueIn.enqueue(Cmd);
}

//Update internal RTC of Nextion
void UpdateNextionRTC(uint32_t Hour, uint32_t Min, uint32_t Sec)
{
myNex.writeNum(F("rtc3"), Hour);
myNex.writeNum(F("rtc4"), Min);
myNex.writeNum(F("rtc5"), Sec);
}
Loading

0 comments on commit a093277

Please sign in to comment.