From 68d43dd5837b507bb86eecc57075c2d906b856a2 Mon Sep 17 00:00:00 2001 From: ZMiguel Date: Wed, 19 Aug 2020 18:10:35 +0100 Subject: [PATCH] update modules --- .gitmodules | 3 +++ ESP32-SolarPowerMonitor.ino | 26 ++++++++++++++++++-------- scr/PZEM-004T-v30 | 1 + src/EmonLib | 1 - 4 files changed, 22 insertions(+), 9 deletions(-) create mode 160000 scr/PZEM-004T-v30 delete mode 160000 src/EmonLib diff --git a/.gitmodules b/.gitmodules index 7371102..7970037 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "src/InfluxDB-Client-for-Arduino"] path = src/InfluxDB-Client-for-Arduino url = https://github.com/tobiasschuerg/InfluxDB-Client-for-Arduino.git +[submodule "scr/PZEM-004T-v30"] + path = scr/PZEM-004T-v30 + url = https://github.com/mandulaj/PZEM-004T-v30.git diff --git a/ESP32-SolarPowerMonitor.ino b/ESP32-SolarPowerMonitor.ino index 74f2e59..26f77a6 100644 --- a/ESP32-SolarPowerMonitor.ino +++ b/ESP32-SolarPowerMonitor.ino @@ -15,11 +15,11 @@ InfluxDBClient client(INFLUXDB_URL, INFLUXDB_DB_NAME); // Data point Point sensor("solar_status"); -void ConnectToWiFiMulti(){ +void ConnectToWiFiMulti() { WiFi.mode(WIFI_STA); WiFiMulti.addAP(SSID, WiFiPassword); Serial.println("Connecting Wifi..."); - while(WiFiMulti.run() != WL_CONNECTED) { + while (WiFiMulti.run() != WL_CONNECTED) { delay(100); } Serial.println(""); @@ -28,7 +28,7 @@ void ConnectToWiFiMulti(){ Serial.println(WiFi.localIP()); } -void ConnectToInflux(){ +void ConnectToInflux() { // Add constant tags - only once sensor.addTag("Phase", "Solar 1"); @@ -46,14 +46,24 @@ void setup() { Serial.begin(115200); ConnectToWiFiMulti(); ConnectToInflux(); - analogReadResolution(ADC_BITS); - emon1.voltage(Vpin, 234.26, 1.7); // Voltage: input pin, calibration, phase_shift - emon1.current(Apin, 111.1); // Current: input pin, calibration. + analogReadResolution(12); + pinMode(Apin, INPUT); + Serial.println(ADC_COUNTS); + emon1.voltage(Vpin, 406, 1.7); // Voltage: input pin, calibration, phase_shift + emon1.current(Apin, 66); // Current: input pin, calibration. } void loop() { - emon1.calcVI(20,2000); // Calculate all. No.of half wavelengths (crossings), time-out - emon1.serialprint(); // Print out all variables (realpower, apparent power, Vrms, Irms, power factor) + Serial.println(analogRead(Vpin)); + emon1.calcVI(20, 2000); // Calculate all. No.of half wavelengths (crossings), time-out + Serial.print(emon1.Vrms); + Serial.print(" Volts | "); + Serial.print(emon1.Irms); + Serial.print(" Amps | "); + Serial.print(emon1.Vrms*emon1.Irms); + Serial.println(" Watts"); + Serial.println(emon1.calcIrms(1480)); + //emon1.serialprint(); // Print out all variables (realpower, apparent power, Vrms, Irms, power factor) delay(5000); //influx to be implemented... diff --git a/scr/PZEM-004T-v30 b/scr/PZEM-004T-v30 new file mode 160000 index 0000000..d459097 --- /dev/null +++ b/scr/PZEM-004T-v30 @@ -0,0 +1 @@ +Subproject commit d4590976d412fafa91df66f1592314aae790b642 diff --git a/src/EmonLib b/src/EmonLib deleted file mode 160000 index 02d21ad..0000000 --- a/src/EmonLib +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 02d21ad457d4bc42b386c9952e21e552d7847e41