1Ghasthunter1 / Helium_RMS

2 stars 0 forks source link

Renogy Wanderer always returns 0 bytes in response #2

Open denicola2 opened 2 years ago

denicola2 commented 2 years ago

Added code to count the return bytes in the response:

static byte recvd_data[16] = {};
static byte * querySlave( byte b[], int sizeOfArray ) {
  uint16_t crc = ModRTU_CRC(b, sizeOfArray);
  byte LSB = crc & 0xFF; //comes first
  byte MSB = (crc >> 8) & 0xFF; //then second
  b[sizeOfArray-2] = LSB;
  b[sizeOfArray-1] = MSB;

  Serial1.write(b, sizeOfArray);
  int counter = 0;
  while ((Serial1.available() < 1) && (counter < 10)){
    counter += 1;
    delay(5);
  }

  counter = 0;
  while (Serial1.available() > 0) {
    recvd_data[counter] = Serial1.read();
    counter++;
  }

  MYLOG("RS232", "Read %d bytes from Renogy: 0x%X.", counter, recvd_data);

  return recvd_data;
}

I always receive Read 0 bytes from Renogy: 0x0

I did not modify anything besides the serial device used, and that is initialized as follows: Serial1.begin(9600);

The rest of the code appears to not work as written.

1Ghasthunter1 commented 2 years ago

So this is one of those weird problems with Renogy products. On some of my Renogy devices, you must flip the orders of the wires to receive a response, EG:

Wanderer A Wanderer B
TX GND
RX VCC
VCC RX
GND TX

It may be possible to solve this through software explicity, as the bluetooth RS232 product seems to work across all devices regardless of this. Personally, I would always leave a reversible connector at some point between my arduino and the renogy's RS232 port to flip connections on the go.

If you do happen to get code working that handles this, get a pull request going and I'll be happy to pull it in.

I should add, I used RS232 converters that had lights to show when TX or RX pins were active. This was a great debugging tool and I was easily able to see when the wanderer did not reply during a serial transmission.

denicola2 commented 2 years ago

Do you mind sharing which RS232 converter you used? I am trying to use Mikroe CLICK RS232 in combination with a RAK WisBlock. The CLICK does not indicate when RX/TX is active.

Additionally, does the Wanderer expect a 5V or 3.3V signal?

Thanks so much for the responses! I will certainly investigate the signal swizzle.