Help using an Arduino to read UART messages?

I’m trying to read the data from a solar charge controller using an Arduino. The charge controller has a modbus interface, but for some reason it stops communicating with my Python script running on a Raspberry Pi periodically, making it useless.

I opened up its remote monitor box and found some UART pins, so I thought a good workaround would be to read the data directly from those pins if possible.

Attached is a picture of the remote monitoring box happily communicating with my charge controller, and of the UART pins I’m connecting to.

When I connect the TX pin from the remote monitoring box to the RX pin (pin 0) on my Arduino (and ground to ground) and run the following script, I get pulses of gibberish characters, which I believe is progress:

#include <SoftwareSerial.h>

// software serial : TX, RX 
SoftwareSerial portOne(0, 1);


void setup()
{
  // Start the hardware serial port
  Serial.begin(9600);

  // Start the software serial port
  portOne.begin(9600);

}

void loop()
{
  
   portOne.listen();

  while (portOne.available() > 0) {
    char inByte = portOne.read();
    Serial.write(inByte);
  }


}

But so far I haven’t found a buad rate that turns that gibberish into anything that I can make sense of.

Does anyone have any tips?

And I’m new to UART, does it sound like I’m barking up the right tree? When I connect the RX pin of the box to the Arduino’s TX pin, the box says “connecting”, meaning (I think) that its trying to communicate exclusively over the UART pins. So I’m not completely sure that it’s sending its data over the UART pins when there’s no connection.

Incidentally the charge controller I’m trying to read the data from is an Epsolar 4210a. If anyone’s interested, I’ve been writing about my issues connecting to it here:

Images from Original Post so we don’t have to download them. See this Image Guide

8b5e2fe24eb923539942c4ae59b6e6a40114d238.jpg

7513773912b7852b23654794c2b376e79326e4dd.jpg

…R

Do you know if the Tx and Rx on the device work at TTL (5v) signal levels?

How does the device communicate with the RPi?

Can you post a link to the datasheet or User Manual for the device?

...R

Oops, thanks for the tip on image uploading.

Here's the manual for the charge controller itself:

http://www.epsolarpv.com/en/uploads/news/201512/1449040581526220.pdf

And here's the manual for the remote monitoring box that I'm trying to connect to:

https://www.renogy.com/template/files/Manuals/TrcrMtr-MT-50.pdf

Your device may or may not use inverted TTL logic on the serial port, like the Arduino does. If you can, check the data with an oscilloscope.

Paul

And sorry I missed this:

How does the device communicate with the RPi?

Here's a stripped down version of my Python code. It works beautifully for awhile and then the controller will stop responding for hours, before seemingly randomly coming back. I haven't figured out any pattern.

#!/usr/bin/python

from pymodbus.client.sync import ModbusSerialClient as ModbusClient

import time

port = "/dev/ttyUSB0"

client = ModbusClient(method = 'rtu', port = port, baudrate = 115200)
client.connect()

while True:


    # read 6 registers starting at 0x3000
    result = client.read_input_registers(0x3000, 1, unit=1)

    pvVolts = float(result.registers[0] / 100.0)
    pvAmps = float(result.registers[1] / 100.0)
    batteryVolts = float(result.registers[4] / 100.0)
    batteryAmps = float(result.registers[5] / 100.0)


    print "pvvolts=", pvVolts
    print "pvamps=", pvAmps
    print "batteryvolts=", batteryVolts
    print "pvcurrent=", batteryAmps
    print


    time.sleep(1) # pause before reading the next register

    # read the battery SOC
    result = client.read_input_registers(0x311A, 1, unit=1)
    batterySOC = result.registers[0]

    print "batterySOC=", batterySOC

The odd thing is that the MT50 box always communicates just fine. And sometimes connecting that box for a moment will make it so my Python script works again, so I'm wondering if I'm missing something.

wrybread:

How does the device communicate with the RPi?

Sorry. I was not clear. I wanted to know what is the hardware connection - is it a serial connection or USB or something else?

From looking at the User Manual it seems to be RS485. You can get an RS485 - TTL serial converter and that may be the simplest way to connect the Arduino to it.

...R

Yes, with the Pi it uses RS485. But it periodically stops responding, which is why I'm trying to get the data in this way.

wrybread: Yes, with the Pi it uses RS485. But it periodically stops responding, which is why I'm trying to get the data in this way.

I can't see why it would behave any differently just because you connect upstream of the RS485 connector - IF that is what you are doing.

Do you know if the Tx pin you are connecting to is RS485 or not?

Do you know whether the RPi is causing the problem?

...R