Thinking of getting started

I am somewhat new to this world but have several jobs that I need a inexpensive modbus i/o network setup. I have several analog sensors all being 4-20ma, 0-5v, and 0-10v as well as 4 10k thermistor. I do not have experience with aadruino or code and was wondering how hard these are to set up and get sensor data back to my modbus master over ip? And if there are enough inputs on 1 unit for 4 thermistor inputs and 2 4-20 inputs as well as 1 0-5v input? If this is very difficult is there any chance of getting the setup loaded at the factory for a fee? I understand modbus and bacnet protocol but have no experience with adruino. I am looking for something that I can embed in my OEM products to give them the ability to communicate with modbus in current automation systems in facilities that retrofit my hardware. Thanks

| 1 1 1
Asked on 8/31/15, 2:05 AM

Any thoughts here?

on 8/31/15, 8:45 PM

Hi Derrick, I have implemented Modbus by using on the Industruino (as Master) and an Arduino Uno (as Slave). In order to get it to run on the Industruino, I had to modify the code - replacing Serial with Serial1, and ensuring that I set the Tx_En_Pin to 9. In order to get it running on the Uno I had to modify the code to use Software Serial.


#include <ModbusRtu.h> // mondified to have port 0 point to Serial1

// Modbus

uint16_t au16data[16]; //!< data array for modbus network sharing
uint8_t u8state; //!< machine state
uint8_t u8query; //!< pointer to message query
unsigned long u32wait;

Modbus master(0,1,9); // this is master on Serial1, with TX_EN on Pin 9 for RS-485

// Timer driving reading / sending of messages
Timer modbusTimer;

 * This is an structe which contains a query to a slave device
modbus_t telegram[1];

void setup() {

// Modbus
  // telegram 0: read registers from Slave 1
  telegram[0].u8id = 1; // slave address
  telegram[0].u8fct = 3; // function code (this one is registers read)
  telegram[0].u16RegAdd = 0; // start address in slave
  telegram[0].u16CoilsNo = 4; // number of elements (coils or registers) to read
  telegram[0].au16reg = au16data; // pointer to a memory array in the Arduino

  // telegram 1: read registers from Slave 2
  telegram[1].u8id = 2; // slave address
  telegram[1].u8fct = 3; // function code (this one is write a single register)
  telegram[1].u16RegAdd = 0; // start address in slave
  telegram[1].u16CoilsNo = 3; // number of elements (coils or registers) to read
  telegram[1].au16reg = au16data+4; // pointer to a memory array in the Arduino


  master.begin(9600); // baud-rate at 9600
  master.setTimeOut(2000); // if there is no answer in 5000 ms, roll over
  u32wait = millis() + 1000;
  u8state = u8query = 0;
  int modbusEvent = modbusTimer.every(500, getModbusData);  // Every 500mSec


void loop() {

  // Handle modbus timer


void getModbusData()
  switch( u8state ) {
    case 0:
      master.query( telegram[0] );
      master.query( telegram[1] );
      //master.query( telegram[u8query] ); // send query (only once)
      if (u8query > TOTAL_TELEGRAMS) u8query = 0;
    case 1:
      master.poll(); // check incoming messages
      if (master.getState() == COM_IDLE) {
        u8state = 0;

Mark Leyden
Mark Leyden
| 2 1 2
Answered on 8/31/15, 9:22 PM

Thanks that's great I have a Modbus master server that I just need modbus slaves to communicate over tcp. I need several connections in a single ahu.

on 8/31/15, 11:38 PM

Could this work as a Modbus slave?

on 11/28/15, 3:49 PM

Your answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

Ask a Question

Keep Informed

About This Forum

This community is for professionals and enthusiasts of our products and services.

Read Guidelines

Question tools

12 follower(s)


Asked: 8/31/15, 2:05 AM
Seen: 4056 times
Last updated: 8/31/15, 9:22 PM