test commit après reinstall
This commit is contained in:
@@ -38,26 +38,26 @@ const char* adminPassword = "setaou"; // Mot de passe pour la connexion
|
|||||||
//#define PIN_DIMMER_OUTPUT 18 // D8
|
//#define PIN_DIMMER_OUTPUT 18 // D8
|
||||||
//#define PIN_DIMMER_ZEROCROSS 19 // 12 // D6 for boards with CHANGEBLE input pins
|
//#define PIN_DIMMER_ZEROCROSS 19 // 12 // D6 for boards with CHANGEBLE input pins
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
#define PIN_SOFTWARE_SERIAL_RX D4 // GPIO2
|
#define PIN_SOFTWARE_SERIAL_RX D4 // GPIO2
|
||||||
#define PIN_SOFTWARE_SERIAL_TX D2 // GPIO4
|
#define PIN_SOFTWARE_SERIAL_TX D2 // GPIO4
|
||||||
#elif defined(ESP32)
|
#elif defined(ESP32)
|
||||||
//#define PZEM true
|
//#define PZEM true
|
||||||
#define PIN_LED 2
|
#define PIN_LED 2
|
||||||
#define SERIAL_BLUE_SOLAR true
|
#define SERIAL_BLUE_SOLAR true
|
||||||
#define SERIAL_XY6020L true
|
#define SERIAL_XY6020L true
|
||||||
//#define SERIAL_XY6020L_2 true
|
//#define SERIAL_XY6020L_2 true
|
||||||
|
|
||||||
|
|
||||||
#define PIN_SOFTWARE_SERIAL_RX 4
|
#define PIN_SOFTWARE_SERIAL_RX 4
|
||||||
#define PIN_SOFTWARE_SERIAL_TX 5
|
#define PIN_SOFTWARE_SERIAL_TX 5
|
||||||
#define PIN_SOFTWARE_SERIAL_RX2 25
|
#define PIN_SOFTWARE_SERIAL_RX2 25
|
||||||
#define PIN_SOFTWARE_SERIAL_TX2 26
|
#define PIN_SOFTWARE_SERIAL_TX2 26
|
||||||
#define PIN_SOFTWARE_SERIAL_TX3 32
|
#define PIN_SOFTWARE_SERIAL_TX3 32
|
||||||
#define PIN_SOFTWARE_SERIAL_RX3 33
|
#define PIN_SOFTWARE_SERIAL_RX3 33
|
||||||
|
|
||||||
#define PIN_REGULATION 21
|
#define PIN_REGULATION 21
|
||||||
// #define PIN_DALLAS 26 // D5
|
// #define PIN_DALLAS 26 // D5
|
||||||
//#define PIN_HALL 33
|
//#define PIN_HALL 33
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -146,21 +146,21 @@ dimmerLamp dimmer(PIN_DIMMER_OUTPUT, PIN_DIMMER_ZEROCROSS); //initialase port fo
|
|||||||
// DALLAS
|
// DALLAS
|
||||||
/////////////////////////////////////////
|
/////////////////////////////////////////
|
||||||
#ifdef PIN_DALLAS
|
#ifdef PIN_DALLAS
|
||||||
float temperature = 0;
|
float temperature = 0;
|
||||||
|
|
||||||
#include <OneWire.h>
|
#include <OneWire.h>
|
||||||
#include <DallasTemperature.h>
|
#include <DallasTemperature.h>
|
||||||
#define onewirepin PIN_DALLAS // DATA pin of DS18B20 wired to pin DALLAS of Arduino
|
#define onewirepin PIN_DALLAS // DATA pin of DS18B20 wired to pin DALLAS of Arduino
|
||||||
|
|
||||||
OneWire oneWire(onewirepin);
|
OneWire oneWire(onewirepin);
|
||||||
DallasTemperature sensors(&oneWire);
|
DallasTemperature sensors(&oneWire);
|
||||||
|
|
||||||
// find the DeviceAddress of your DS18B20 with the sketch DS18B20_address_reporter
|
// find the DeviceAddress of your DS18B20 with the sketch DS18B20_address_reporter
|
||||||
// then replace the 8-byte ID below with the reported one
|
// then replace the 8-byte ID below with the reported one
|
||||||
|
|
||||||
DeviceAddress Probe = { 0x28, 0xFF, 0x61, 0x1D, 0x76, 0x04, 0x00, 0x34 };
|
DeviceAddress Probe = { 0x28, 0xFF, 0x61, 0x1D, 0x76, 0x04, 0x00, 0x34 };
|
||||||
|
|
||||||
float printTemperature(DeviceAddress deviceAddress);
|
float printTemperature(DeviceAddress deviceAddress);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void blink();
|
void blink();
|
||||||
@@ -216,26 +216,26 @@ unsigned long lastTimeRead = millis();
|
|||||||
// PZEM for arduino
|
// PZEM for arduino
|
||||||
// -----------------
|
// -----------------
|
||||||
#ifdef PZEM
|
#ifdef PZEM
|
||||||
#include <PZEM004Tv30.h>
|
#include <PZEM004Tv30.h>
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
#define PIN_PZEM_1 D5
|
#define PIN_PZEM_1 D5
|
||||||
#define PIN_PZEM_2 D6
|
#define PIN_PZEM_2 D6
|
||||||
PZEM004Tv30 pzem(PIN_PZEM_1, PIN_PZEM_2);
|
PZEM004Tv30 pzem(PIN_PZEM_1, PIN_PZEM_2);
|
||||||
|
|
||||||
#elif defined(ESP32)
|
#elif defined(ESP32)
|
||||||
|
|
||||||
#define RXD2 16
|
#define RXD2 16
|
||||||
#define TXD2 17
|
#define TXD2 17
|
||||||
PZEM004Tv30 pzem(&Serial2);
|
PZEM004Tv30 pzem(&Serial2);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
double voltage;
|
double voltage;
|
||||||
double current;
|
double current;
|
||||||
double pf;
|
double pf;
|
||||||
double power;
|
double power;
|
||||||
double energy;
|
double energy;
|
||||||
double frequency;
|
double frequency;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -245,49 +245,49 @@ void setup() {
|
|||||||
// initialize digital pin LED_BUILTIN as an output.
|
// initialize digital pin LED_BUILTIN as an output.
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
||||||
#ifdef PZEM
|
#ifdef PZEM
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
|
Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PIN_TENSION
|
#ifdef PIN_TENSION
|
||||||
pinMode(PIN_TENSION, INPUT);
|
pinMode(PIN_TENSION, INPUT);
|
||||||
#endif
|
#endif
|
||||||
#ifdef PIN_HALL
|
#ifdef PIN_HALL
|
||||||
pinMode(PIN_HALL, INPUT);
|
pinMode(PIN_HALL, INPUT);
|
||||||
delay(200);
|
delay(200);
|
||||||
getHall();
|
getHall();
|
||||||
#endif
|
#endif
|
||||||
#ifdef PIN_POWER
|
#ifdef PIN_POWER
|
||||||
pinMode(PIN_POWER, OUTPUT);
|
pinMode(PIN_POWER, OUTPUT);
|
||||||
#endif
|
#endif
|
||||||
#ifdef PIN_LED
|
#ifdef PIN_LED
|
||||||
pinMode(PIN_LED, OUTPUT);
|
pinMode(PIN_LED, OUTPUT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pinMode(PIN_INJECTION, OUTPUT);
|
pinMode(PIN_INJECTION, OUTPUT);
|
||||||
pinMode(PIN_CHARGE, OUTPUT);
|
pinMode(PIN_CHARGE, OUTPUT);
|
||||||
#ifdef PIN_BATTERIE
|
#ifdef PIN_BATTERIE
|
||||||
pinMode(PIN_BATTERIE, OUTPUT);
|
pinMode(PIN_BATTERIE, OUTPUT);
|
||||||
#endif
|
#endif
|
||||||
#ifdef PIN_REGULATION
|
#ifdef PIN_REGULATION
|
||||||
|
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
// ledcAttachPin(PIN_REGULATION, 0); // assign a led pins to a channel
|
// ledcAttachPin(PIN_REGULATION, 0); // assign a led pins to a channel
|
||||||
// // Initialize channels
|
// // Initialize channels
|
||||||
// // channels 0-15, resolution 1-16 bits, freq limits depend on resolution
|
// // channels 0-15, resolution 1-16 bits, freq limits depend on resolution
|
||||||
// // ledcSetup(uint8_t channel, uint32_t freq, uint8_t resolution_bits);
|
// // ledcSetup(uint8_t channel, uint32_t freq, uint8_t resolution_bits);
|
||||||
// ledcSetup(0, 4000, 8); // 12 kHz PWM, 8-bit resolution
|
// ledcSetup(0, 4000, 8); // 12 kHz PWM, 8-bit resolution
|
||||||
pinMode(PIN_REGULATION, OUTPUT);
|
pinMode(PIN_REGULATION, OUTPUT);
|
||||||
#else
|
#else
|
||||||
pinMode(PIN_REGULATION, OUTPUT); // set mtorPin as output
|
pinMode(PIN_REGULATION, OUTPUT); // set mtorPin as output
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifdef SERIAL_BLUE_SOLAR
|
#ifdef SERIAL_BLUE_SOLAR
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
Serial1.begin(19200, SERIAL_8N1, PIN_SOFTWARE_SERIAL_RX, PIN_SOFTWARE_SERIAL_TX); // Rx = 4, Tx = 5 will work for ESP32, S2, S3 and C3
|
Serial1.begin(19200, SERIAL_8N1, PIN_SOFTWARE_SERIAL_RX, PIN_SOFTWARE_SERIAL_TX); // Rx = 4, Tx = 5 will work for ESP32, S2, S3 and C3
|
||||||
#else
|
#else
|
||||||
// Serial port configuration
|
// Serial port configuration
|
||||||
//Baud rate:19200
|
//Baud rate:19200
|
||||||
//Data bits: 8
|
//Data bits: 8
|
||||||
@@ -295,12 +295,12 @@ void setup() {
|
|||||||
//Stop bits: 1
|
//Stop bits: 1
|
||||||
//Flow control: None
|
//Flow control: None
|
||||||
victronSerial.begin(19200); //, SWSERIAL_8N1);
|
victronSerial.begin(19200); //, SWSERIAL_8N1);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
char tmpBuf[30]; // text buffer for serial messages
|
char tmpBuf[30]; // text buffer for serial messages
|
||||||
|
|
||||||
#ifdef SERIAL_XY6020L
|
#ifdef SERIAL_XY6020L
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
xy6020l xy(Serial2, 0x01, 50, XY6020_OPT_SKIP_SAME_HREG_VALUE | XY6020_OPT_NO_HREG_UPDATE);
|
xy6020l xy(Serial2, 0x01, 50, XY6020_OPT_SKIP_SAME_HREG_VALUE | XY6020_OPT_NO_HREG_UPDATE);
|
||||||
|
|
||||||
Serial2.begin(115200, SERIAL_8N1, PIN_SOFTWARE_SERIAL_RX2, PIN_SOFTWARE_SERIAL_TX2); // Rx = 4, Tx = 5 will work for ESP32, S2, S3 and C3
|
Serial2.begin(115200, SERIAL_8N1, PIN_SOFTWARE_SERIAL_RX2, PIN_SOFTWARE_SERIAL_TX2); // Rx = 4, Tx = 5 will work for ESP32, S2, S3 and C3
|
||||||
@@ -314,8 +314,8 @@ void setup() {
|
|||||||
Mem.sOVP = 1300;
|
Mem.sOVP = 1300;
|
||||||
Mem.sOCP = 620;
|
Mem.sOCP = 620;
|
||||||
Mem.sOPP = 1040;
|
Mem.sOPP = 1040;
|
||||||
Mem.sOHPh= 0;
|
Mem.sOHPh = 0;
|
||||||
Mem.sOHPm= 0;
|
Mem.sOHPm = 0;
|
||||||
Mem.sOAH = 0;
|
Mem.sOAH = 0;
|
||||||
Mem.sOWH = 0;
|
Mem.sOWH = 0;
|
||||||
Mem.sOTP = 61;
|
Mem.sOTP = 61;
|
||||||
@@ -331,11 +331,11 @@ void setup() {
|
|||||||
|
|
||||||
sprintf( tmpBuf, "Modele 1 :%04X Version 1 :%04X\n", xy.getModel(), xy.getVersion() );
|
sprintf( tmpBuf, "Modele 1 :%04X Version 1 :%04X\n", xy.getModel(), xy.getVersion() );
|
||||||
Serial.print(tmpBuf);
|
Serial.print(tmpBuf);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SERIAL_XY6020L_2
|
#ifdef SERIAL_XY6020L_2
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
|
|
||||||
// xy6020l xy2(Serial3, 0x01, 50, XY6020_OPT_SKIP_SAME_HREG_VALUE | XY6020_OPT_NO_HREG_UPDATE);
|
// xy6020l xy2(Serial3, 0x01, 50, XY6020_OPT_SKIP_SAME_HREG_VALUE | XY6020_OPT_NO_HREG_UPDATE);
|
||||||
|
|
||||||
@@ -350,8 +350,8 @@ void setup() {
|
|||||||
Mem2.sOVP = 1300;
|
Mem2.sOVP = 1300;
|
||||||
Mem2.sOCP = 619;
|
Mem2.sOCP = 619;
|
||||||
Mem2.sOPP = 1041;
|
Mem2.sOPP = 1041;
|
||||||
Mem2.sOHPh= 0;
|
Mem2.sOHPh = 0;
|
||||||
Mem2.sOHPm= 0;
|
Mem2.sOHPm = 0;
|
||||||
Mem2.sOAH = 0;
|
Mem2.sOAH = 0;
|
||||||
Mem2.sOWH = 0;
|
Mem2.sOWH = 0;
|
||||||
Mem2.sOTP = 60;
|
Mem2.sOTP = 60;
|
||||||
@@ -367,8 +367,8 @@ void setup() {
|
|||||||
|
|
||||||
sprintf( tmpBuf, "Modele 2 :%04X Version 2 :%04X\n", xy.getModel(), xy.getVersion() );
|
sprintf( tmpBuf, "Modele 2 :%04X Version 2 :%04X\n", xy.getModel(), xy.getVersion() );
|
||||||
Serial.print(tmpBuf);
|
Serial.print(tmpBuf);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
delay(10);
|
delay(10);
|
||||||
@@ -411,7 +411,7 @@ void setup() {
|
|||||||
//server.on("/test", HTTP_GET, handleTestConnection);
|
//server.on("/test", HTTP_GET, handleTestConnection);
|
||||||
server.on("/slider", HTTP_POST, handleUpdate);
|
server.on("/slider", HTTP_POST, handleUpdate);
|
||||||
|
|
||||||
#ifdef SERIAL_BLUE_SOLAR
|
#ifdef SERIAL_BLUE_SOLAR
|
||||||
|
|
||||||
// Initialisation de l'EEPROM
|
// Initialisation de l'EEPROM
|
||||||
EEPROM.begin(EEPROM_SIZE); //sizeof(To_Store) + sizeof(config));
|
EEPROM.begin(EEPROM_SIZE); //sizeof(To_Store) + sizeof(config));
|
||||||
@@ -433,7 +433,7 @@ void setup() {
|
|||||||
to_store.total_elements = 0;
|
to_store.total_elements = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
configTime(0, 0, "pool.ntp.org", "time.nist.gov");
|
configTime(0, 0, "pool.ntp.org", "time.nist.gov");
|
||||||
// Synchronize time
|
// Synchronize time
|
||||||
@@ -444,19 +444,19 @@ void setup() {
|
|||||||
lastSyncMillis = millis();
|
lastSyncMillis = millis();
|
||||||
|
|
||||||
// Dimmer
|
// Dimmer
|
||||||
#ifdef PIN_DIMMER_OUTPUT
|
#ifdef PIN_DIMMER_OUTPUT
|
||||||
server.on("/minus", minus);
|
server.on("/minus", minus);
|
||||||
server.on("/plus", plus);
|
server.on("/plus", plus);
|
||||||
server.on("/exact", exact);
|
server.on("/exact", exact);
|
||||||
server.on("/zero", stopPWM);
|
server.on("/zero", stopPWM);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PIN_REGULATION
|
#ifdef PIN_REGULATION
|
||||||
server.on("/minus_reg", minus_reg);
|
server.on("/minus_reg", minus_reg);
|
||||||
server.on("/plus_reg", plus_reg);
|
server.on("/plus_reg", plus_reg);
|
||||||
server.on("/exact_reg", exact_reg);
|
server.on("/exact_reg", exact_reg);
|
||||||
server.on("/zero_reg", stop_reg);
|
server.on("/zero_reg", stop_reg);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//initialize variables__________________
|
//initialize variables__________________
|
||||||
pwm = 0;
|
pwm = 0;
|
||||||
@@ -464,18 +464,18 @@ void setup() {
|
|||||||
// Dimmer
|
// Dimmer
|
||||||
Serial.println("Dimmer Program is starting...");
|
Serial.println("Dimmer Program is starting...");
|
||||||
delay(1000);
|
delay(1000);
|
||||||
#ifdef PIN_DIMMER_OUTPUT
|
#ifdef PIN_DIMMER_OUTPUT
|
||||||
dimmer.begin(NORMAL_MODE, ON); //dimmer initialisation: name.begin(MODE, STATE)
|
dimmer.begin(NORMAL_MODE, ON); //dimmer initialisation: name.begin(MODE, STATE)
|
||||||
Serial.println("Set value");
|
Serial.println("Set value");
|
||||||
dimmer.setState(ON_OFF_typedef::OFF);
|
dimmer.setState(ON_OFF_typedef::OFF);
|
||||||
dimmer.setPower(pwm); // setPower(0-100%);
|
dimmer.setPower(pwm); // setPower(0-100%);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Démarrer le serveur
|
// Démarrer le serveur
|
||||||
server.begin();
|
server.begin();
|
||||||
Serial.println("Serveur Web démarré");
|
Serial.println("Serveur Web démarré");
|
||||||
|
|
||||||
#ifdef PIN_DALLAS
|
#ifdef PIN_DALLAS
|
||||||
|
|
||||||
sensors.begin (); // Initialize the sensor and set resolution level
|
sensors.begin (); // Initialize the sensor and set resolution level
|
||||||
sensors.setResolution(Probe, 10);
|
sensors.setResolution(Probe, 10);
|
||||||
@@ -486,13 +486,13 @@ void setup() {
|
|||||||
Serial.println (sensors.getDeviceCount());
|
Serial.println (sensors.getDeviceCount());
|
||||||
Serial.print ("Getting temperatures... ");
|
Serial.print ("Getting temperatures... ");
|
||||||
Serial.println ();
|
Serial.println ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PZEM
|
#ifdef PZEM
|
||||||
Serial.println("-------PZEM-----------"); // Start Print Test to Line 2
|
Serial.println("-------PZEM-----------"); // Start Print Test to Line 2
|
||||||
pzem.resetEnergy();
|
pzem.resetEnergy();
|
||||||
delay(1000);
|
delay(1000);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
///////////////////////////////////
|
///////////////////////////////////
|
||||||
// UPDATE OTA
|
// UPDATE OTA
|
||||||
@@ -555,17 +555,17 @@ void loop() {
|
|||||||
|
|
||||||
#ifdef SERIAL_XY6020L
|
#ifdef SERIAL_XY6020L
|
||||||
xy.task();
|
xy.task();
|
||||||
// if(xy.HRegUpdated()) {
|
// if(xy.HRegUpdated()) {
|
||||||
// double vIn = xy.getInV();
|
// double vIn = xy.getInV();
|
||||||
// xy.setCV(500);
|
// xy.setCV(500);
|
||||||
// }
|
// }
|
||||||
#endif
|
#endif
|
||||||
#ifdef SERIAL_XY6020L_2
|
#ifdef SERIAL_XY6020L_2
|
||||||
xy2.task();
|
xy2.task();
|
||||||
// if(xy.HRegUpdated()) {
|
// if(xy.HRegUpdated()) {
|
||||||
// double vIn = xy.getInV();
|
// double vIn = xy.getInV();
|
||||||
// xy.setCV(500);
|
// xy.setCV(500);
|
||||||
// }
|
// }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (millis() - lastTimeRead >= analogReadInterval)//read ldr periodically
|
if (millis() - lastTimeRead >= analogReadInterval)//read ldr periodically
|
||||||
@@ -577,8 +577,8 @@ void loop() {
|
|||||||
|
|
||||||
if (millis() - lastUpdateTime >= updateInterval || lastUpdateTime == 0) {
|
if (millis() - lastUpdateTime >= updateInterval || lastUpdateTime == 0) {
|
||||||
|
|
||||||
// digitalWrite(PIN_LED, HIGH);
|
// digitalWrite(PIN_LED, HIGH);
|
||||||
// delay(500);
|
// delay(500);
|
||||||
unsigned long currentMillis = millis();
|
unsigned long currentMillis = millis();
|
||||||
time_t elapsedTime = (currentMillis - lastSyncMillis) / 1000;
|
time_t elapsedTime = (currentMillis - lastSyncMillis) / 1000;
|
||||||
localTime = currentTime + elapsedTime;
|
localTime = currentTime + elapsedTime;
|
||||||
@@ -599,60 +599,60 @@ void loop() {
|
|||||||
|
|
||||||
cleanValues();
|
cleanValues();
|
||||||
#endif
|
#endif
|
||||||
//#ifdef SERIAL_XY6020L
|
//#ifdef SERIAL_XY6020L
|
||||||
// printMem();
|
// printMem();
|
||||||
//#endif
|
//#endif
|
||||||
//#ifdef SERIAL_XY6020L_2
|
//#ifdef SERIAL_XY6020L_2
|
||||||
// printMem();
|
// printMem();
|
||||||
//#endif
|
//#endif
|
||||||
// Mettre à jour le temps de la dernière mise à jour
|
// Mettre à jour le temps de la dernière mise à jour
|
||||||
lastUpdateTime = millis();
|
lastUpdateTime = millis();
|
||||||
#ifdef PIN_TENSION
|
#ifdef PIN_TENSION
|
||||||
getTension();
|
getTension();
|
||||||
#endif
|
#endif
|
||||||
// digitalWrite(PIN_LED, LOW);
|
// digitalWrite(PIN_LED, LOW);
|
||||||
// delay(500);
|
// delay(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ///////////////////////////////////////////////////////////////
|
// ///////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifdef SERIAL_XY6020L
|
#ifdef SERIAL_XY6020L
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// //////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleRoot() {
|
void handleRoot() {
|
||||||
// IPAddress clientIP = server.client().remoteIP();
|
// IPAddress clientIP = server.client().remoteIP();
|
||||||
// Serial.println("Client IP: " + clientIP.toString());
|
// Serial.println("Client IP: " + clientIP.toString());
|
||||||
//
|
//
|
||||||
// if (!isLocalIP(clientIP)) {
|
// if (!isLocalIP(clientIP)) {
|
||||||
// // Vérifie si le mot de passe est correct
|
// // Vérifie si le mot de passe est correct
|
||||||
// if (server.hasArg("password")) {
|
// if (server.hasArg("password")) {
|
||||||
// String passwordParam = server.arg("password");
|
// String passwordParam = server.arg("password");
|
||||||
// if (passwordParam == adminPassword) {
|
// if (passwordParam == adminPassword) {
|
||||||
// server.send(200, "text/html", "<h1>Accès autorisé</h1>");
|
// server.send(200, "text/html", "<h1>Accès autorisé</h1>");
|
||||||
// } else {
|
// } else {
|
||||||
// server.send(401, "text/html", "<h1>Mot de passe incorrect</h1>");
|
// server.send(401, "text/html", "<h1>Mot de passe incorrect</h1>");
|
||||||
// }
|
// }
|
||||||
// } else {
|
// } else {
|
||||||
// server.send(401, "text/html", "<form action='/' method='get'>"
|
// server.send(401, "text/html", "<form action='/' method='get'>"
|
||||||
// "<label for='password'>Mot de passe:</label><br>"
|
// "<label for='password'>Mot de passe:</label><br>"
|
||||||
// "<input type='password' id='password' name='password'><br>"
|
// "<input type='password' id='password' name='password'><br>"
|
||||||
// "<input type='submit' value='Se connecter'>"
|
// "<input type='submit' value='Se connecter'>"
|
||||||
// "</form>");
|
// "</form>");
|
||||||
// }
|
// }
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// bool connectionStatus = testDomoticzConnection();
|
// bool connectionStatus = testDomoticzConnection();
|
||||||
// String connectionIcon = connectionStatus
|
// String connectionIcon = connectionStatus
|
||||||
// ? "<i class='fas fa-check-circle' style='color: green;'></i>"
|
// ? "<i class='fas fa-check-circle' style='color: green;'></i>"
|
||||||
// : "<i class='fas fa-times-circle' style='color: red;'></i>";
|
// : "<i class='fas fa-times-circle' style='color: red;'></i>";
|
||||||
|
|
||||||
#ifdef PIN_HALL
|
#ifdef PIN_HALL
|
||||||
getHall();
|
getHall();
|
||||||
@@ -780,14 +780,14 @@ void handleRoot() {
|
|||||||
|
|
||||||
#ifdef TUYA
|
#ifdef TUYA
|
||||||
|
|
||||||
to_add.replace("@@VALUE@@", String(String(conso_apparente).toFloat(),1) + " W");
|
to_add.replace("@@VALUE@@", String(String(conso_apparente).toFloat(), 1) + " W");
|
||||||
to_add.replace("@@LABEL@@", "Conso apparente");
|
to_add.replace("@@LABEL@@", "Conso apparente");
|
||||||
to_add.replace("@@KEY@@", "IND_CONSO");
|
to_add.replace("@@KEY@@", "IND_CONSO");
|
||||||
|
|
||||||
indicators += to_add;
|
indicators += to_add;
|
||||||
to_add = indicator;
|
to_add = indicator;
|
||||||
|
|
||||||
to_add.replace("@@VALUE@@", String(String(production).toFloat(),1) + " W");
|
to_add.replace("@@VALUE@@", String(String(production).toFloat(), 1) + " W");
|
||||||
to_add.replace("@@LABEL@@", "Production");
|
to_add.replace("@@LABEL@@", "Production");
|
||||||
to_add.replace("@@KEY@@", "IND_PROD");
|
to_add.replace("@@KEY@@", "IND_PROD");
|
||||||
|
|
||||||
@@ -955,9 +955,9 @@ void handleStop() {
|
|||||||
|
|
||||||
setCC(xy, 0);
|
setCC(xy, 0);
|
||||||
|
|
||||||
#ifdef SERIAL_XY6020L_2
|
#ifdef SERIAL_XY6020L_2
|
||||||
setCC2(xy2, 0);
|
setCC2(xy2, 0);
|
||||||
#endif
|
#endif
|
||||||
delay(200);
|
delay(200);
|
||||||
digitalWrite(PIN_CHARGE, LOW);
|
digitalWrite(PIN_CHARGE, LOW);
|
||||||
delay(200);
|
delay(200);
|
||||||
@@ -1001,18 +1001,18 @@ void handleStart() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void injection() {
|
void injection() {
|
||||||
#ifdef PIN_DIMMER_OUTPUT
|
#ifdef PIN_DIMMER_OUTPUT
|
||||||
dimmer.setState(ON_OFF_typedef::OFF);
|
dimmer.setState(ON_OFF_typedef::OFF);
|
||||||
#endif
|
#endif
|
||||||
#ifdef PIN_POWER
|
#ifdef PIN_POWER
|
||||||
digitalWrite(PIN_POWER, HIGH);
|
digitalWrite(PIN_POWER, HIGH);
|
||||||
delay(200);
|
delay(200);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PIN_BATTERIE
|
#ifdef PIN_BATTERIE
|
||||||
digitalWrite(PIN_BATTERIE, HIGH);
|
digitalWrite(PIN_BATTERIE, HIGH);
|
||||||
delay(200);
|
delay(200);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
digitalWrite(PIN_CHARGE, LOW);
|
digitalWrite(PIN_CHARGE, LOW);
|
||||||
delay(200);
|
delay(200);
|
||||||
@@ -1021,14 +1021,14 @@ void injection() {
|
|||||||
digitalWrite(PIN_INJECTION, HIGH);
|
digitalWrite(PIN_INJECTION, HIGH);
|
||||||
delay(200);
|
delay(200);
|
||||||
|
|
||||||
#ifdef PIN_BATTERIE
|
#ifdef PIN_BATTERIE
|
||||||
digitalWrite(PIN_BATTERIE, HIGH);
|
digitalWrite(PIN_BATTERIE, HIGH);
|
||||||
delay(200);
|
delay(200);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PIN_REGULATION
|
#ifdef PIN_REGULATION
|
||||||
setReg(0);
|
setReg(0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
void handleInjection() {
|
void handleInjection() {
|
||||||
|
|
||||||
@@ -1040,7 +1040,7 @@ void handleInjection() {
|
|||||||
|
|
||||||
void stopInjection()
|
void stopInjection()
|
||||||
{
|
{
|
||||||
#ifdef PIN_BATTERIE
|
#ifdef PIN_BATTERIE
|
||||||
digitalWrite(PIN_BATTERIE, LOW);
|
digitalWrite(PIN_BATTERIE, LOW);
|
||||||
delay(200);
|
delay(200);
|
||||||
#endif
|
#endif
|
||||||
@@ -1060,7 +1060,7 @@ void handleStopInjection() {
|
|||||||
|
|
||||||
void charge()
|
void charge()
|
||||||
{
|
{
|
||||||
#ifdef PIN_DIMMER_OUTPUT
|
#ifdef PIN_DIMMER_OUTPUT
|
||||||
dimmer.setState(ON_OFF_typedef::ON);
|
dimmer.setState(ON_OFF_typedef::ON);
|
||||||
#endif
|
#endif
|
||||||
Serial.println("charge");
|
Serial.println("charge");
|
||||||
@@ -1102,9 +1102,9 @@ void stopCharge()
|
|||||||
#ifdef PIN_REGULATION
|
#ifdef PIN_REGULATION
|
||||||
setReg(0);
|
setReg(0);
|
||||||
#endif
|
#endif
|
||||||
#ifdef SERIAL_XY6020L
|
#ifdef SERIAL_XY6020L
|
||||||
setCC(xy, 0);
|
setCC(xy, 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleStopCharge() {
|
void handleStopCharge() {
|
||||||
|
|||||||
@@ -140,8 +140,6 @@ String to_include = R"=(
|
|||||||
table.deleteRow(-1); // Supprime la dernière ligne
|
table.deleteRow(-1); // Supprime la dernière ligne
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (field_chart && !chart) {
|
if (field_chart && !chart) {
|
||||||
var ctx = field_chart.getContext('2d');
|
var ctx = field_chart.getContext('2d');
|
||||||
chart = new Chart(ctx, {
|
chart = new Chart(ctx, {
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ ESP8266WebServer server(80);
|
|||||||
|
|
||||||
void ICACHE_RAM_ATTR handleInterrupt();
|
void ICACHE_RAM_ATTR handleInterrupt();
|
||||||
|
|
||||||
|
#define HOSTNAME "ESP8266_RADIATEUR"
|
||||||
|
|
||||||
// Dimmer
|
// Dimmer
|
||||||
#include <RBDdimmer.h>//
|
#include <RBDdimmer.h>//
|
||||||
|
|
||||||
@@ -30,11 +32,13 @@ void ICACHE_RAM_ATTR handleInterrupt();
|
|||||||
#define zerocross 12 // D6 for boards with CHANGEBLE input pins
|
#define zerocross 12 // D6 for boards with CHANGEBLE input pins
|
||||||
#define pas 5
|
#define pas 5
|
||||||
|
|
||||||
|
bool led;
|
||||||
|
int pwm;
|
||||||
|
int pwmCount;
|
||||||
|
|
||||||
dimmerLamp dimmer(outputPin, zerocross); //initialase port for dimmer for ESP8266, ESP32, Arduino due boards
|
dimmerLamp dimmer(outputPin, zerocross); //initialase port for dimmer for ESP8266, ESP32, Arduino due boards
|
||||||
//dimmerLamp dimmer(outputPin); //initialase port for dimmer for MEGA, Leonardo, UNO, Arduino M0, Arduino Zero
|
//dimmerLamp dimmer(outputPin); //initialase port for dimmer for MEGA, Leonardo, UNO, Arduino M0, Arduino Zero
|
||||||
|
|
||||||
int outVal = 0;
|
|
||||||
|
|
||||||
String webpage = R"=(
|
String webpage = R"=(
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
@@ -42,22 +46,61 @@ String webpage = R"=(
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>LED Control</title>
|
<title>LED Control</title>
|
||||||
|
<link type='text/css' rel='stylesheet' href='http://192.168.1.3:81/velux/style.css'>
|
||||||
|
<script>
|
||||||
|
var xmlHttp01=createXmlHttpObject();
|
||||||
|
var previous_value = 10;
|
||||||
|
function createXmlHttpObject(){
|
||||||
|
if(window.XMLHttpRequest){
|
||||||
|
xmlHttp=new XMLHttpRequest();
|
||||||
|
}else{
|
||||||
|
xmlHttp=new ActiveXObject('Microsoft.XMLHTTP');
|
||||||
|
}
|
||||||
|
return xmlHttp;
|
||||||
|
}
|
||||||
|
function process(){
|
||||||
|
if(xmlHttp01.readyState==0 || xmlHttp01.readyState==4){
|
||||||
|
xmlHttp01.open('GET','getData',true);
|
||||||
|
xmlHttp01.onreadystatechange=handleServerResponse;
|
||||||
|
xmlHttp01.send(null);
|
||||||
|
}
|
||||||
|
setTimeout('process()', 30000);
|
||||||
|
}
|
||||||
|
function handleServerResponse(){
|
||||||
|
var field = document.getElementById('current_value');
|
||||||
|
if(field && xmlHttp01.readyState == 4 && xmlHttp01.status == 200){
|
||||||
|
const json_obj = JSON.parse(xmlHttp01.response);
|
||||||
|
// console.log(xmlHttp01.response);
|
||||||
|
const values = Object.values(json_obj);
|
||||||
|
var value = values[1]
|
||||||
|
if (value != previous_value) {
|
||||||
|
let button = document.querySelector('.arcade-button');
|
||||||
|
button.classList.add('gradient'); // Ajoute l'effet
|
||||||
|
setTimeout(() => button.classList.remove('gradient'), 3000);
|
||||||
|
previous_value = value;
|
||||||
|
}
|
||||||
|
field.textContent = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
|
align-content: center;
|
||||||
|
background-color: #3498db;
|
||||||
|
color: white;
|
||||||
|
display: flex;
|
||||||
font-family: 'Arial', sans-serif;
|
font-family: 'Arial', sans-serif;
|
||||||
background-color: #f2f2f2;
|
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
justify-content: space-around;
|
justify-content: space-around;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
height: 100vh;
|
width: 300px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.control-container {
|
.control-container {
|
||||||
background: #C0C0C0;
|
background: #66cc66;
|
||||||
width: 128px;
|
width: 256px;
|
||||||
height: 64px;
|
height: 64px;
|
||||||
margin: 10px;
|
margin: 10px;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -90,7 +133,7 @@ String webpage = R"=(
|
|||||||
position: relative;
|
position: relative;
|
||||||
width: 150px;
|
width: 150px;
|
||||||
height: 150px;
|
height: 150px;
|
||||||
background-color: #3498db;
|
background-color: #005599;
|
||||||
border: 10px solid #2c3e50;
|
border: 10px solid #2c3e50;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
@@ -102,6 +145,29 @@ String webpage = R"=(
|
|||||||
background-color: #2980b9;
|
background-color: #2980b9;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
width: 100%;
|
||||||
|
align-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
header {
|
||||||
|
background-color: #003366;
|
||||||
|
padding: 1rem;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.header_info {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
.header_info h2 {
|
||||||
|
margin: 0 10px;
|
||||||
|
}
|
||||||
|
h1, h2 {
|
||||||
|
color: white;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.button-content {
|
.button-content {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
@@ -111,9 +177,40 @@ String webpage = R"=(
|
|||||||
font-size: 1.5rem;
|
font-size: 1.5rem;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Effet Flash */
|
||||||
|
.arcade-button.flash {
|
||||||
|
animation: flash 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes flash {
|
||||||
|
0% { background-color: #005599; }
|
||||||
|
50% { background-color: red; }
|
||||||
|
100% { background-color: #005599; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Animation fluide entre rouge et orange */
|
||||||
|
@keyframes smoothGradient {
|
||||||
|
0% { background-color: #005599; }
|
||||||
|
50% { background-color: orange; }
|
||||||
|
100% { background-color: #005599; }
|
||||||
|
}
|
||||||
|
|
||||||
|
.arcade-button.gradient {
|
||||||
|
animation: smoothGradient 3s ease-in-out; /* Durée ajustable */
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body onload='process()'>
|
||||||
|
<div class="container">
|
||||||
|
<header>
|
||||||
|
<h1>Surplux solaire</h1>
|
||||||
|
<div class="header_info">
|
||||||
|
<h2>@@IP@@</h2>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</header>
|
||||||
<div class="control-container" id="LEDn">
|
<div class="control-container" id="LEDn">
|
||||||
<button onclick="alert('on');">ON</button>
|
<button onclick="alert('on');">ON</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -124,7 +221,6 @@ String webpage = R"=(
|
|||||||
|
|
||||||
<div class="control-container" id="pwmminus">
|
<div class="control-container" id="pwmminus">
|
||||||
<a href="/minus?value=10">Minus</a>
|
<a href="/minus?value=10">Minus</a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="control-container" id="pwmstop">
|
<div class="control-container" id="pwmstop">
|
||||||
@@ -132,28 +228,27 @@ String webpage = R"=(
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="arcade-button">
|
<div class="arcade-button">
|
||||||
<div class="button-content">@@pwmCount@@</div>
|
<div class="button-content" id='current_value'>@@pwmCount@@</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
)=";
|
)=";
|
||||||
|
|
||||||
bool led;
|
|
||||||
int pwm;
|
|
||||||
int pwmCount;
|
void ledON(){
|
||||||
//
|
led=1;
|
||||||
//void ledON(){
|
digitalWrite(LEDn, led);
|
||||||
// led=1;
|
handleRoot();
|
||||||
// digitalWrite(LEDn, led);
|
|
||||||
// handleRoot();
|
}
|
||||||
//
|
|
||||||
//}
|
void ledOFF(){
|
||||||
//
|
led=0;
|
||||||
//void ledOFF(){
|
digitalWrite(LEDn, led);
|
||||||
// led=0;
|
handleRoot();
|
||||||
// digitalWrite(LEDn, led);
|
}
|
||||||
// handleRoot();
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
//pwm functions - if pwm is set to 1/-1 it will in-/decrease pwmCounter in loop()
|
//pwm functions - if pwm is set to 1/-1 it will in-/decrease pwmCounter in loop()
|
||||||
@@ -222,6 +317,7 @@ void setPwm(int pwm)
|
|||||||
void handleRoot(void){
|
void handleRoot(void){
|
||||||
String page = webpage;
|
String page = webpage;
|
||||||
page.replace("@@pwmCount@@", String(pwmCount));
|
page.replace("@@pwmCount@@", String(pwmCount));
|
||||||
|
page.replace("@@IP@@", String(WiFi.localIP().toString()));
|
||||||
//Serial.println(page);
|
//Serial.println(page);
|
||||||
server.send(200, "text/html", page);
|
server.send(200, "text/html", page);
|
||||||
}
|
}
|
||||||
@@ -319,18 +415,27 @@ String generateKey()
|
|||||||
|
|
||||||
IPAddress getIP(String macId)
|
IPAddress getIP(String macId)
|
||||||
{
|
{
|
||||||
IPAddress ip; //(192, 168, 1, 222);
|
// IPAddress ip (192, 168, 1, 222);
|
||||||
|
//
|
||||||
|
// String fst = macId.substring(0, 2);
|
||||||
|
// String sec = macId.substring(2);
|
||||||
|
//
|
||||||
|
// char fstc[fst.length() + 1];
|
||||||
|
// fst.toCharArray(fstc, fst.length() + 1);
|
||||||
|
//
|
||||||
|
// char secc[sec.length() + 1];
|
||||||
|
// sec.toCharArray(secc, fst.length() + 1);
|
||||||
|
|
||||||
String fst = macId.substring(0, 2);
|
return IPAddress (192, 168, 1, 222); //IPAddress(192, 168, strtol(fstc, 0, 16), strtol(secc, 0, 16));
|
||||||
String sec = macId.substring(2);
|
|
||||||
|
|
||||||
char fstc[fst.length() + 1];
|
}
|
||||||
fst.toCharArray(fstc, fst.length() + 1);
|
|
||||||
|
|
||||||
char secc[sec.length() + 1];
|
void handleData()
|
||||||
sec.toCharArray(secc, fst.length() + 1);
|
{
|
||||||
|
String JSON = F("");
|
||||||
return IPAddress(192, 168, strtol(fstc, 0, 16), strtol(secc, 0, 16));
|
JSON += "{\"id\":\"current\", \"value\":" + String(pwmCount) + "}";
|
||||||
|
JSON += "";
|
||||||
|
server.send(200, "application/json", JSON);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,6 +460,7 @@ void setup()
|
|||||||
server.on("/plus", plus);
|
server.on("/plus", plus);
|
||||||
server.on("/exact", exact);
|
server.on("/exact", exact);
|
||||||
server.on("/stop", stopPWM);
|
server.on("/stop", stopPWM);
|
||||||
|
server.on("/getData", handleData);
|
||||||
//initialize variables__________________
|
//initialize variables__________________
|
||||||
pwm = 0;
|
pwm = 0;
|
||||||
pwmCount= 0;
|
pwmCount= 0;
|
||||||
@@ -378,7 +484,7 @@ void setup()
|
|||||||
ArduinoOTA.setPort(8266);
|
ArduinoOTA.setPort(8266);
|
||||||
|
|
||||||
// Hostname defaults to esp8266-[ChipID]
|
// Hostname defaults to esp8266-[ChipID]
|
||||||
// ArduinoOTA.setHostname("myesp8266");
|
ArduinoOTA.setHostname(HOSTNAME);
|
||||||
|
|
||||||
// No authentication by default
|
// No authentication by default
|
||||||
// ArduinoOTA.setPassword("admin");
|
// ArduinoOTA.setPassword("admin");
|
||||||
|
|||||||
Reference in New Issue
Block a user