|
Post by furball on Dec 6, 2019 21:48:32 GMT
Trying to setup a raspberry pi to directly connect to the serial interface that the BT module uses. I have found several articles mentioning other controllers but not the Adventurer models. I have tried the directions from renogy.boards.net/thread/119/rover-monitoring-using-raspberry-pi but I can't seem to get any data from the serial port just an error message about expecting 2 bytes and only getting 1. I am trying the setup with a usb to serial adapter that works fine for other communications just not this. The software used is python based with the pymodbus package. The code that I changed for my setup and testing was: modbus = ModbusClient(method='rtu', port='/dev/ttyAMA0', baudrate=9600,stopbits = 1, bytesize = 8, parity = 'N', timeout = 5, unit = 1) a = modbus.connect() I change the port to /dev/ttyUS0 and I have tried the unit as 0,1 and 2. I also changed # Read registers from the controller r = modbus.read_holding_registers(256, 35, unit=1) register values to 255,35,unit=1 and several other combinations. The pymodbus package also has a cli interface that I use that would allow me to connect to the serial port but would not allow me to read any data. Is the interface the BT module uses on the Adventure not a true serial interface? Am I getting the starting register values wrong? Am I getting the unit # wrong? Any suggestions would be greatly appreciated.
|
|
|
Post by retrodaredevil on Dec 6, 2019 23:02:32 GMT
My guess is that you don't have the wires connected correctly, or what you're doing right now isn't set up for RS-232 communication.
This thread is very similar to what you are doing. If it doesn't help you, tell us how you have your wires connected to your raspberry pi and what you are using to convert the RS-232 signal to something the pi can read.
renogy.boards.net/thread/535/using-rj11-cable-connect-raspberryEDIT: Wait, I just read that you're using the included serial to USB, so now you can ignore the above. I recommend checking out libraries made for the rover that already exist to see why the communication doesn't work. Such as: github.com/KyleJamesWalker/renogy_rover or github.com/wildmountainfarms/solarthing (my own)
|
|
|
Post by furball on Dec 7, 2019 0:43:45 GMT
Not sure those will work since they seem to be aimed at the rover and not the adventurer, but I will take a look.
|
|
|
Post by retrodaredevil on Dec 7, 2019 4:15:43 GMT
Not sure those will work since they seem to be aimed at the rover and not the adventurer, but I will take a look. I think that because the Adventurer is compatible with the Renogy Bluetooth Module, it uses the same protocol as the Rover and Wanderer. If you don't want to use either of those examples I linked above, there are a ton of other repositories on github that do the same thing in different ways.
|
|
|
Post by playersz28 on Dec 8, 2019 18:36:41 GMT
I'm using the USB cable that came with my Rover. I also used an old RS232-USB cable I had and cut it up so that I could extend it with wire to reach between my RV in the driveway and my office. Both worked fine with the software I use. I created my setup by basing it off of the EPSolarServer code on github. I have a Pi3 and the app logs to a SQL server db. I have some other modules in the RV that support a shunt, GPS, accelerometer and such which also talk to the Pi. The document that is posted on a couple of threads here is correct for the Rover and other CC's.
|
|
|
Post by Mar on Dec 15, 2019 18:09:38 GMT
Hello
|
|
|
Post by furball on Dec 24, 2019 22:04:19 GMT
retrodaredevilI've tried the solarshed repo and it returned this error: ValueError: Checksum error in rtu mode: '\x00\x00' instead of '$\x00' . The response is: '\x00\x00\x00\x00\x00\x00\x00' (plain response: '\x00\x00\x00\x00\x00\x00\x00') That was just trying to load it. It may be a difference in the pin out for the adventurer vs the rover. I wish someone from renogy could very the pinout for me. I have not had much time to look at this lately, but I'm going to try the other repos you mentioned. playersz28, I wish the adventurer had the USB cable but it does not.
|
|
|
Post by retrodaredevil on Dec 25, 2019 0:03:05 GMT
|
|
|
Post by furball on Dec 25, 2019 16:10:58 GMT
That's the thread I followed to wire this up, but it does not match the wiring from the Bluetooth module cable that I cut to use. The rj11 pinout on it is populated with 4 wires. 1 = red 2 = black 3 = empty 4 = white 5 = empty 6 = green I have also ditched the USB to serial adapter and I am using a hat from Pimoroni that has breakout pins for serial Tx & Rx chicagodist.com/collections/pimoroni/products/pim445I have noticed something else when using minicom to monitor the serial port I get random data coming in. I am guessing it is hex values since they make no sense. sample of what I'm seeing .. .... .H. ..@. ........... $. . .H..........�. ..@@.....
|
|
|
Post by retrodaredevil on Dec 25, 2019 16:59:20 GMT
Yeah, the data won't be readable. But, with how Modbus works, you shouldn't be getting ANY data from the serial port unless you request it. Your computer has to be the one to initialize the communication. So, if you are getting random data like you said and you aren't requesting it, something is wrong with your adapter.
I am unfamiliar with the Pimoroni but after doing a ctl+f on that page, RS232 doesn't come up anywhere on that page. If we go back to talking about the USB to serial adapter, which you stopped using, do you know if that used RS232? The RS232 adapter is the most important part for getting this to work.
|
|
|
Post by furball on Dec 26, 2019 0:03:01 GMT
After doing some research on the native Tx Rx ports on the raspberry, it seems that it uses a 3.3v signal instead of the 12v signals that RS232 standard calls for so that idea is scrapped.
I'll switch back to the USB to serial adapter and see what I can get from that.
I might be wrong on the pinout from USB adapter as well but I think I have a decent map of a male pin RS232 serial port to work with.
More to follow once that is in place again.
|
|
|
Post by furball on Dec 26, 2019 1:31:11 GMT
And got a new error msg:
Modbus Error: [Input/Output] Modbus Error: [Invalid Message] Incomplete message received, expected at least 2 bytes (1 received)
This is from using the following code:
import time, datetime, os UNIT = 0x1
# Import Pymodbus from pymodbus.client.sync import ModbusSerialClient as ModbusClient
client = ModbusClient(method='rtu', port='/dev/ttyUSB0', timeout=1,baudrate=9600) client.connect() rr = client.read_holding_registers(0, 1, unit=UNIT) client.close() print(rr)
|
|
|
Post by furball on Dec 26, 2019 12:25:21 GMT
Output from logging enabled
DEBUG:pymodbus.transaction:Current transaction state - IDLE DEBUG:pymodbus.transaction:Running transaction 1 DEBUG:pymodbus.transaction:SEND: 0x1 0x3 0x0 0x0 0x0 0x4 0x44 0x9 DEBUG:pymodbus.client.sync:New Transaction state 'SENDING' DEBUG:pymodbus.transaction:Changing transaction state from 'SENDING' to 'WAITING FOR REPLY' DEBUG:pymodbus.transaction:Transaction failed. (Modbus Error: [Invalid Message] Incomplete message received, expected at least 2 bytes (1 received)) DEBUG:pymodbus.framer.rtu_framer:Frame - [] not ready DEBUG:pymodbus.transaction:Getting transaction 1 DEBUG:pymodbus.transaction:Changing transaction state from 'PROCESSING REPLY' to 'TRANSACTION_COMPLETE' Modbus Error: [Input/Output] Modbus Error: [Invalid Message] Incomplete message received, expected at least 2 bytes (1 received)
|
|
|
Post by furball on Dec 27, 2019 13:47:24 GMT
And another modbus client with more debug info.
This was done on a fresh install of the raspberry will all updates applied and only the minimalmodbus package for python installed.
>>> import minimalmodbus >>> instrument = minimalmodbus.Instrument('/dev/ttyUSB0', 1, debug = True) MinimalModbus debug mode. Create serial port /dev/ttyUSB0 >>> instrument.serial.baudrate = 9600 >>> print(instrument.read_register(2, 4)) MinimalModbus debug mode. Will write to instrument (expecting 7 bytes back): '\x01\x03\x00\x02\x00\x01%\xca' (01 03 00 02 00 01 25 CA) MinimalModbus debug mode. Clearing serial buffers for port /dev/ttyUSB0 MinimalModbus debug mode. No sleep required before write. Time since previous read: 1577454319875.52 ms, minimum silent period: 4.01 ms. MinimalModbus debug mode. Response from instrument: '\xff' (FF) (1 bytes), roundtrip time: 50.4 ms. Timeout for reading: 50.0 ms.
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/minimalmodbus.py", line 447, in read_register payloadformat=_PAYLOADFORMAT_REGISTER, File "/usr/local/lib/python2.7/dist-packages/minimalmodbus.py", line 1170, in _generic_command payload_from_slave = self._perform_command(functioncode, payload_to_slave) File "/usr/local/lib/python2.7/dist-packages/minimalmodbus.py", line 1244, in _perform_command response, self.address, self.mode, functioncode File "/usr/local/lib/python2.7/dist-packages/minimalmodbus.py", line 1699, in _extract_payload MINIMAL_RESPONSE_LENGTH_RTU, response minimalmodbus.InvalidResponseError: Too short Modbus RTU response (minimum length 4 bytes). Response: '\xff'
It looks like the adventurer is not responding with a properly formatted modbus reply.
Might try another USB to serial adapter just to be sure.
|
|
|
Post by retrodaredevil on Dec 27, 2019 18:24:46 GMT
I think that because you're unable to get it working with multiple modbus clients, your adapter is probably not correct. Can you send me a link to the adapter you're currently using? Does the adapter explicitly say it was meant for RS232 to USB?
|
|