hi
I am using a 2.5kw Growatt PV solar inverter connected to an Rs485 TTL converter through Modbus protocol which is further connected to Arduino Uno.I want to form a solar data monitoring system and want to monitor or get values of input registers to the serial monitor using Arduino but unable to get so.
Instead, I am getting some symbol of square boxes and question marks as the output on Serial Monitor.
need help anxiously!!
also in code, I have a query that address at last section in Serial.println to get or read input register value, should we use 0x04 or 0x03?
Pls PLs, help.......Also haven't used softwareserial.h library anywhere in the code, don't know why wrote it!!
#include<SoftwareSerial.h>
#include<ModbusMaster.h>
#define m485a 3
#define m485b 2
ModbusMaster node;
void preTransmission()
{
digitalWrite(m485a,1);
digitalWrite(m485b,1);
}
void postTransmission()
{
digitalWrite(m485a,0);
digitalWrite(m485b,0);
}
void setup() {
// put your setup code here, to run once:
pinMode(m485a,OUTPUT);
pinMode(m485b,OUTPUT);
digitalWrite(m485a,0);
digitalWrite(m485b,0);
Serial.begin(9600);
node.begin(1,Serial);
node.preTransmission(preTransmission);
node.postTransmission(postTransmission);
}
void loop() {
// put your main code here, to run repeatedly:
uint8_t resultmain;
resultmain = node.readInputRegisters(0x3100,33);
if (resultmain==node.ku8MBSuccess)
{
Serial.println("---------");
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);
}
delay(1000);
}



