Arduino Nano as Slave

Jilson Jose's picture

Offline

Joined: Dec 18, 2020

Replies: 0
Arduino Nano as Slave
December 18, 2020 - 5:23am

Hi, 

I would like to read float values from Arduino Nano using RS485 protocol.

Arduino nano is interfaced with Modbus poll using Max 485 TTL module. 

 

With help of a library application, I'm able to read integer values using Modbus Poll software... But can someone help me with reading analog values(Float) from Arduino Nano.

 

#include <ModbusRtu.h>
 
// assign the Arduino pin that must be connected to RE-DE RS485 transceiver
#define TXEN
 
// data array for modbus network sharing
uint16_t au16data[16] = {
  3, 1415, 9265, 4, 2, 7182, 28182, 8, 0, 0, 0, 0, 0, 0, 1, -1 };
 
/**
 *  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,TXEN); // this is slave @1 and RS-485
 
void setup() {
  Serial.begin( 19200 ); // baud-rate at 19200
  slave.start();
}
 
void loop() {
  slave.poll( au16data, 16 );
}
Tune pannunga's picture

Offline

Joined: Mar 23, 2021

Replies: 1

can you help me to read the int data from modbus slave using aurdino uno...because i don't understand # define TXEN 4

Sourav Gupta's picture

Offline

Joined: Feb 12, 2018

Replies: 508

This is the transmit enable pin of the Mudbus device that is being controlled by the Arduino pin 4.

Sourav Gupta's picture

Offline

Joined: Feb 12, 2018

Replies: 508

Could you share the function defination of slave.poll inside the ModbusRtu.h