Arduino Modbus Issues -

For those who are interested, I've spent hours and hours on this and not really got anywhere. What I've done though now is simply eliminated a lot of the code and now I'm reading from only one register. It works if I only read from one register. I have no idea what was up with it, the other fields would have been handy, but these fields in this one register will have to suffice.

For those who see this thread in the future, this was the code which I managed to scrape by with:

#include

#define MAX485_DE 3
#define MAX485_RE_NEG 2

ModbusMaster node;

void preTransmission()
{
digitalWrite(MAX485_RE_NEG, 1);
digitalWrite(MAX485_DE, 1);
}

void postTransmission()
{
digitalWrite(MAX485_RE_NEG, 0);
digitalWrite(MAX485_DE, 0);
}

void setup()
{
pinMode(MAX485_RE_NEG, OUTPUT);
pinMode(MAX485_DE, OUTPUT);
// Init in receive mode
digitalWrite(MAX485_RE_NEG, 0);
digitalWrite(MAX485_DE, 0);

// Modbus communication runs at 115200 baud
Serial.begin(115200);

// Modbus slave ID 1
node.begin(1, Serial);
// Callbacks allow us to configure the RS485 transceiver correctly
node.preTransmission(preTransmission);
node.postTransmission(postTransmission);
}

void loop()
{
uint8_t resultMain;

resultMain = node.readInputRegisters(0x3100, 6);
if (resultMain == node.ku8MBSuccess)
{
Serial.print("PV Voltage: ");
Serial.println(node.getResponseBuffer(0x00) / 100.0f);
Serial.print("PV Current: ");
Serial.println(node.getResponseBuffer(0x01) / 100.0f);
Serial.print("Battery Voltage: ");
Serial.println(node.getResponseBuffer(0x04) / 100.0f);
Serial.print("Battery Charge Current: ");
Serial.println(node.getResponseBuffer(0x05) / 100.0f);
}
}

Antony...