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

Compilation error #3

Open
KhurramFHassan opened this issue Sep 13, 2021 · 6 comments
Open

Compilation error #3

KhurramFHassan opened this issue Sep 13, 2021 · 6 comments

Comments

@KhurramFHassan
Copy link

I am getting the following error when compiling for arduino nano:
....\Arduino\libraries\PZEM-017-v1-master\PZEM017v1.cpp: In constructor 'PZEM017v1::PZEM017v1(uint8_t, uint8_t, uint8_t)': ....\Arduino\libraries\PZEM-017-v1-master\PZEM017v1.cpp:90:32: error: 'SWSERIAL_8N2' was not declared in this scope port->begin(PZEM_BAUD_RATE,SWSERIAL_8N2); ^~~~~~~~~~~~ ....\Arduino\libraries\PZEM-017-v1-master\PZEM017v1.cpp:90:32: note: suggested alternative: 'SERIAL_8N2' port->begin(PZEM_BAUD_RATE,SWSERIAL_8N2); ^~~~~~~~~~~~ SERIAL_8N2 exit status 1

How can I make it compile?
Thanks

@KhurramFHassan
Copy link
Author

It seems that there are 2 errors in the softwareserial example:

  1. You need to include softwareserial library in your code.
  2. You need a modbus address in the constructor.

I was able to compile the program (a simple getAddress) but was unable to change the address using setAddress; it always returned false. Now I will wire up the circuit and try to get some readings.

Can you please look into why setAddress is not working.

Thanks

@maxzerker
Copy link
Owner

maxzerker commented Sep 14, 2021

I'm initially using this code for ESP8266 on this project other boards were not tested, you can look into PZEM017v1.h and modify it there.

setAddress problem is a known issue during the test, but my project doesn't require the address to be changed
I instead use supplied rs485 converter connected to the PC and use qmodbus to modify PZEM's address.

The project was finished last year I'm no longer have the hardware to fix the code 'pull request' is welcomed.

@KhurramFHassan
Copy link
Author

Qmodbus looks interesting. I have downloaded it but cannot figure out how to change the slave id. Can you please help me out here?
Thanks

@KhurramFHassan
Copy link
Author

I was able to get the pzem-017 to work with QModBus. Apparently, you need a 120 ohm resistor between the A and B lines. I just added the resistor to the A/B terminal block and it started working.

@AtherSaleem
Copy link

I am having some problem in reading through ESP32

USB RS485, I can read on PC. This means Pzem Module is fine.

But on Arduino (ESP32) using Serial 2 (HardSerial Example), The Tx light on Rs485 Module blinks , but there is no response from Pzem. I also tried 100 Ohm and 180ohm resisters , I can found in my junk. I am not engineer, my guess is these resisters should work. B is connected to B & A is connected to A.

Any help would be appreciated

@impotter
Copy link

impotter commented Aug 5, 2024

Change SWSERIAL_8N2 to SERIAL_8N2 in the directory your lib
....\Arduino\libraries\PZEM-017-v1-master\PZEM017v1.cpp in line 90

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

No branches or pull requests

4 participants