Hello people
I'm a novice and I'm trying to read data from an epever charge controller using MODBUS according to the following details:
Arduino: Mega
Used library: ModbusMaster
Circuit: rs-485 module connected as follows
1- MAX485_DE → Pin 2 of Arduino
2- MAX485_RE_NEG → Pin 2 of the Arduino
3- MAX485_RO → 19 Arduino RX Pin
4- MAX485_DI → 18 TX Pin of Arduino
Teste.ino (1.2 KB)
The link below has the address of each epever charge controller data
https://drive.google.com/file/d/1MR_LYVdnBIO6cV4cjuRz217lro9rRGKE/view?usp=sharing
I tested the code to get variables like voltage and current and it works normally. My question is how can I get the Battery status, Array status, Charging status, Load status and Array Power(W) data correctly?
@anon35854268, your topic has been moved to a more suitable location on the forum. Introductory Tutorials is for tutorials that e.g. you write, not for questions. Feel free to write a tutorial once you have solved your problem 
In future, please post your code in a post instead of as an attachment. Not everybody can open ino files on e.g. a cell phone so your missing out on knowledgeable people.
OP's code
#include <ModbusMaster.h>
#include <SPI.h>
#include <SD.h>
#define MAX485_DE 2
#define MAX485_RE_NEG 2
ModbusMaster node;
File myFile;
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 no modo de recepção
digitalWrite(MAX485_RE_NEG, 0);
digitalWrite(MAX485_DE, 0);
Serial1.begin(115200);
Serial.begin(9600);
node.begin(1, Serial1);
node.preTransmission(preTransmission);
node.postTransmission(postTransmission);
if (!SD.begin(53)) {
while (1);
}
}
bool state = true;
void loop()
{
uint8_t result;
uint16_t data[6];
result = node.writeSingleCoil(0x0002, state);
state = !state;
result = node.readInputRegisters(0x3100,20);
myFile = SD.open("alex.txt", FILE_WRITE);
if (result == node.ku8MBSuccess)
{
Serial.print("Array Current(A): ");
Serial.print(node.getResponseBuffer(0x01)/100.0f);
Serial.print(";");
}
delay(1000);
}
Thank you for the informations
A little wiring, drawn by pen and paper is preferred. Word built wirings often hide away the reason for error. It's what's not told that often matters.