hello i try to read holding register on pool pump but i have no response .
i used this code who works with relay modbus card but don't work with the pump
it has work only one time by magic ?? but now i have "faild to read registers! connection timed out"
i must send 01H(Device Adress) 03H(Function code) 0AH(controller 8bit high) 00H(controller 8bit low) 00H(controller lenght 8bit high) 01H(controller lenght 8bit low) 86H(crc control 8bit low) 03H(crc control 8bit high)
so --> 00H 03H 0AH 00H 00H 01H 86H 03H
the controller slave will respond 00H 03H 01H 00H 05H 31H B7H
in the pdf i have this register table :
Adress :0x0A00 / lenght:1 / read / task: display ID
adress: 0x0A01 / lenght:1 / read,write / task : language configuration
etc etc..
did you have any idea?
#include <ArduinoModbus.h>
// How often (in milliseconds) the pump will be read.
const unsigned long REPORT_INTERVAL = 1000;
void setup() {
Serial.begin(9600);
while(!Serial);
if (!ModbusRTUClient.begin(9600)) {
Serial.println("Failed to start Modbus RTU Client!");
while (1);
}
}
// The time at which the pump were last read.
unsigned long lastMillis = 0;
void loop() {
// If enough time has elapsed, read again.
if (millis() - lastMillis > REPORT_INTERVAL) {
lastMillis = millis();
// The Modbus RTU pump:
// Address: 0x00
// Holding Register: 0xA0
// Read Length: 1
if (!ModbusRTUClient.requestFrom(0x00, HOLDING_REGISTERS, 0xA0, 1)) {
Serial.print("failed to read registers! ");
Serial.println(ModbusRTUClient.lastError());
}
else {
// If the request succeeds, the pump sends the readings, that are
// stored in the holding registers. The read() method can be used to
// get the display id values.
short displayid = ModbusRTUClient.read();
Serial.print("DISPLAY ID: ");
Serial.println(displayid);
}
}
delay(100);
}