Closed magorm closed 9 months ago
What charge controller are you using and how have you connected to it?
Can you try replacing the line containing read_holding_registers
with response = modbus.read_holding_registers(256, 35, unit=1, slave=255)
.
If your charge controller address is different than mine this will fix it.
Thanks so much. May I know the version of pymodbus you're using? Here is how I connected SNRE SCC to my Laptop running the Python script:
What charge controller are you using and how have you connected to it?
Can you try replacing the line containing
read_holding_registers
withresponse = modbus.read_holding_registers(256, 35, unit=1, slave=255)
.If your charge controller address is different than mine this will fix it.
Did not work. I think the issue is related to USB adapter?
Which USB adapter are you using? It might not use the right voltage.
Also, can you show how you wired the serial adapter up to the RJ12 cable?
Which USB adapter are you using? It might not use the right voltage.
I am using this adapter: USB to TTL converter UART module CH340G CH340 3.3V 5V switch
Also, can you show how you wired the serial adapter up to the RJ12 cable?
![Uploading solar-monitor.png…]()
The CH340G won't work, it only does +/-5V where RS232 needs +/-13V.
You'll need to use a usb to RS232 converter like this one: https://www.amazon.ca/StarTech-com-USB-Serial-Adapter-Prolific/dp/B00GRP8EZU
Also, I can't see that image so I'm not sure how you wired it up to your charge controller.
The CH340G won't work, it only does +/-5V where RS232 needs +/-13V.
You'll need to use a usb to RS232 converter like this one: https://www.amazon.ca/StarTech-com-USB-Serial-Adapter-Prolific/dp/B00GRP8EZU
Also, I can't see that image so I'm not sure how you wired it up to your charge controller.
Thanks. Apologies. Here's the connection diagram.
The CH340G won't work, it only does +/-5V where RS232 needs +/-13V.
You'll need to use a usb to RS232 converter like this one: https://www.amazon.ca/StarTech-com-USB-Serial-Adapter-Prolific/dp/B00GRP8EZU
Also, I can't see that image so I'm not sure how you wired it up to your charge controller.
If I use Raspberry Pi, is the Pi serial using +-13v? Thanks in advance.
The Pi is not using that voltage. In my demo it has to go through a breakout board with a MAX3232 on it which handles the voltage boost to talk to the charge controller.
MAX3232
Thanks. Will try this board, see if it will work - https://shopee.ph/MAX3232-RS232-to-TTL-Serial-Port-Converter-Module-DB9-Connector-MAX232-For-Arduino-i.226548939.4317808086
@magorm Did you get it to work?
Not yet. I already setup the raspberry pi zero 2w, made the code run but I think I bought a wrong RS232 adapter. I already ordered the board (https://www.digikey.ph/en/products/detail/mikroelektronika/MIKROE-602/4495610) similar to what you used. Hopefully I can make it work.
Question: from RS232 adapter going to RJ12 (charge controller), I only have to use tx, rx and gnd connection, right?
Yes, you only need rx, tx, and gnd coming from the charge controller.
I've never had much luck getting the dupont cables to make good contact with the DB9 port, so make sure you have good a good connection there.
You can also try swapping around the positions of the yellow and green wires connected to the Pi and the DB9 connector.
Hi. How did you get the register address? In the code its 256, not sure if it the same with SRNE charge controller?
I'm using SRNE charge controllers, which ones are you using?
I got it from the SRNE modbus datasheet
I'm using SRNE charge controllers, which ones are you using?
I got it from the SRNE modbus datasheet
Thanks. I am using the same SCC, specifically ML2440 model.
I have that one also, so you definitely should be able to get it to work with it :)
I have that one also, so you definitely should be able to get it to work with it :)
In rj12, did you use pin1 (tx), pin2 (rx) and pin3(gnd)? pin4 is also gnd but not sure if I should use it instead of pin3?
It should work either way. I only used pin 3 for ground.
Hi @cole8888 , for RJ12, the pin 1 is from the left side, right?
This is the log when I run the script; it is sending 0xff 0x3 0x1 0x0 0x0 0x23 0x10 0x31? Connection : True DEBUG:pymodbus.logging:Current transaction state - IDLE DEBUG:pymodbus.logging:Running transaction 1 DEBUG:pymodbus.logging:SEND: 0xff 0x3 0x1 0x0 0x0 0x23 0x10 0x31 DEBUG:pymodbus.logging:New Transaction state "SENDING" WARNING:pymodbus.logging:Cleanup recv buffer before send: 0x0 0x0 0x0 DEBUG:pymodbus.logging:Changing transaction state from "SENDING" to "WAITING FOR REPLY" DEBUG:pymodbus.logging:Changing transaction state from "WAITING FOR REPLY" to "PROCESSING REPLY" DEBUG:pymodbus.logging:RECV: 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 DEBUG:pymodbus.logging:Processing: 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 DEBUG:pymodbus.logging:Getting transaction 255 DEBUG:pymodbus.logging:Changing transaction state from "PROCESSING REPLY" to "TRANSACTION_COMPLETE" Failed to read data, reconnecting... 'ModbusIOException' object has no attribute 'registers'
Yes, that's pin one and it is the charge controller tx pin. Here is the pinout: https://github.com/cole8888/SRNE-Solar-Charge-Controller-Monitor/blob/main/Charge-Controller-Connector-Pinout.png
Can you replace the line containing read_holding_registers
with response = modbus.read_holding_registers(256, 35, unit=1, slave=255)
.
This will eliminate any address issues.
Can you follow the steps in this guide to make sure the serial port is enabled in raspi-config: https://pimylifeup.com/raspberry-pi-serial/
Also, can you send a picture of how you've got everything wired everything up now?
For the DB9, its 2(rx), 3(tx) and 5(gnd)?
Black (controller rx) goes to pin 2, White (controller tx) goes to pin 3, red (controller gnd) goes to pin 5.
Remember that the pin numbers reverse when comparing the male/female connectors:
Here's my connection. Not sure if the problem is the RJ12? BTW, I am using pymodbus v3.5.4
Yellow - Tx, Green - Rx, Black - Gnd, Red - Vcc
slave=255
Serial Enablement: I am using /dev/ttyS0
It looks like your RX and TX are flipped compared to my photo. Try doing this:
I was able to make it work! Thanks so much @cole8888 ! You are right the problem is wrong connection.
Getting the error 'has no attribute registers' when running SolarMonitor.py. Need your help :-)