|
|
@@ -1,356 +1,610 @@
|
|
|
-
|
|
|
-
|
|
|
-/* Comment this out to disable prints and save space */
|
|
|
-//#define BLYNK_PRINT Serial
|
|
|
-
|
|
|
-
|
|
|
-//#include <ESP8266WiFi.h>
|
|
|
#include <BlynkSimpleEsp8266.h>
|
|
|
#include <TimeLib.h>
|
|
|
#include <WidgetRTC.h>
|
|
|
|
|
|
+//#define AQUAGRA
|
|
|
+//#define AQUAZOA
|
|
|
|
|
|
+#ifdef AQUAGRA
|
|
|
+ char auth[] = "_Fw7V6o4bPAovQ1idbetFcith6LmMnyh"; //220L
|
|
|
+#elif AQUAZOA
|
|
|
+ char auth[] = "oObIhJsLplCUAhCBfwyvpBF_n_N8oqJv"; //70L
|
|
|
+#endif
|
|
|
|
|
|
-// You should get Auth Token in the Blynk App.
|
|
|
-// Go to the Project Settings (nut icon).
|
|
|
-char auth[] = "5I28lN8RWcLQLvaoRyv0RNuiuBVwy99K";
|
|
|
-
|
|
|
-// Your WiFi credentials.
|
|
|
-// Set password to "" for open networks.
|
|
|
char ssid[] = "Livebox-7C2C";
|
|
|
char pass[] = "566C61F61F9C925C9F3D7D79E6";
|
|
|
|
|
|
WidgetRTC rtc;
|
|
|
-
|
|
|
BlynkTimer timer;
|
|
|
-
|
|
|
+WidgetTerminal terminal(V60);
|
|
|
|
|
|
//************************************************************************
|
|
|
// Variable Global perso
|
|
|
//************************************************************************
|
|
|
-#define POMPE1 0
|
|
|
-#define POMPE2 1
|
|
|
-#define POMPE3 2
|
|
|
-#define POMPE4 3
|
|
|
+#ifdef AQUA220
|
|
|
+ #define RESERVE 1200
|
|
|
+ #define LITRE 220
|
|
|
+ #define FACTEURML 635 //Temps d'allumage de la pompe en ms pour distribuer 1ml
|
|
|
+ #define RESERVEMIN 100
|
|
|
+ #define STARTCa 16
|
|
|
+ #define STARTKh 30
|
|
|
+ #define STARTMg 7
|
|
|
+#else
|
|
|
+ #define RESERVE 450
|
|
|
+ #define LITRE 70
|
|
|
+ #define FACTEURML 200//todo //Temps d'allumage de la pompe en ms pour distribuer 1ml
|
|
|
+ #define RESERVEMIN 50
|
|
|
+ #define STARTCa 16
|
|
|
+ #define STARTKh 30
|
|
|
+ #define STARTMg 7
|
|
|
+#endif
|
|
|
+
|
|
|
+#define POMPE0 0
|
|
|
+#define POMPE1 1
|
|
|
+#define POMPE2 2
|
|
|
+#define POMPE3 3
|
|
|
+
|
|
|
+//nombre de ml a distribuer pour remonter de +1 (mg ou kh) par litre d'eau
|
|
|
+#define FACTEUR0 0.0057 //FACTEUR CA
|
|
|
+#define FACTEUR1 0.36 //0.36ml/L = +1KH
|
|
|
+#define FACTEUR3 0.02 //FACTEUR MG
|
|
|
+
|
|
|
+const int PINPOMPE0 = 16;
|
|
|
+const int PINPOMPE1 = 5;
|
|
|
+const int PINPOMPE2 = 4;
|
|
|
+const int PINPOMPE3 = 0;
|
|
|
+
|
|
|
+float Mesure0, Mesure1, Mesure2, Mesure3;
|
|
|
+float ML0, ML1, ML2, ML3 ;
|
|
|
+float Cible0, Cible1, Cible2, Cible3 ;
|
|
|
+bool Auto0, Auto1, Auto2, Auto3 ;
|
|
|
+float Reserve0, Reserve1, Reserve2, Reserve3 ;
|
|
|
+float MLForce0, MLForce1, MLForce2, MLForce3 ;
|
|
|
+int dist;
|
|
|
+
|
|
|
+//************************************************************************
|
|
|
+// Fonction Seul
|
|
|
+//************************************************************************
|
|
|
+void Ft_Timer() {
|
|
|
+ int Hmin = hour() * 60 + minute();
|
|
|
+ switch(Hmin){
|
|
|
+ case 0: //Calcium
|
|
|
+ dist=0;
|
|
|
+ AutoDistribue0(ML0);
|
|
|
+ break;
|
|
|
+ case 360: //Calcium
|
|
|
+ dist=1;
|
|
|
+ AutoDistribue0(ML0);
|
|
|
+ break;
|
|
|
+ case 720: //Calcium
|
|
|
+ dist=2;
|
|
|
+ AutoDistribue0(ML0);
|
|
|
+ break;
|
|
|
+ case 1080: //Calcium
|
|
|
+ dist=3;
|
|
|
+ AutoDistribue0(ML0);
|
|
|
+ break;
|
|
|
+ case 90: //KH
|
|
|
+ dist=0;
|
|
|
+ AutoDistribue1(ML1);
|
|
|
+ break;
|
|
|
+ case 450: //KH
|
|
|
+ dist=1;
|
|
|
+ AutoDistribue1(ML1);
|
|
|
+ break;
|
|
|
+ case 810: //KH
|
|
|
+ dist=2;
|
|
|
+ AutoDistribue1(ML1);
|
|
|
+ break;
|
|
|
+ case 1170: //KH
|
|
|
+ dist=3;
|
|
|
+ AutoDistribue1(ML1);
|
|
|
+ break;
|
|
|
+ case 180: //mineral
|
|
|
+ dist=0;
|
|
|
+ AutoDistribue2(ML2);
|
|
|
+ break;
|
|
|
+ case 540: //mineral
|
|
|
+ dist=1;
|
|
|
+ AutoDistribue2(ML2);
|
|
|
+ break;
|
|
|
+ case 900: //mineral
|
|
|
+ dist=2;
|
|
|
+ AutoDistribue2(ML2);
|
|
|
+ break;
|
|
|
+ case 1260: //mineral
|
|
|
+ dist=3;
|
|
|
+ AutoDistribue2(ML2);
|
|
|
+ break;
|
|
|
+ case 270://mg
|
|
|
+ dist=0;
|
|
|
+ AutoDistribue3(ML3);
|
|
|
+ break;
|
|
|
+ case 630://mg
|
|
|
+ dist=1;
|
|
|
+ AutoDistribue3(ML3);
|
|
|
+ break;
|
|
|
+ case 990://mg
|
|
|
+ dist=2;
|
|
|
+ AutoDistribue3(ML3);
|
|
|
+ break;
|
|
|
+ case 1350://mg
|
|
|
+ dist=3;
|
|
|
+ AutoDistribue3(ML3);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
-#define FACTEURML 635
|
|
|
+BLYNK_CONNECTED() {
|
|
|
+ char message[30];
|
|
|
+ sprintf(message, "\nnew Connection\n");
|
|
|
+ terminal.print(message);
|
|
|
+ terminal.flush();
|
|
|
|
|
|
-#define INTER24H 1
|
|
|
-#define INTER12H 2
|
|
|
-#define INTER6H 3
|
|
|
+ rtc.begin();
|
|
|
|
|
|
-int inter1, inter2, inter3, inter4;
|
|
|
+ Blynk.syncAll();
|
|
|
+}
|
|
|
|
|
|
-const int PINPOMPE1 = 16;
|
|
|
-const int PINPOMPE2 = 5;
|
|
|
-const int PINPOMPE3 = 4;
|
|
|
-const int PINPOMPE4 = 0;
|
|
|
+BLYNK_WRITE(V60){
|
|
|
+ if (String("Ca") == param.asStr())
|
|
|
+ Blynk.virtualWrite(V3, STARTCa);
|
|
|
+ if (String("Kh") == param.asStr())
|
|
|
+ Blynk.virtualWrite(V13, STARTKh);
|
|
|
+ if (String("Mi") == param.asStr())
|
|
|
+ Blynk.virtualWrite(V23, (ML0+ML1)/2);
|
|
|
+ if (String("Mg") == param.asStr())
|
|
|
+ Blynk.virtualWrite(V33, STARTMg);
|
|
|
+}
|
|
|
|
|
|
-float ML1 = 0.0;
|
|
|
-float ML2 = 0.0;
|
|
|
-float ML3 = 0.0;
|
|
|
-float ML4 = 0.0;
|
|
|
|
|
|
+void setup(){
|
|
|
|
|
|
-float nbMLTest = 2.0;
|
|
|
+ //Pin Setup
|
|
|
+ pinMode(PINPOMPE0, OUTPUT);
|
|
|
+ pinMode(PINPOMPE1, OUTPUT);
|
|
|
+ pinMode(PINPOMPE2, OUTPUT);
|
|
|
+ pinMode(PINPOMPE3, OUTPUT);
|
|
|
+
|
|
|
+ digitalWrite(PINPOMPE0, HIGH);
|
|
|
+ digitalWrite(PINPOMPE1, HIGH);
|
|
|
+ digitalWrite(PINPOMPE2, HIGH);
|
|
|
+ digitalWrite(PINPOMPE3, HIGH);
|
|
|
|
|
|
-bool AUTO1 = false;
|
|
|
-bool AUTO2 = false;
|
|
|
-bool AUTO3 = false;
|
|
|
-bool AUTO4 = false;
|
|
|
+ Blynk.begin(auth, ssid, pass, IPAddress(192, 168, 1, 18), 8081);
|
|
|
+
|
|
|
+ setSyncInterval(10 * 60); // Sync interval in seconds (10 minutes)
|
|
|
|
|
|
-#define H1 0*60
|
|
|
-#define H2 6*60
|
|
|
-#define H3 12*60
|
|
|
-#define H4 18*60
|
|
|
+ timer.setInterval(1000L*60, Ft_Timer);
|
|
|
+}
|
|
|
|
|
|
+void loop(){
|
|
|
+ Blynk.run();
|
|
|
+ timer.run();
|
|
|
+}
|
|
|
//************************************************************************
|
|
|
-// Fonction
|
|
|
+// Fonction Calcium
|
|
|
//************************************************************************
|
|
|
-void Active1(float ml) {
|
|
|
- if (AUTO1) {
|
|
|
- char message[30];
|
|
|
- digitalWrite(PINPOMPE1, LOW);
|
|
|
- delay(FACTEURML * ml);
|
|
|
- digitalWrite(PINPOMPE1, HIGH);
|
|
|
- Serial.print("Distribue pompe1 : ");
|
|
|
- Serial.print(ml);
|
|
|
- Serial.println("ml");
|
|
|
- sprintf(message, "Distribution %.1fml de calcium", ml);
|
|
|
- //Blynk.notify(message);
|
|
|
+
|
|
|
+void AutoDistribue0(float ml){
|
|
|
+
|
|
|
+ if (Auto0) {
|
|
|
+ if(((ML0/4)*FACTEURML)>(1000*4)){
|
|
|
+ }
|
|
|
+ else if((((ML0/2)*FACTEURML)>(1000*2))&(dist==0|dist==2)){
|
|
|
+ Active0(ML0/2);
|
|
|
+ }
|
|
|
+ else if (dist==0){
|
|
|
+ Active0(ML0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ Blynk.notify("Calcium est Arreter");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void Active0(float ml) {
|
|
|
+ digitalWrite(PINPOMPE0, LOW);
|
|
|
+ delay(FACTEURML * ml);
|
|
|
+ digitalWrite(PINPOMPE0, HIGH);
|
|
|
+ Reserve0=Reserve0-ml;
|
|
|
+ Blynk.virtualWrite(V4, Reserve0);
|
|
|
+ char message[30];
|
|
|
+ sprintf(message, "Distribution %.1fml de Calcium a %d:%d\n", ml,hour(),minute());
|
|
|
+ terminal.print(message);
|
|
|
+ terminal.flush();
|
|
|
+ if(Reserve0<RESERVEMIN)
|
|
|
+ Blynk.notify("Penser a remettre du Calcium");
|
|
|
+}
|
|
|
|
|
|
-void Active2(float ml) {
|
|
|
- if (AUTO2) {
|
|
|
- char message[30];
|
|
|
- digitalWrite(PINPOMPE2, LOW);
|
|
|
- delay(FACTEURML * ml);
|
|
|
- digitalWrite(PINPOMPE2, HIGH);
|
|
|
- Serial.print("Distribue pompe2 : ");
|
|
|
- Serial.print(ml);
|
|
|
- Serial.println("ml");
|
|
|
- sprintf(message, "Distribution %.1fml de KH", ml);
|
|
|
- //Blynk.notify(message);
|
|
|
+//Mesure
|
|
|
+BLYNK_WRITE(V0) {
|
|
|
+ if(Mesure0==0){//Si nouvelle connection on recupere juste la valeur enregistrer sur le server
|
|
|
+ Mesure0 = param.asFloat();
|
|
|
+ return;
|
|
|
}
|
|
|
+ Mesure0 = param.asFloat();
|
|
|
+
|
|
|
+ ML0 = ML0 + (((ML0/Mesure0)* Cible0 - ML0)/4.0);
|
|
|
+ MLForce0 = (Cible0-Mesure0)*FACTEUR0*LITRE;
|
|
|
+
|
|
|
+ if(MLForce0<0)
|
|
|
+ MLForce0=0;
|
|
|
+
|
|
|
+ ML2 = (ML1+ML0)/2.0;
|
|
|
+ Blynk.virtualWrite(V23, ML2);
|
|
|
+ Blynk.virtualWrite(V3, ML0);
|
|
|
+ Blynk.virtualWrite(V7, MLForce0);
|
|
|
}
|
|
|
|
|
|
-void Active3(float ml) {
|
|
|
- if (AUTO3) {
|
|
|
- char message[30];
|
|
|
- digitalWrite(PINPOMPE3, LOW);
|
|
|
- delay(FACTEURML * ml);
|
|
|
- digitalWrite(PINPOMPE3, HIGH);
|
|
|
- Serial.print("Distribue pompe3 : ");
|
|
|
- Serial.print(ml);
|
|
|
- Serial.println("ml");
|
|
|
- sprintf(message, "Distribution %.1fml de Iode", ml);
|
|
|
- //Blynk.notify(message);
|
|
|
+//Cible
|
|
|
+BLYNK_WRITE(V1) {
|
|
|
+ if(Cible0==0){//Si nouvelle connection on recupere juste la valeur enregistrer sur le server
|
|
|
+ Cible0 = param.asFloat();
|
|
|
+ return;
|
|
|
}
|
|
|
+ Cible0 = param.asFloat();
|
|
|
+ ML0 = ML0 +(((ML0/Mesure0)* Cible0- ML0)/4.0);
|
|
|
+ ML2 = (ML1+ML0)/2.0;
|
|
|
+
|
|
|
+ Blynk.virtualWrite(V23, ML2);
|
|
|
+ Blynk.virtualWrite(V3, ML0);
|
|
|
}
|
|
|
|
|
|
-void Active4(float ml) {
|
|
|
- if (AUTO4) {
|
|
|
- char message[30];
|
|
|
- digitalWrite(PINPOMPE4, LOW);
|
|
|
- delay(FACTEURML * ml);
|
|
|
- digitalWrite(PINPOMPE4, HIGH);
|
|
|
- Serial.print("Distribue pompe4 : ");
|
|
|
- Serial.print(ml);
|
|
|
- Serial.println("ml");
|
|
|
- sprintf(message, "Distribution %.1fml de Pompe4", ml);
|
|
|
- //Blynk.notify(message);
|
|
|
+//En route
|
|
|
+BLYNK_WRITE(V2) {
|
|
|
+ if ( param.asInt()){
|
|
|
+ Auto0 = true;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ Auto0 = false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void Ft_Timer() {
|
|
|
- int Hmin = hour() * 60 + minute();
|
|
|
- Serial.println(Hmin);
|
|
|
- switch (Hmin) {
|
|
|
- case ( H1):
|
|
|
- Active1(ML1);
|
|
|
- break;
|
|
|
- case ( H1 + 30 ):
|
|
|
- Active2(ML2);
|
|
|
- break;
|
|
|
- case ( H1 + 60 ):
|
|
|
- Active3(ML3);
|
|
|
- break;
|
|
|
- case ( H1 + 90 ):
|
|
|
- Active4(ML4);
|
|
|
- break;
|
|
|
- case H2:
|
|
|
- if (inter1 == INTER6H)
|
|
|
- Active1(ML1);
|
|
|
- break;
|
|
|
- case H2+30:
|
|
|
- if (inter2 == INTER6H)
|
|
|
- Active2(ML2);
|
|
|
- break;
|
|
|
- case H2+60:
|
|
|
- if (inter3 == INTER6H)
|
|
|
- Active3(ML3);
|
|
|
- break;
|
|
|
- case H2+90:
|
|
|
- if (inter4 == INTER6H)
|
|
|
- Active4(ML4);
|
|
|
- break;
|
|
|
- case H3:
|
|
|
- if (inter1 == INTER12H)
|
|
|
- Active1(ML1);
|
|
|
- break;
|
|
|
- case H3+30:
|
|
|
- if (inter2 == INTER12H)
|
|
|
- Active2(ML2);
|
|
|
- break;
|
|
|
- case H3+60:
|
|
|
- if (inter3 == INTER12H)
|
|
|
- Active3(ML3);
|
|
|
- break;
|
|
|
- case H3+90:
|
|
|
- if (inter4 == INTER12H)
|
|
|
- Active4(ML4);
|
|
|
- break;
|
|
|
- case H4:
|
|
|
- if (inter1 == INTER6H)
|
|
|
- Active1(ML1);
|
|
|
- break;
|
|
|
- case H4+30:
|
|
|
- if (inter2 == INTER6H)
|
|
|
- Active2(ML2);
|
|
|
- break;
|
|
|
- case H4+60:
|
|
|
- if (inter3 == INTER6H)
|
|
|
- Active3(ML3);
|
|
|
- break;
|
|
|
- case H4+90:
|
|
|
- if (inter4 == INTER6H)
|
|
|
- Active4(ML4);
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
+BLYNK_WRITE(V3){
|
|
|
+ ML0=param.asFloat();
|
|
|
+ Blynk.virtualWrite(V3, ML0);
|
|
|
+}
|
|
|
+
|
|
|
+BLYNK_WRITE(V4){
|
|
|
+ Reserve0=param.asFloat();
|
|
|
+ Blynk.virtualWrite(V4, Reserve0);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+//RAZ Reserve
|
|
|
+BLYNK_WRITE(V5){
|
|
|
+ if(param.asInt()){
|
|
|
+ Reserve0=RESERVE;
|
|
|
+ Blynk.virtualWrite(V4, Reserve0);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+//Forcé4
|
|
|
+BLYNK_WRITE(V6){
|
|
|
+ if(param.asInt()){
|
|
|
+ Active0(4.0);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//NB/Forcé
|
|
|
+BLYNK_WRITE(V7){
|
|
|
+ MLForce0=param.asFloat();
|
|
|
+}
|
|
|
+
|
|
|
+//Forcé
|
|
|
+BLYNK_WRITE(V8){
|
|
|
+ if ( param.asInt()){
|
|
|
+ Active0(MLForce0);
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
|
|
//************************************************************************
|
|
|
-// Fonction Blynk
|
|
|
+// Fonction KH
|
|
|
//************************************************************************
|
|
|
|
|
|
-BLYNK_CONNECTED() {
|
|
|
- Blynk.syncAll();
|
|
|
- rtc.begin();
|
|
|
+void AutoDistribue1(float ml){
|
|
|
+ if (Auto1) {
|
|
|
+ if(((ML1/4)*FACTEURML)>(1000*4)){
|
|
|
+ }
|
|
|
+ else if((((ML1/2)*FACTEURML)>(1000*2))&(dist==0|dist==2)){
|
|
|
+ Active1(ML1/2);
|
|
|
+ }
|
|
|
+ else if (dist==0){
|
|
|
+ Active1(ML1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ Blynk.notify("KH est Arreter");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+void Active1(float ml) {
|
|
|
+ digitalWrite(PINPOMPE1, LOW);
|
|
|
+ delay(FACTEURML * ml);
|
|
|
+ digitalWrite(PINPOMPE1, HIGH);
|
|
|
+ Reserve1=Reserve1-ml;
|
|
|
+ Blynk.virtualWrite(V14, Reserve1);
|
|
|
+ char message[30];
|
|
|
+ sprintf(message, "Distribution %.1fml de KH a %d:%d\n", ml,hour(),minute());
|
|
|
+ terminal.print(message);
|
|
|
+ terminal.flush();
|
|
|
+ if(Reserve1<RESERVEMIN)
|
|
|
+ Blynk.notify("Penser a remettre du KH");
|
|
|
+}
|
|
|
|
|
|
-//Quantité
|
|
|
-BLYNK_WRITE(V0) {
|
|
|
- float ml = param.asFloat();
|
|
|
- if (ml < 10) {
|
|
|
- inter1 = INTER24H;
|
|
|
- ML1 = ml;
|
|
|
- }
|
|
|
- else if (ml < 30) {
|
|
|
- inter1 = INTER12H;
|
|
|
- ML1 = ml / 2;
|
|
|
- }
|
|
|
- else {
|
|
|
- inter1 = INTER6H;
|
|
|
- ML1 = ml / 4;
|
|
|
+//Mesure
|
|
|
+BLYNK_WRITE(V10) {
|
|
|
+ if(Mesure1==0){//Si nouvelle connection on recupere juste la valeur enregistrer sur le server
|
|
|
+ Mesure1 = param.asFloat();
|
|
|
+ return;
|
|
|
}
|
|
|
+ Mesure1 = param.asFloat();
|
|
|
+
|
|
|
+ ML1 = ML1 + (((ML1/Mesure1)* Cible1 - ML1)/4.0);
|
|
|
+ MLForce1 = (Cible1-Mesure1)*FACTEUR1*LITRE;
|
|
|
+ if(MLForce1<0)
|
|
|
+ MLForce1=0;
|
|
|
+
|
|
|
+ ML2 = (ML1+ML0)/2.0;
|
|
|
+ Blynk.virtualWrite(V23, ML2);
|
|
|
+ Blynk.virtualWrite(V13, ML1);
|
|
|
+ Blynk.virtualWrite(V17, MLForce1);
|
|
|
}
|
|
|
|
|
|
-BLYNK_WRITE(V1) {
|
|
|
- float ml = param.asFloat();
|
|
|
- if (ml < 10) {
|
|
|
- inter2 = INTER24H;
|
|
|
- ML2 = ml;
|
|
|
+//Cible
|
|
|
+BLYNK_WRITE(V11) {
|
|
|
+ if(Cible1==0){//Si nouvelle connection on recupere juste la valeur enregistrer sur le server
|
|
|
+ Cible1 = param.asFloat();
|
|
|
+ return;
|
|
|
}
|
|
|
- else if (ml < 30) {
|
|
|
- inter2 = INTER12H;
|
|
|
- ML2 = ml / 2;
|
|
|
+ Cible1 = param.asFloat();
|
|
|
+ ML1 = ML1 +(((ML1/Mesure1) * Cible1- ML1)/4.0);
|
|
|
+
|
|
|
+ ML2 = (ML0+ML1)/2.0;
|
|
|
+
|
|
|
+ Blynk.virtualWrite(V23, ML2);
|
|
|
+ Blynk.virtualWrite(V13, ML1);
|
|
|
+}
|
|
|
+
|
|
|
+//En route
|
|
|
+BLYNK_WRITE(V12) {
|
|
|
+ if ( param.asInt()){
|
|
|
+ Auto1 = true;
|
|
|
}
|
|
|
- else {
|
|
|
- inter2 = INTER6H;
|
|
|
- ML2 = ml / 4;
|
|
|
+ else{
|
|
|
+ Auto1 = false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-BLYNK_WRITE(V2) {
|
|
|
- float ml = param.asFloat();
|
|
|
- if (ml < 10) {
|
|
|
- inter3 = INTER24H;
|
|
|
- ML3 = ml;
|
|
|
- }
|
|
|
- else if (ml < 30) {
|
|
|
- inter3 = INTER12H;
|
|
|
- ML3 = ml / 2;
|
|
|
+BLYNK_WRITE(V13){
|
|
|
+ ML1=param.asFloat();
|
|
|
+ Blynk.virtualWrite(V13, ML1);
|
|
|
+}
|
|
|
+
|
|
|
+BLYNK_WRITE(V14){
|
|
|
+ Reserve1=param.asFloat();
|
|
|
+ Blynk.virtualWrite(V14, Reserve1);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+//RAZ Reserve
|
|
|
+BLYNK_WRITE(V15){
|
|
|
+ if(param.asInt()){
|
|
|
+ Reserve1=RESERVE;
|
|
|
+ Blynk.virtualWrite(V14, Reserve1);
|
|
|
}
|
|
|
- else {
|
|
|
- inter3 = INTER6H;
|
|
|
- ML3 = ml / 4;
|
|
|
+}
|
|
|
+
|
|
|
+//Forcé4
|
|
|
+BLYNK_WRITE(V16){
|
|
|
+ if(param.asInt()){
|
|
|
+ Active1(4.0);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-BLYNK_WRITE(V3) {
|
|
|
- float ml = param.asFloat();
|
|
|
- if (ml < 10) {
|
|
|
- inter4 = INTER24H;
|
|
|
- ML4 = ml;
|
|
|
+//NB/Forcé
|
|
|
+BLYNK_WRITE(V17){
|
|
|
+ MLForce1=param.asFloat();
|
|
|
+}
|
|
|
+
|
|
|
+//Forcé
|
|
|
+BLYNK_WRITE(V18){
|
|
|
+ if ( param.asInt()){
|
|
|
+ Active1(MLForce1);
|
|
|
}
|
|
|
- else if (ml < 30) {
|
|
|
- inter4 = INTER12H;
|
|
|
- ML4 = ml / 2;
|
|
|
+}
|
|
|
+
|
|
|
+//************************************************************************
|
|
|
+// Fonction Mineral
|
|
|
+//************************************************************************
|
|
|
+
|
|
|
+void AutoDistribue2(float ml){
|
|
|
+ if (Auto2) {
|
|
|
+ if(((ML2/4)*FACTEURML)>(1000*4)){
|
|
|
+ }
|
|
|
+ else if((((ML2/2)*FACTEURML)>(1000*2))&(dist==0|dist==2)){
|
|
|
+ Active2(ML2/2);
|
|
|
+ }
|
|
|
+ else if (dist==0){
|
|
|
+ Active2(ML2);
|
|
|
+ }
|
|
|
}
|
|
|
- else {
|
|
|
- inter4 = INTER6H;
|
|
|
- ML4 = ml / 4;
|
|
|
+ else{
|
|
|
+ Blynk.notify("Mineral est Arreter");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//ON/OFF Auto
|
|
|
-BLYNK_WRITE(V4) {
|
|
|
- if ( param.asInt()) {
|
|
|
- AUTO1 = true;
|
|
|
+void Active2(float ml) {
|
|
|
+ digitalWrite(PINPOMPE2, LOW);
|
|
|
+ delay(FACTEURML * ml);
|
|
|
+ digitalWrite(PINPOMPE2, HIGH);
|
|
|
+ Reserve2=Reserve2-ml;
|
|
|
+ Blynk.virtualWrite(V24, Reserve2);
|
|
|
+ char message[30];
|
|
|
+ sprintf(message, "Distribution %.1fml de Mineral a %d:%d\n", ml,hour(),minute());
|
|
|
+ terminal.print(message);
|
|
|
+ terminal.flush();
|
|
|
+ if(Reserve2<RESERVEMIN)
|
|
|
+ Blynk.notify("Penser a remettre du Mineral");
|
|
|
+}
|
|
|
+
|
|
|
+//En route
|
|
|
+BLYNK_WRITE(V22) {
|
|
|
+ if ( param.asInt()){
|
|
|
+ Auto2 = true;
|
|
|
}
|
|
|
- else
|
|
|
- AUTO1 = false;
|
|
|
+ else{
|
|
|
+ Auto2 = false;
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
+BLYNK_WRITE(V23){
|
|
|
+ ML2=param.asFloat();
|
|
|
+ Blynk.virtualWrite(V23, ML2);
|
|
|
}
|
|
|
-BLYNK_WRITE(V5) {
|
|
|
- if ( param.asInt())
|
|
|
- AUTO2 = true;
|
|
|
- else
|
|
|
- AUTO2 = false;
|
|
|
|
|
|
+BLYNK_WRITE(V24){
|
|
|
+ Reserve2=param.asFloat();
|
|
|
+ Blynk.virtualWrite(V24, Reserve2);
|
|
|
}
|
|
|
-BLYNK_WRITE(V6) {
|
|
|
- if ( param.asInt())
|
|
|
- AUTO3 = true;
|
|
|
- else
|
|
|
- AUTO3 = false;
|
|
|
+
|
|
|
+
|
|
|
+//RAZ Reserve
|
|
|
+BLYNK_WRITE(V25){
|
|
|
+ if(param.asInt()){
|
|
|
+ Reserve2=RESERVE;
|
|
|
+ Blynk.virtualWrite(V24, Reserve2);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//Forcé4
|
|
|
+BLYNK_WRITE(V26){
|
|
|
+ if(param.asInt()){
|
|
|
+ Active2(4.0);
|
|
|
+ }
|
|
|
}
|
|
|
-BLYNK_WRITE(V7) {
|
|
|
- if ( param.asInt())
|
|
|
- AUTO4 = true;
|
|
|
- else
|
|
|
- AUTO4 = false;
|
|
|
|
|
|
+//NB/Forcé
|
|
|
+BLYNK_WRITE(V27){
|
|
|
+ MLForce2=param.asFloat();
|
|
|
}
|
|
|
|
|
|
//Forcé
|
|
|
-BLYNK_WRITE(V12) {
|
|
|
- if ( param.asInt())
|
|
|
- Active1(nbMLTest);
|
|
|
+BLYNK_WRITE(V28){
|
|
|
+ if ( param.asInt()){
|
|
|
+ Active2(MLForce2);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-BLYNK_WRITE(V13) {
|
|
|
- if ( param.asInt())
|
|
|
- Active2(nbMLTest);
|
|
|
+//************************************************************************
|
|
|
+// Fonction Magnesium
|
|
|
+//************************************************************************
|
|
|
+
|
|
|
+void AutoDistribue3(float ml){
|
|
|
+ if (Auto3) {
|
|
|
+ if(((ML3/4)*FACTEURML)>(1000*4)){
|
|
|
+ }
|
|
|
+ else if((((ML3/2)*FACTEURML)>(1000*2))&(dist==0|dist==2)){
|
|
|
+ Active3(ML3/2);
|
|
|
+ }
|
|
|
+ else if (dist==0){
|
|
|
+ Active3(ML3);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ Blynk.notify("Magnesium est Arreter");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-BLYNK_WRITE(V14) {
|
|
|
- if ( param.asInt())
|
|
|
- Active3(nbMLTest);
|
|
|
+void Active3(float ml) {
|
|
|
+ digitalWrite(PINPOMPE3, LOW);
|
|
|
+ delay(FACTEURML * ml);
|
|
|
+ digitalWrite(PINPOMPE3, HIGH);
|
|
|
+ Reserve3=Reserve3-ml;
|
|
|
+ Blynk.virtualWrite(V34, Reserve3);
|
|
|
+ char message[30];
|
|
|
+ sprintf(message, "Distribution %.1fml de Magnesium a %d:%d\n", ml,hour(),minute());
|
|
|
+ terminal.print(message);
|
|
|
+ terminal.flush();
|
|
|
+ if(Reserve3<RESERVEMIN)
|
|
|
+ Blynk.notify("Penser a remettre du Magnesium");
|
|
|
}
|
|
|
|
|
|
-BLYNK_WRITE(V15) {
|
|
|
- if ( param.asInt())
|
|
|
- Active4(nbMLTest);
|
|
|
+//Mesure
|
|
|
+BLYNK_WRITE(V30) {
|
|
|
+ if(Mesure3==0){//Si nouvelle connection on recupere juste la valeur enregistrer sur le server
|
|
|
+ Mesure3 = param.asFloat();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Mesure3 = param.asFloat();
|
|
|
+ ML3 = ML3 + (((ML3/Mesure3)* Cible3 - ML3)/4.0);
|
|
|
+ MLForce3 = (Cible3-Mesure3)*FACTEUR3*LITRE;
|
|
|
+ if(MLForce3<0)
|
|
|
+ MLForce3=0;
|
|
|
+
|
|
|
+ Blynk.virtualWrite(V33, ML3);
|
|
|
+ Blynk.virtualWrite(V37, MLForce3);
|
|
|
}
|
|
|
|
|
|
+//Cible
|
|
|
+BLYNK_WRITE(V31) {
|
|
|
+ if(Cible3==0){//Si nouvelle connection on recupere juste la valeur enregistrer sur le server
|
|
|
+ Cible3 = param.asFloat();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Cible3 = param.asFloat();
|
|
|
+ ML3 = ML3 +(((ML3/Mesure3)* Cible3- ML3)/4.0);
|
|
|
+ Blynk.virtualWrite(V23, ML2);
|
|
|
+ Blynk.virtualWrite(V33, ML3);
|
|
|
+}
|
|
|
|
|
|
-void setup()
|
|
|
-{
|
|
|
- // Debug console
|
|
|
- Serial.begin(9600);
|
|
|
- Serial.println("Start");
|
|
|
+//En route
|
|
|
+BLYNK_WRITE(V32) {
|
|
|
+ if ( param.asInt()){
|
|
|
+ Auto3 = true;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ Auto3 = false;
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
- //Pin Setup
|
|
|
- pinMode(PINPOMPE1, OUTPUT);
|
|
|
- pinMode(PINPOMPE2, OUTPUT);
|
|
|
- pinMode(PINPOMPE3, OUTPUT);
|
|
|
- pinMode(PINPOMPE4, OUTPUT);
|
|
|
- digitalWrite(PINPOMPE1, HIGH);
|
|
|
- digitalWrite(PINPOMPE2, HIGH);
|
|
|
- digitalWrite(PINPOMPE3, HIGH);
|
|
|
- digitalWrite(PINPOMPE4, HIGH);
|
|
|
+BLYNK_WRITE(V33){
|
|
|
+ ML3=param.asFloat();
|
|
|
+ Blynk.virtualWrite(V33, ML3);
|
|
|
+}
|
|
|
|
|
|
- //Blynk.begin(auth, ssid, pass);
|
|
|
- // You can also specify server:
|
|
|
- //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
|
|
|
- Blynk.begin(auth, ssid, pass, IPAddress(192, 168, 1, 18), 8081);
|
|
|
+BLYNK_WRITE(V34){
|
|
|
+ Reserve3=param.asFloat();
|
|
|
+ Blynk.virtualWrite(V34, Reserve3);
|
|
|
+}
|
|
|
|
|
|
- setSyncInterval(10 * 60); // interval de syncro de la RTC (10 min)
|
|
|
|
|
|
- timer.setInterval(60000L, Ft_Timer);
|
|
|
+//RAZ Reserve
|
|
|
+BLYNK_WRITE(V35){
|
|
|
+ if(param.asInt()){
|
|
|
+ Reserve3=RESERVE;
|
|
|
+ Blynk.virtualWrite(V34, Reserve3);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-void loop()
|
|
|
-{
|
|
|
- Blynk.run();
|
|
|
- timer.run();
|
|
|
+//Forcé4
|
|
|
+BLYNK_WRITE(V36){
|
|
|
+ if(param.asInt()){
|
|
|
+ Active3(4.0);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//NB/Forcé
|
|
|
+BLYNK_WRITE(V37){
|
|
|
+ MLForce3=param.asFloat();
|
|
|
+}
|
|
|
+
|
|
|
+//Forcé
|
|
|
+BLYNK_WRITE(V38){
|
|
|
+ if ( param.asInt()){
|
|
|
+ Active3(MLForce3);
|
|
|
+ }
|
|
|
}
|