4.66 out of 5
195 reviews on Udemy

How to Program an Arduino as a Modbus RS485 Master & Slave

Learn how to create your own Modbus RS485 Master and Slave Device using the Arduino Uno Development System
Emile Ackbarali
829 students enrolled
English [Auto-generated]
Understand the Arduino Uno and RS485 Shield from a Hardware persepctive
Connect an Arduino RS485 Shield to an Arduino Uno
Connect an Arduino Uno to a Hitachi HD44780 LCD display
Use the Arduino IDE to develop applications for the Arduino Uno
Write an Arduino Sketch application to display messages on an LCD display
Write an Arduino Sketch application to implement a Modbus Master
Test an Arduino Modbus master using the Modsim32 Modbus slave simulator
Write an Arduino Sketch application to implement a Modbus Slave
Test an Arduino Modbus slave using the Modscan32 Modbus master application

If you work in the Automation Industry, you will know that automation equipment is very expensive. And many a time, especially for small applications, you simply cannot justify the use of very expensive equipment. 

This is where the Arduino comes in! 

The Arduino development board allows you to create very simple, but very powerful, Modbus master or slave devices through the use of relatively simple “C” programming. With the Arduino, you have full custom control over the program design allowing you to create very lean and very efficient devices for very specific purposes. 

Put simply, mastering Modbus on the Arduino is going to take your skill level and value in the Automation Industry to a whole new level. 

That is what this course is going to do. At the end of the course, you will know how to:

1. Choose the appropriate Arduino hardware.

2. Interconnect Arduino hardware with other add-on hardware.

3. Write “C” applications to implement Modbus master and slave functionality.

4. Use software and hardware to test each application that you write.

All of the programs written in the course are freely downloadable and give you a perfect starting point for further development. At the end of the course, you will have the knowledge to create your own products, your own custom Modbus master and slave hardware.

Looking forward to seeing you on the inside!


Adjust This Setting For Best Video Quality

The Hardware We Will Be Using

The Hardware List

The hardware that is used in the course is listed and their purpose given.

The Arduino Uno

An overview of the Arduino Uno.

The RS485 Shield for Arduino Uno

An overview of the RS485 shield for Arduino Uno.

The LCD Display and Interconnecting Hardware

An overview of the LCD display and Interconnecting Hardware.

The USB-to-RS485 Converter and Connection Overview

An overview of the USB-to-RS485 converter as well as the basic connection of the hardware.

Hardware Setup on my Workbench

A look at the physical hardware set up.

The Software We Will Be Using

The Arduino Programming Software

This lecture shows where to go on the web to download and install the free Arduino programming software.

The Modbus Libraries

Modbus Libraries are used to simplify the implementation of the Modbus protocol on the Arduino.

Modsim32 Modbus Slave Simulator

Modsim32 is a Modbus slave simulation application. It will be used to provide data values that will be read by the Windows Modbus Master application.

Quick Start - Creating our First Arduino Modbus Master Application

A look at the Programming Software - Arduino IDE

The Arduino IDE is briefly introduced.

Our First Program - Testing the LCD Display

A built in application is used as the first application and also to test the LCD display.

Getting the LCD to display the value of a Variable

The code is modified to display the value of a variable on the LCD display.

Additional LCD Code to support Modbus Master Operation

Additional LCD code is added to update the LCD display only on data changes.

Adding Code to Implement Modbus Master Functionality
Running our First Arduino Modbus Master Application

Using the laptop with Modsim32 as a Modbus Slave, the Arduino application is run and tested.

Extending the Arduino Modbus Master Application

Review of the Current Application Code

Quite a bit of coding was done very quickly in the last section. This lecture reviews all of the code so as to solidify the function of the various commands.

Adding Code to Read a Holding Register

Code is added and the application updated to be able to read a holding register.

Adding Code to Read an Input Status

Code is added and the application updated to be able to read an input status.

Adding Code to Read a Coil

Code is added and the application updated to be able to read a coil.

Configuring the Arduino to Read/Display Data from a Modbus Temperature Sensor

What we are going to do in this Section

An overview of the details of the section.

How to Acquire the Sensor

We have a look at the website from which the sensor was purchased.

A Look at the Datasheet for the Sensor

We look at the datasheet for the sensor to determine the communication details.

The Arduino and Sensor setup on my Workbench
Writing the Arduino Code to Read Data from the Temp/Humidity Sensor
Testing the Arduino Program
Modification of Code to Display Decimal Places

Configuring the Arduino to Write Modbus Data to the Slave

Adding Code to Write to a Modbus Coil based on a Condition

Code is added to an existing Arduino program to write to a Modbus Coil based on the value in an Input Register.

Testing of the Write Modbus Function using Modsim32

The new code added in the previous video is testing using Modim32 as the Modbus Slave.

Configuring the Arduino as a Modbus Slave Device

Installing the Modbus Slave Arduino Library

The previously downloaded Modbus Slave Library is installed into the Arduino IDE.

Implementing the Arduino Modbus Slave and Testing Read Functionality

Code is written to implement the Modbus Slave in the Arduino and then Modscan32 is used to read Modbus data.

Implementing the Arduino Modbus Slave and Testing Write Functionality

The code from the previous lecture is modified to test the write functionality of the slave. Modscan32 is used to write to the Arduino slave. 

How To Purchase My Other Courses for ONLY $9.99 Each

Bonus Lecture: Get Any of My Other Courses for $9.99 Each Using This Coupon Code

What to do next to keep further solidify learning.

You can view and review the lecture materials indefinitely, like an on-demand channel.
Definitely! If you have an internet connection, courses on Udemy are available on any device at any time. If you don't have an internet connection, some instructors also let their students download course lectures. That's up to the instructor though, so make sure you get on their good side!
4.7 out of 5
195 Ratings

Detailed Rating

Stars 5
Stars 4
Stars 3
Stars 2
Stars 1
30-Day Money-Back Guarantee


3 hours on-demand video
Full lifetime access
Access on mobile and TV
Certificate of Completion