rs232-MODBUSRTU Connecting with samkoon hmi

hi, I have a project to send data to the HMI Samkoon EA-043A device and get values from HMI to the Arduino. firstly I need to connect with the device. so I used this code to get the connection.

#include <ModbusRtu.h>
#include <SoftwareSerial.h>

// data array for modbus network sharing
uint16_t au16data[9];
uint8_t u8state;

SoftwareSerial mySerial(3, 5);//Create a SoftwareSerial object so that we can use software serial. Search "software serial" on Arduino.cc to find out more details.

/**
 *  Modbus object declaration
 *  u8id : node id = 0 for master, = 1..247 for slave
 *  port : serial port
 *  u8txenpin : 0 for RS-232 and USB-FTDI 
 *               or any pin number > 1 for RS-485
 */
Modbus slave(1, Serial, 0); // this is master and RS-232 or USB-FTDI via software serial

/**
 * This is an structe which contains a query to an slave device
 */
//modbus_t telegram;

unsigned long u32wait;

void setup() {
  mySerial.begin(9600);//use the hardware serial if you want to connect to your computer via usb cable, etc.
  slave.start(); // start the ModBus object.
  slave.setTimeOut( 2000 ); // if there is no answer in 2000 ms, roll over
  u32wait = millis() + 1000;
  u8state = 0; 
}
void loop(){
  // uint8_t state = slave.poll( au16data,9);
   //Serial.println(state);
  }


now I have done that part but I need to send data and receive data. but I don't have any ideas how the data address needs to be set. this figure shows the ASCII entry configuration that I have tried to use to send data to the Arduino


.
this is the configuration for the ASCII display which use to display data of the Arduino.

so, this is what I exactly need to do. firstly I need to send data(any ASCII character) from Arduino and display it on the HMI device. I'm sending one character as my first step. the second step is to receive data from HMI and display it on the serial monitor. any kind of help is much appreciated.

You create a SoftwareSerial device but you don't used afterwards.

If you comment out important parts of the code it cannot work.

1 Like

I have changed to Nextion displays. got many issues to send and receive