I am working on a power monitoring system for college project we are using power meter that has out RS485 Modbus RTU
I need to read Modbus register address starting from 30000 to 30058 which has length 2(no ODD number only even it counts 30000 30002) and data structure float.
I am using an Arduino UNO and RS485/TTL converter auto direction with inputs A and B output RX TX.
I have tried this code but unfortunately, it didn't work any advice or help would be much appreciated
////////////////////
#include <ModbusMaster.h>
ModbusMaster node;
void setup()
{
Serial.begin(9600);
Serial.println("------");
node.begin(1, Serial);
node.preTransmission(preTransmission);
node.postTransmission(postTransmission);
}
void loop()
{
uint8_t resultMain;
resultMain=node.readInputRegisters(0x30000, 58);
if (resultMain == node.ku8MBSuccess)
{
Serial.println("------");
Serial.print("Voltage: ");
Serial.println(node.getResponseBuffer(0x00) / 100.0f);
Serial.print("Current: ");
Serial.println(node.getResponseBuffer(0x10) / 100.0f);
Serial.print("Power: ");
Serial.println(node.getResponseBuffer(0x18) / 100.0f);
Serial.print("PF: ");
Serial.println(node.getResponseBuffer(0x30) / 100.0f);
}
delay(1000);
}