Code Monkey home page Code Monkey logo

Comments (6)

mandulaj avatar mandulaj commented on May 27, 2024

Hi there, sorry, I don't have an Arduino Due so I can't have a look at this. Maybe someone else can help?

from pzem-004t-v30.

Bruno999B avatar Bruno999B commented on May 27, 2024

Hello, I have the same problem, the problem is as follows:

arduino_due_x/variant.h:251:18: error: 'Serial' has a previous declaration as 'UARTClass Serial'
extern UARTClass Serial;
invalid conversion from 'int' to 'HardwareSerial*' [-fpermissive]

you can see the problem by compiling with the IDE configured on a due card.
Please take a look if you have a few minutes. I want to connect several Pzem on a Due, the mega is not powerful enough for the web interface...

Thank you!

from pzem-004t-v30.

mandulaj avatar mandulaj commented on May 27, 2024

Has anyone found a solution, or work around? Is this issues still relevant?

from pzem-004t-v30.

Fox2829 avatar Fox2829 commented on May 27, 2024

Hi,

Unfortunately the problem has not been resolved.
Please help to implement compatibility with DUE.
It is very necessary!

Thank you!

from pzem-004t-v30.

mandulaj avatar mandulaj commented on May 27, 2024

This issue might be related to #39 It looks like the workaround for using both hardware and software serial is not completely compatible with all boards. Further investigation is required thought.

from pzem-004t-v30.

seramonte avatar seramonte commented on May 27, 2024

Newbie, here. pzem017v1 library (for PZEM-017 DC meter) is identical to pzem004t30 except for specific data addresses. So this should apply. For pzem017v1 DUE compatibility I took inspiration from ModbusMaster library; it uses Stream instead of HardwareSerial; it separates initialization (outside of setup()) from begin() (inside setup). This works...except that oddly I get occasional random read errors (no problem when using ModbusMaster). Still investigating. This is what I did:

In PZEM017v1.cpp replace class initialization and add new begin() member:

//extern HardwareSerial Serial;  // Commented out for DUE

/*
PZEM017v1::PZEM017v1(HardwareSerial* port, uint8_t addr) // Commented out for DUE
{
    port->begin(PZEM_BAUD_RATE, SERIAL_8N2);
    this->_serial = &port;
    this->_isSoft = false;
    init(addr);
}
*/

PZEM017v1::PZEM017v1(void)
{
}

void PZEM017v1::begin(uint8_t slaveAddr, Stream &serial)
{
    _serial = &serial;
    init(slaveAddr);
}

In pzem017v1.h:

    //PZEM017v1(HardwareSerial* port, uint8_t addr=PZEM_DEFAULT_ADDR);
    PZEM017v1(void); // changed for DUE

    void begin(uint8_t slaveAddr, Stream &serial); //  added

In .ino:

//PZEM017v1 pzem(&Serial3, slaveAddr);
PZEM017v1 pzem;

setup() {
  Serial3.begin(9600, SERIAL_8N2);
  pzem.begin(slaveAddr, Serial3);

...

I think that's it.

from pzem-004t-v30.

Related Issues (20)

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.