MODBUS Slaves with Arduino

Is arduino UNO is ok or do you need smaller than this?

OZ_Willy:
I have seen a few posts lately on MODBUS so I thought I might post what I use with arduino.

Oz, thanks for the code in your original post.

I found a version of the code that wasn't mapped to the IO and was just starting to map it. Then I randomly stumbled across your code and what do ya know...its mapped! Kudos!!

Any chance of getting this to work with Modbus TCP? Would love to throw a bunch of Uno's in a network environment.

Hello I wanted to ask for help, I am working with Arduino UNO and the following library modbus slave

https://code.google.com/archive/p/simple-modbus/

communication I'm trying with a program called Modscan32, this is being communicated via a USB-RS232 converter. I can not receive data or send, it may be that not using the corresponding pins of transmission and reception.

Sorry for the English, I am Chilean. :frowning:

someone can help me?

I have module Arduino Uno R3 will connected to Inverter through RS485. Frequency & Speed Modbus Slave RTU of Inverter be connected with Arduino (as Master). It is still not run yet. Would you share me some of tutorial for modbus Master RTU for Read holding Register? thank you very much.

Hi.
I'm using the code and libraries you supplied to test out the Arduino for a simple Modbus RTU.
I am currently using ModScan32 on a PC using the USB connection as Master.
Everything works really well when reading the registers etc, but when I try and write, the connection just times out with a timeout error and it's clear that the Arduino has not tried to reply as the Tx LED does not flash. (MODBUS Message TIME-OUT)
Any ideas?
I've tried both Arduino Uno and Elgoo Uno R3 with exactly the same result.

Hello,

Excuse me for my stupidity, but I am quite sure that I am missing something. I straight up copy the code and run it on my arduino UNO which is connected to my pc with USB. Then I use master programs (QModMaster and ModScan32) connect to it and when I start polling it tells me Error: Timeout.

I will be very thankful if you help me in some way.

Thank you in advance

I want to read input registers 30001,30003,..... etc from an Energy Meter using Arduino UNO. I am using Arduino in master configuration and Energy Meter(address =101) in slave. When i try to read the registers, I get this result e226. Can someone suggest , how it can be solved?.

Code is---

#include <ModbusMaster.h>

#include <SoftwareSerial.h>
SoftwareSerial ArduinoUno(3,2);

/!
We're using a MAX485-compatible RS485 Transceiver.
Rx/Tx is hooked up to the hardware serial port at 'Serial'.
/
#define MAX485_DE 9
#define MAX485_RE_NEG 8

// instantiate ModbusMaster object
ModbusMaster node;

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 in receive mode
digitalWrite(MAX485_RE_NEG, 0);
digitalWrite(MAX485_DE, 0);

// Modbus communication runs at 115200 baud
Serial.begin(9600);
ArduinoUno.begin(19200);

// Modbus slave ID 1
node.begin(101, ArduinoUno);
// Callbacks allow us to configure the RS485 transceiver correctly
node.preTransmission(preTransmission);
node.postTransmission(postTransmission);
}

bool state = true;

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

// Read 16 registers starting at 0x30003)
result = node.readInputRegisters(30003,4);
Serial.println(result);

delay(1000);
}

Hi sir, your code is used to read and write register of Arduino through Modbus

And how about the coil, I am looking for a way to write and read the coil in arduino

In the ModbusSlave library,there got a function call setStatus for write coil and getDigitalStatus for read coil

But It doesn't work and I'm not clear about that,anyone know how to solve this question?

Thanks.

Hi sir , I also have write a code which is looks alike yours, and it work.

Write register : regBank.set(XXXXX,XX);
Read register : regBank.get(XXXXX);

But now I want to read and write a coil of Modbus Arduino , do you have any idea how to implement it?

i think this helps u: