SDM120 Modbus change ID

Hi all,

I have a SDM120 Modbus energy meter where I would like to change the id from 1 to 2. I have already figured out how to read from the energy meter but I had no luck so far writing to it.

The SDM Manual says that
image
So I assume that writeMultipleRegisters is correct:

writeMultipleRegisters(uint16_t u16WriteAddress,
  uint16_t u16WriteQty)

The write address is 0x0014 and the Write Qty is 2.

But I must be doing something wrong because I always receive in the Particle Console the value 226 which stands for Timeout Error.
So I would be very grateful if you could help me a little bit :slight_smile:

#include "ModbusMaster.h"


// instantiate ModbusMaster object as slave ID 1
ModbusMaster node(1);


void setup() {
	// initialize Modbus communication baud rate

	node.begin(2400);
	node.enableTXpin(D7); //A1 is the pin used to control the TX enable pin of RS485 driver
	//node.enableDebug();  //Print TX and RX frames out on Serial. Beware, enabling this messes up the timings for RS485 Transactions, causing them to fail.

	Serial.begin(9600);
	Serial.println("Starting Modbus Transaction:");
}

void loop() {
    uint8_t result;
     
    node.setTransmitBuffer(0, 0x4000);
    node.setTransmitBuffer(1, 0x0000);
    
    result = node.writeMultipleRegisters(0x0014, 2);
   
   delay(10000);
}

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.