emelianov / modbus-esp8266

Most complete Modbus library for Arduino. A library that allows your Arduino board to communicate via Modbus protocol, acting as a master, slave or both. Supports network transport (Modbus TCP) and Serial line/RS-485 (Modbus RTU). Supports Modbus TCP Security for ESP8266/ESP32.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add Modbus function to reset a Power Monitor

dakriege opened this issue · comments

I'm using the library with an Adafruit ESP32-3 and a Modbus Power Monitor.

The Power Monitor has a KWH Totalizer that can be reset using a custom Modbus Command 0x42.

The format of the command is SlaveID + 0x42 + CRC High Byte + CRC Low Byte

The reply length is 0 bytes. -> SlaveID + 0x42 + CRC High Byte + CRC Low Byte

Using a SAND51 processor and the Arduino Modbus library it was pretty easy to add the 0x42 function.

Can you offer any help in adding the 0x42 command or a means to send raw data to create a custom message.

This issue was resolved using the Raw Request function. I added a 0x42 function code in the modbus.h file so that it could be used in the MasterPDU switch statement that tests the reply function code returned in the slave response.