Giter Site home page Giter Site logo

vortigont / pzem-edl Goto Github PK

View Code? Open in Web Editor NEW
18.0 5.0 3.0 1.04 MB

An event-driven library for ESP32 implementing PZEM-004T v3.0 / PZEM-003 / PZEM-017 Modbus-RTU proto

License: GNU General Public License v3.0

C++ 99.21% CMake 0.79%
pzem-004t pzem004t pzem004t30 pzem pzem-004tv30 peacefair energymonitoring powermeter pzem-017 pzem-003

pzem-edl's Issues

Multiple PZEM example - Single Variable Compile Error

Hi @vortigont, thanks for the nice Lib!

Im not a specialist in Programming, so I need to aks some silly questions.

I Use 3x PZEM and they work great with your example code.

pz004::rx_msg_prettyp(m); Gives me the Whole list of Values of the Boards wich is great!

What I need to do is only get Voltages / Currents / Power etc. and write them in custom variables.

I tried this from the main.cpp to get the current from one Sensor:

void mycallback(uint8_t id, const RX_msg* m){

auto *m = (const pz004::metrics*)meters->getMetrics(PZEM_ID_2)
Serial.printf("PZEM '%s' current as float: %.3f (Amps)\n", meters->getDescr(PZEM_ID_2), m->asFloat(meter_t::cur));

But it wont compile and gives me errors.

I also dont need floats, so raw Integer values would be enough for me.

how do I access the single values within the callback (Raw values & Floats)?

Thanks in advance!

esp32/spiram.h is missing

@vortigont , after updating to new version of this library, I get an error while compiling "In file included from espem/espem.h:12:0,
from espem/interface.cpp:1:
.pio/libdeps/espem/pzem-edl/src/timeseries.hpp:32:26: fatal error: esp32/spiram.h: No such file or directory
compilation terminated.
In file included from espem/espem.h:12:0,
from espem/espem.cpp:9:
.pio/libdeps/espem/pzem-edl/src/timeseries.hpp:32:26: fatal error: esp32/spiram.h: No such file or directory
compilation terminated.
*** [.pio\build\espem\src\interface.cpp.o] Error 1
*** [.pio\build\espem\src\espem.cpp.o] Error 1
In file included from espem/espem.h:12:0,
from espem/main.cpp:11:
.pio/libdeps/espem/pzem-edl/src/timeseries.hpp:32:26: fatal error: esp32/spiram.h: No such file or directory
compilation terminated.
*** [.pio\build\espem\src\main.cpp.o] Error 1
============================================================ [FAILED] Took 8.03 seconds ============================================================
Environment Status Duration


espem FAILED 00:00:08.027
====================================================== 1 failed, 0 succeeded in 00:00:08.027 ====================================================== "

and an error in the main.cpp also as shown in the screen shot below

image

Your examples do not compile in Arduino IDE

Swears like this -

In file included from C:\Users\User\Documents\Arduino\libraries\pzem-edl-main\examples\03_MultiplePZEM004\src\main.h:14:0,
from C:\Users\User\Documents\Arduino\libraries\pzem-edl-main\examples\03_MultiplePZEM004\src\main.cpp:14:
C:\Users\User\Documents\Arduino\libraries\pzem-edl-main\src/pzem_edl.hpp:18:19: fatal error: LList.h: No such file or directory
compilation terminated.
exit status 1
Compilation error for board ESP32 Dev Module.

What to do?

Multiple instance example crashes

I've setup my PZEMs as per the CLI instructions and run the sample. Only change is that my GPIO pins are 16 and 17. So changed

#define RX_PIN 16           // custom RX pin number
#define TX_PIN 17           // custom TX pin number

Upon running the example crashes with:

PZEM multiple instance example

Added port id:10
Added PZEM id:42 addr:10, port id:1
Added PZEM id:43 addr:11, port id:1
Added PZEM id:44 addr:12, port id:1
abort() was called at PC 0x400ebf8b on core 1

ELF file SHA256: 0000000000000000

Backtrace: 0x40084f18:0x3ffb1e50 0x4008518d:0x3ffb1e70 0x400ebf8b:0x3ffb1e90 0x400ebfd2:0x3ffb1eb0 0x400ec0eb:0x3ffb1ed0 0x400eec13:0x3ffb1ef0 0x400d12a6:0x3ffb1f10 0x400d4492:0x3ffb1fb0 0x40086dfd:0x
--- exit ---
3ffb1fd0
  #0  0x40084f18:0x3ffb1e50 in invoke_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c:715
  #1  0x4008518d:0x3ffb1e70 in abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c:715
  #2  0x400ebf8b:0x3ffb1e90 in __cxxabiv1::__terminate(void (*)()) at /builds/idf/crosstool-NG/.build/src/gcc-5.2.0/libstdc++-v3/libsupc++/eh_terminate.cc:112
  #3  0x400ebfd2:0x3ffb1eb0 in std::terminate() at /builds/idf/crosstool-NG/.build/src/gcc-5.2.0/libstdc++-v3/libsupc++/eh_terminate.cc:112
  #4  0x400ec0eb:0x3ffb1ed0 in __cxa_pure_virtual at ??:?
  #5  0x400eec13:0x3ffb1ef0 in PZPool::updateMetrics() at .pio/libdeps/example/pzem-edl/src/pzem_edl.cpp:303
  #6  0x400d12a6:0x3ffb1f10 in setup() at src/main.cpp:110
  #7  0x400d4492:0x3ffb1fb0 in loopTask(void*) at /Users/nevilledastur/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:18
  #8  0x40086dfd:0x3ffb1fd0 in vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c:355 (discriminator 1)

loop() not working / Execute own program Code Example.

Hi @vortigont,

It´s Me again. I had success with the Signale Values, now I tried to add some stuff to loop() and it is not working.

this kind of Programing is new to me, can you give a newbie a example on how to execute my "own" code? with your Library?

Sorry for these kind of questions, but i would love to use ur Library for my projekt.

Thanks in advance.

Resetting energy counter

I can't find a way to reset the power meters back to zero. I.e. a Energy counter reset

From https://github.com/mandulaj/PZEM-004T-v30/blob/master/src/PZEM004Tv30.cpp

/*!
 * PZEM004Tv30::resetEnergy
 *
 * Reset the Energy counter on the device
 *
 * @return success
*/
bool PZEM004Tv30::resetEnergy(){
    uint8_t buffer[] = {0x00, CMD_REST, 0x00, 0x00};
    uint8_t reply[5];
    buffer[0] = _addr;

    setCRC(buffer, 4);
    _serial->write(buffer, 4);

    uint16_t length = receive(reply, 5);

    if(length == 0 || length == 5){
        return false;
    }

    return true;
}

Значение потребленной мощности в киловатт часах, сбросилось и начало считать заново

{"age":245,"U":200.1,"I":10.79,"P":2104,"W":16976,"hz":50.0,"pF":0.97}
Вчера значение когда подключил esp значение показало 52квч, хотя на прошивке тасмола было 378 квч, сегодня же значение пошло считать заново, при этом достало примерно до 65квч и сбросилось, мое предположение что это проблема может быть в переменной unsigned int у которой значения 0… 65 535

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.