Reading energy meter with RS485 MODBUS protocol

Hello everyone

I am currently working on a project for which I have to read data from an energy meter through RS485 communication.

Energy meter: http://.farnell.com/datasheets/2166982.pdf
Communication protocol energy meter: https://.enika.cz/data/files/produkty/energy%20m/CP/EM100%20and%20ET100%20series%20-%20Modbus%20serial%20protocol%20-%20rev.2.6%20-%20141114.pdf

(put 'www' after 'https://', I could not post more than 2 links in my thread)

The board I am using is an Arduino Leonardo board, but it is mounted inside of a PLC enclosure. The PLC is a product from industrial shields, a company that makes Arduino based PLC's for a low price. This PLC allows communication through RS485 when the switch zones are setup correctly. A MAX485 module is used for this.

Arduino PLC: https://www.industrialshields.com/web/content?model=ir.attachment&field=datas&id=185658&

I am currently trying to read 2 registers from the energy meter. Holding register 4 and 5, those registers contain the active power. I think my wiring is correct and the parameters are also set up correctly. But every time I run my code, I do not get any response from the energy meter. Reading the parameter "result" gives me the error code E2, which means that I did not get any response from my slave.

I have attached the settings for my energy meter, my code and pictures of my connection.

Settings energy meter:
Parity: even
Stop bit: 1
Slave ID: 1
Baud rate: 9600

Code:
`#include <ModbusMaster.h>

ModbusMaster node;

uint16_t baudrate = 9600L;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////

void setup() {

Serial.begin(baudrate, SERIAL_8E1);
node.begin(1, Serial);

}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////

void loop() {
uint8_t result;
uint16_t data[2];

result = node.readHoldingRegisters(4, 2);

Serial.println(" ");

if (result == node.ku8MBSuccess)
{
Serial.println("succes");
}
else
{
Serial.print("no succes, error code: ");
Serial.println(result, HEX);
}

delay(1000);

}`

Pictures:
https://we.tl/t-kCGbYQ3P26

The cable I just an ethernet cable that I cut open and stripped on both sides.

This is my first post on the forum so I hope that I provided enough information. If not, please let me know. If anyone would be able to help me, that would be greatly appreciated!

Thanks in advance.

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