Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PZEM004T compiling code problem #837

Closed
MariusLaurinaitis opened this issue May 2, 2018 · 21 comments
Closed

PZEM004T compiling code problem #837

MariusLaurinaitis opened this issue May 2, 2018 · 21 comments

Comments

@MariusLaurinaitis
Copy link

Hello,
I have problem with PZEM004T, Platformio dont compile the code, I get an errors:
espurna/config/../sensors/PZEM004TSensor.h:131:23: error: expected identifier before numeric constant
espurna/config/../sensors/PZEM004TSensor.h:131:23: error: expected ',' or '...' before numeric constant
espurna/config/../sensors/PZEM004TSensor.h:130:28: error: invalid initialization of non-const reference of type 'Stream&' from an rvalue of type 'int'
espurna/config/../sensors/PZEM004TSensor.h:23:41: error: class 'PZEM004TSensor' does not have any field named '_data'
espurna/config/../sensors/PZEM004TSensor.h:75:25: error: no match for 'operator==' (operand types are 'Stream' and 'int')
espurna/config/../sensors/PZEM004TSensor.h:76:23: error: cannot convert 'PZEM004T' to 'PZEM004T*' in assignment
espurna/config/../sensors/PZEM004TSensor.h:78:41: error: no matching function for call to 'PZEM004T::PZEM004T(Stream&)'
espurna/config/../sensors/PZEM004TSensor.h:80:34: error: no matching function for call to 'PZEM004T::setAddress()'
espurna/config/../sensors/PZEM004TSensor.h:101:23: error: '((PZEM004TSensor*)this)->PZEM004TSensor::_ip' does not have cla
ss type
espurna/config/../sensors/PZEM004TSensor.h:115:54: error: no matching function for call to 'PZEM004T::current()'
espurna/config/../sensors/PZEM004TSensor.h:116:54: error: no matching function for call to 'PZEM004T::voltage()'
espurna/config/../sensors/PZEM004TSensor.h:117:52: error: no matching function for call to 'PZEM004T::power()'
espurna/config/../sensors/PZEM004TSensor.h:118:53: error: no matching function for call to 'PZEM004T::energy()'

@MariusLaurinaitis
Copy link
Author

Thanks,
I downloaded DEV, BIN compiled, but WEB GUI does not turn on. I'll wait, maybe I hurried up

Marius

@xoseperez
Copy link
Owner

Yeah, just fixed the compiling problems, I have not test it yet.

@MariusLaurinaitis
Copy link
Author

Hello, any news?

Thanks
Marius

@xoseperez
Copy link
Owner

I've been testing the PZEM with ESPurna and there an issue when using software serial that I have not been able to solve. Using hardware serial works just fine. I have changed the default method in the sensors.h file for the moment. Notice that using hardware serial for PZEM is not compatible with serial debug, so to build an image with this settings the hardware definition must state:

#define PZEM004T_SUPPORT                0
#define DEBUG_SERIAL_SUPPORT            0

@xoseperez
Copy link
Owner

Actually, using an oscilloscope shows that the PZEM is not answering back when using software serial... not sure the reason, but it does when using hardware serial..

@xoseperez xoseperez modified the milestones: 1.12.7, 1.13.0 Jun 4, 2018
@xoseperez
Copy link
Owner

@MariusLaurinaitis Can you give it a try using hardware serial?

@MariusLaurinaitis
Copy link
Author

Hello, I tried it yesterday. But I do not understand. I have downloaded the DEV version. What do I need to change in specific files? At PZEM I connect the Wemos mini.

@MariusLaurinaitis
Copy link
Author

arduino.h
#define WEMOS_D1_MINI_RELAYSHIELD
#define DEBUG_SERIAL_SUPPORT 0
#define PZEM004T_SUPPORT 1

sensors.h
//------------------------------------------------------------------------------
// PZEM004T based power monitor
// Enable support by passing PZEM004T_SUPPORT=1 build flag
//------------------------------------------------------------------------------

#ifndef PZEM004T_SUPPORT
#define PZEM004T_SUPPORT 0
#endif

#ifndef PZEM004T_USE_SOFT
#define PZEM004T_USE_SOFT 0 // Use software serial
#endif

#ifndef PZEM004T_RX_PIN
#define PZEM004T_RX_PIN 13 // Software serial RX GPIO (if PZEM004T_USE_SOFT == 1)
#endif

#ifndef PZEM004T_TX_PIN
#define PZEM004T_TX_PIN 15 // Software serial TX GPIO (if PZEM004T_USE_SOFT == 1)
#endif

#ifndef PZEM004T_HW_PORT
#define PZEM004T_HW_PORT Serial1 // Hardware serial port (if PZEM004T_USE_SOFT == 0)
#endif

@MariusLaurinaitis
Copy link
Author

I understand that I can specify the Wemos PIN:
hardware.h

// PZEM004T
#define PZEM004T_SUPPORT 0 // not working?
#define PZEM004T_RX_PIN 3
#define PZEM004T_TX_PIN 1

@xoseperez
Copy link
Owner

xoseperez commented Jun 13, 2018

No, it should be like this:

#define PZEM004T_SUPPORT                1
#define PZEM004T_USE_SOFT               0
#define PZEM004T_HW_PORT                Serial
#define DEBUG_SERIAL_SUPPORT            0

And connect the PZEM to the RX/TX pins.

@MariusLaurinaitis
Copy link
Author

OK,
#define PZEM004T_HW_PORT Serial

#define PZEM004T_HW_PORT Serial1 ? (delete 1?)

And Wemos PIN RX and TX? Do I need to use the standard Wemos RX TX?

@MariusLaurinaitis
Copy link
Author

image

@xoseperez
Copy link
Owner

xoseperez commented Jun 13, 2018

The main hardware port in the ESP8266 uses GPIOs 1 and 3. These are mapped to RX and TX in the Wemos.

So yes, you have to wire the PZEM004T to RX/TX and use the configuration I copied above.

In your screenshot you can see it is still using SoftwareSerial (it says "PZEM004T @ SwSerial(13,15)")

@MariusLaurinaitis
Copy link
Author

image

@MariusLaurinaitis
Copy link
Author

MariusLaurinaitis commented Jun 14, 2018

OK! All good!
as I understood, the SWITTCH#0 must be ON

@xoseperez
Copy link
Owner

Nice, I'm labeling it as ready to deploy

@1043717432
Copy link

Hey, what's the final configuration?

@rradar
Copy link

rradar commented Feb 17, 2019

Is there a chance to get a pre build image for the pzem004t and a wemos d1 mini or the node mcu?

Also wiring would be interesting... 😃

@jen101121
Copy link

hey, goodafternoon, I need help, Can you help me?
my problem is, arduino ide software, said "no matching for call to pzem004tv30", how can i solve this?

@mcspr
Copy link
Collaborator

mcspr commented Mar 16, 2024

@jen101121 update ESP8266 Core in boards manager, it must be 3.1.2
don't see any problems when using arduino-ide 2.x or arduino-cli

If you still have any issues, please create a new one instead of continuing here

@jen101121
Copy link

jen101121 commented Mar 16, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants