Open Jetiman opened 2 years ago
Check and recheck all of your wire connections - especially between A and B on the RS485 side of the pzem module and the usb - serial adapter. I was repeatedly getting the same error (with a known working pzem module) and I was able to resolve it by disconnecting everything and reconnecting it with a new pair of wires. In the end I don't think it was a code issue ... Perhaps I had inadvertently crossed A and B. Good luck
Did you install the pymodbus on the RPI? sudo pip3 install pymodbus # Install ModBus
After verifying the wiring, have you tried the command on the RPi to verify it sees the USB device: ls /dev/ttyUSB*
It should result in something like this on the RPI showing the USB port that the PZEM module is connected to: /dev/ttyUSB0
If it is not ttyUSB0 but a second or other port you will need to adjust a setting in the energyMaster.py chanPorts = ["/dev/ttyUSB0"]
The energyMaster.py assumes the PZEM-016 (AC module). For the PZEM-017 (DC module), you will need to change the call from: readAcPZEM(chanPort, chanAddr) to: readDcPZEM(chanPort, chanAddr)
One option is to run the pzem.py directly instead of from energyMaster.py. This will is simpler for debug and you can get the interface working. Then switch back to energyMaster.py.
The usb port is correct. The USB adapter flashes when querying.
The cables must be correct, the Windows software works and shows values.
I don't understand exactly where my mistake is
python3 pzem.py
Test PZEM-016 module on /dev/ttyUSB1 with channel address of 0 by performing read of 10 registers:
Exception reading DC PZEM: 'ModbusIOException' object has no attribute 'registers'
0V
0A
0W
0Wh
The PZEM-016 works. Peacefair claims the PZEM-017 is the same except 2 less registers (no power factor). As the project documentation states, I had not verified operation with the PZEM-017. I will order the PZEM-017 this week and try it out. Are you certain that you are on the second USB port (/dev/ttyUSB1) and that your PZEM-017 address is 0? Would you also check address 0xFB with the software? Thanks.
Jetiman, you wrote that "Data is displayed on Windows, so hardware is okay". Was there a windows package, driver, or code that you used on windows to check-out that the PZEM-017 was functioning correctly? Can you forward a link for the code? I want to compare what you have working on Windows with the settings and message content on the RPI. Thanks in advance. Plan to look at it this weekend.
I used the original PZEM003-Master tool that came with it
Updated pzem.py with enhanced debug. Now logs raw messages and responses. Changed PZEM-017 stop bits from 1 to 2. PZEM-017, the DC module, does not currently (3/21/2022) work. Tried it on Windows with Q_ModMaster and wasn't able to get that working either. Verified raw data on both the RPI and on Windows matches Peacefair's PZEM documentation. Both on the RPI and on Windows 10, you can see the RS-485 Tx LED but no response on the PZEM-017 (DC module). Tired multiple address including 0xF8. PZEM-016 (AC module) still works as it always has.
Hi,
I have the PZEM-017 with 100A.
I don't get any values displayed. Data is displayed on Windows, so hardware is okay.
What do I have to do to make your program work with the PZEM-017?