Proszę o poprawki dla ESP32 nie można korzystać z #include <SoftwareSerial.h>
https://github.com/klew/supla-arduino/b ... r/PzemV2.h
https://github.com/klew/supla-arduino/b ... r/PzemV3.h
https://github.com/klew/supla-arduino/b ... e_PzemV3.h
Kompilacja dla ESP32
-
- Posts: 10022
- Joined: Thu Jun 27, 2019 12:16 pm
- Location: Wrocław
Niestety nie mam PZEMów u siebie, a nie chciałbym tego w ciemno zmieniać.
U mnie doinstalowanie biblioteki EspSoftwareSerial pomogło w kompilacji.
U mnie doinstalowanie biblioteki EspSoftwareSerial pomogło w kompilacji.
-
- Posts: 19340
- Joined: Tue Jan 19, 2016 9:26 am
- Location: Paczków
W Paczkowie leży mi jakiś nieużywany PZEM. Mogę Ci go udostępnić.
-
- Posts: 5417
- Joined: Fri Nov 16, 2018 7:25 am
A którą doinstalowałeś?klew wrote: Sat Aug 28, 2021 10:22 pm Niestety nie mam PZEMów u siebie, a nie chciałbym tego w ciemno zmieniać.
U mnie doinstalowanie biblioteki EspSoftwareSerial pomogło w kompilacji.
Ja doinstalowałem:
https://platformio.org/lib/show/168/Esp ... stallation
ale niestety nadal znajduję tą oryginalną bibliotekę wbudowaną w SDK..
Z tego co się wyczytałem na ESP32 powinno się stosować HardwareSerial.h
Code: Select all
In file included from C:/Users/kryst/Documents/PlatformIO/Projects/GUI-Generic/src/GUI-Generic.ino:19:0:
lib/SuplaDevice/src/supla/sensor/PzemV3.h: In constructor 'Supla::Sensor::PZEMv3::PZEMv3(int8_t, int8_t)':
lib/SuplaDevice/src/supla/sensor/PzemV3.h:33:57: error: invalid conversion from 'int8_t {aka signed char}' to 'HardwareSerial*' [-fpermissive]
PZEMv3(int8_t pinRX, int8_t pinTX) : pzem(pinRX, pinTX) {
^
In file included from lib/SuplaDevice/src/supla/sensor/PzemV3.h:23:0,
from C:/Users/kryst/Documents/PlatformIO/Projects/GUI-Generic/src/GUI-Generic.ino:19:
lib/PZEM-004T-v30/PZEM004Tv30.h:65:5: note: initializing argument 1 of 'PZEM004Tv30::PZEM004Tv30(HardwareSerial*, uint8_t)'
PZEM004Tv30(HardwareSerial* port, uint8_t addr=PZEM_DEFAULT_ADDR);
^
In file included from C:/Users/kryst/Documents/PlatformIO/Projects/GUI-Generic/src/GUI-Generic.ino:20:0:
lib/SuplaDevice/src/supla/sensor/three_phase_PzemV3.h: In constructor 'Supla::Sensor::ThreePhasePZEMv3::ThreePhasePZEMv3(int8_t, int8_t, int8_t, int8_t, int8_t, int8_t)':
lib/SuplaDevice/src/supla/sensor/three_phase_PzemV3.h:39:40: error: invalid conversion from 'int8_t {aka signed char}' to 'HardwareSerial*' [-fpermissive]
: pzem{PZEM004Tv30(pinRX1, pinTX1),
^
In file included from lib/SuplaDevice/src/supla/sensor/PzemV3.h:23:0,
from C:/Users/kryst/Documents/PlatformIO/Projects/GUI-Generic/src/GUI-Generic.ino:19:
lib/PZEM-004T-v30/PZEM004Tv30.h:65:5: note: initializing argument 1 of 'PZEM004Tv30::PZEM004Tv30(HardwareSerial*, uint8_t)'
PZEM004Tv30(HardwareSerial* port, uint8_t addr=PZEM_DEFAULT_ADDR);
^
In file included from C:/Users/kryst/Documents/PlatformIO/Projects/GUI-Generic/src/GUI-Generic.ino:20:0:
lib/SuplaDevice/src/supla/sensor/three_phase_PzemV3.h:40:40: error: invalid conversion from 'int8_t {aka signed char}' to 'HardwareSerial*' [-fpermissive]
PZEM004Tv30(pinRX2, pinTX2),
^
In file included from lib/SuplaDevice/src/supla/sensor/PzemV3.h:23:0,
from C:/Users/kryst/Documents/PlatformIO/Projects/GUI-Generic/src/GUI-Generic.ino:19:
lib/PZEM-004T-v30/PZEM004Tv30.h:65:5: note: initializing argument 1 of 'PZEM004Tv30::PZEM004Tv30(HardwareSerial*, uint8_t)'
PZEM004Tv30(HardwareSerial* port, uint8_t addr=PZEM_DEFAULT_ADDR);
^
In file included from C:/Users/kryst/Documents/PlatformIO/Projects/GUI-Generic/src/GUI-Generic.ino:20:0:
lib/SuplaDevice/src/supla/sensor/three_phase_PzemV3.h:41:40: error: invalid conversion from 'int8_t {aka signed char}' to 'HardwareSerial*' [-fpermissive]
PZEM004Tv30(pinRX3, pinTX3)} {
^
In file included from lib/SuplaDevice/src/supla/sensor/PzemV3.h:23:0,
from C:/Users/kryst/Documents/PlatformIO/Projects/GUI-Generic/src/GUI-Generic.ino:19:
lib/PZEM-004T-v30/PZEM004Tv30.h:65:5: note: initializing argument 1 of 'PZEM004Tv30::PZEM004Tv30(HardwareSerial*, uint8_t)'
PZEM004Tv30(HardwareSerial* port, uint8_t addr=PZEM_DEFAULT_ADDR);
^
*** [.pio\build\GUI_Generic_ESP32\src\GUI-Generic.ino.cpp.o] Error 1
https://gui-generic-builder.supla.io/
-
- Posts: 5417
- Joined: Fri Nov 16, 2018 7:25 am
wg
https://github.com/mandulaj/PZEM-004T-v ... are-serial
Poprawiłbym to tak:
https://github.com/mandulaj/PZEM-004T-v ... are-serial
Poprawiłbym to tak:
Code: Select all
/*
Copyright (C) AC SOFTWARE SP. Z O.O.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _PzemV3_h
#define _PzemV3_h
#include <Arduino.h>
// dependence: Arduino library for the Updated PZEM-004T v3.0 Power and Energy
// meter https://github.com/mandulaj/PZEM-004T-v30
#include <PZEM004Tv30.h>
#ifdef ARDUINO_ARCH_8266
#include <SoftwareSerial.h>
#endif
#include "one_phase_electricity_meter.h"
namespace Supla {
namespace Sensor {
class PZEMv3 : public OnePhaseElectricityMeter {
public:
#ifdef ARDUINO_ARCH_ESP32
PZEMv3(int8_t pinRX, int8_t pinTX) : pzem(Serial2, pinRX, pinTX) {
}
#else
PZEMv3(int8_t pinRX, int8_t pinTX) : pzem(pinRX, pinTX) {
}
PZEMv3(HardwareSerial *serial) : pzem(serial) {
}
#endif
void onInit() {
readValuesFromDevice();
updateChannelValues();
}
virtual void readValuesFromDevice() {
float current = pzem.current();
// If current reading is NAN, we assume that PZEM there is no valid
// communication with PZEM. Sensor shouldn't show any data
if (isnan(current)) {
resetReadParameters();
return;
}
float voltage = pzem.voltage();
float active = pzem.power();
float apparent = (voltage * current);
float reactive = 0;
if (apparent > active) {
reactive = sqrt(apparent * apparent - active * active);
} else {
reactive = 0;
}
setVoltage(0, voltage * 100);
setCurrent(0, current * 1000);
setPowerActive(0, active * 100000);
setFwdActEnergy(0, pzem.energy() * 100000);
setFreq(pzem.frequency() * 100);
setPowerFactor(0, pzem.pf() * 1000);
setPowerApparent(0, apparent * 100000);
setPowerReactive(0, reactive * 10000);
}
void resetStorage() {
pzem.resetEnergy();
}
protected:
PZEM004Tv30 pzem;
};
}; // namespace Sensor
}; // namespace Supla
#endif
https://gui-generic-builder.supla.io/
-
- Posts: 10022
- Joined: Thu Jun 27, 2019 12:16 pm
- Location: Wrocław
Tam jeszcze mega powinno działać.
U siebie sprawdzałem tylko kompilację tego pzem V2. Poprawie wieczorem też ten drugi wariant
U siebie sprawdzałem tylko kompilację tego pzem V2. Poprawie wieczorem też ten drugi wariant
-
- Posts: 5417
- Joined: Fri Nov 16, 2018 7:25 am
Akurat w GUI-Generic nie ma wsparcia dla pzem v2.klew wrote: Sun Aug 29, 2021 8:49 am Tam jeszcze mega powinno działać.
U siebie sprawdzałem tylko kompilację tego pzem V2. Poprawie wieczorem też ten drugi wariant
Zamieniłem ARDUINO_ARCH_ESP32 na PZEM004_SOFTSERIAL. A three_phase_PzemV3.h poprawiłem w taki sposób:
Code: Select all
#ifdef ARDUINO_ARCH_ESP32
ThreePhasePZEMv3(int8_t pinRX1,
int8_t pinTX1,
int8_t pinRX2,
int8_t pinTX2,
int8_t pinRX3,
int8_t pinTX3)
: pzem{PZEM004Tv30(Serial2, pinRX1, pinTX1),
PZEM004Tv30(Serial2, pinRX2, pinTX2),
PZEM004Tv30(Serial2, pinRX3, pinTX3)} {
}
#else
ThreePhasePZEMv3(int8_t pinRX1,
int8_t pinTX1,
int8_t pinRX2,
int8_t pinTX2,
int8_t pinRX3,
int8_t pinTX3)
: pzem{PZEM004Tv30(pinRX1, pinTX1),
PZEM004Tv30(pinRX2, pinTX2),
PZEM004Tv30(pinRX3, pinTX3)} {
}
ThreePhasePZEMv3(HardwareSerial *serial1,
HardwareSerial *serial2,
HardwareSerial *serial3)
: pzem{PZEM004Tv30(serial1), PZEM004Tv30(serial2), PZEM004Tv30(serial3)} {
}
#endif
https://gui-generic-builder.supla.io/
-
- Posts: 10022
- Joined: Thu Jun 27, 2019 12:16 pm
- Location: Wrocław
Wrzuciłem poprawki (jest PR do brancha develop).
Zrobiłem ifdefy analogicznie jak to jest w bibliotece PZEMv3 zrobione.
Zrobiłem ifdefy analogicznie jak to jest w bibliotece PZEMv3 zrobione.