Open KhurramFHassan opened 3 years ago
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
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.
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
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.
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
Change SWSERIAL_8N2
to SERIAL_8N2
in the directory your lib
....\Arduino\libraries\PZEM-017-v1-master\PZEM017v1.cpp in line 90
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