Kompilacja dla ESP32

krycha88
Posty: 5187
Rejestracja: pt lis 16, 2018 7:25 am
Kontakt:

https://gui-generic-builder.supla.io/
Awatar użytkownika
klew
Posty: 8184
Rejestracja: czw cze 27, 2019 12:16 pm
Lokalizacja: 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.
Widzimy się na Supla Offline Party vol. 2 :!:
Awatar użytkownika
pzygmunt
Posty: 18284
Rejestracja: wt sty 19, 2016 9:26 am
Lokalizacja: Paczków
Kontakt:

W Paczkowie leży mi jakiś nieużywany PZEM. Mogę Ci go udostępnić.
krycha88
Posty: 5187
Rejestracja: pt lis 16, 2018 7:25 am
Kontakt:

klew pisze: sob sie 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.
A którą doinstalowałeś?

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

Kod: Zaznacz cały

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/
krycha88
Posty: 5187
Rejestracja: pt lis 16, 2018 7:25 am
Kontakt:

wg
https://github.com/mandulaj/PZEM-004T-v ... are-serial

Poprawiłbym to tak:

Kod: Zaznacz cały

/*
 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/
Awatar użytkownika
klew
Posty: 8184
Rejestracja: czw cze 27, 2019 12:16 pm
Lokalizacja: Wrocław

Tam jeszcze mega powinno działać.
U siebie sprawdzałem tylko kompilację tego pzem V2. Poprawie wieczorem też ten drugi wariant
Widzimy się na Supla Offline Party vol. 2 :!:
krycha88
Posty: 5187
Rejestracja: pt lis 16, 2018 7:25 am
Kontakt:

klew pisze: ndz sie 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
Akurat w GUI-Generic nie ma wsparcia dla pzem v2.

Zamieniłem ARDUINO_ARCH_ESP32 na PZEM004_SOFTSERIAL. A three_phase_PzemV3.h poprawiłem w taki sposób:

Kod: Zaznacz cały

#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/
Awatar użytkownika
klew
Posty: 8184
Rejestracja: czw cze 27, 2019 12:16 pm
Lokalizacja: Wrocław

Wrzuciłem poprawki (jest PR do brancha develop).
Zrobiłem ifdefy analogicznie jak to jest w bibliotece PZEMv3 zrobione.
Widzimy się na Supla Offline Party vol. 2 :!:
ODPOWIEDZ

Wróć do „Arduino IDE”