Skip to content

Commit 09f891b

Browse files
authored
Merge pull request #250 from arduino/jcarolinares/opta-rs485-tutorial
Tutorial updated to be adapted only for the RS485 communication
2 parents fff49f7 + 535101a commit 09f891b

File tree

1 file changed

+15
-19
lines changed
  • content/hardware/05.pro-solutions/solutions-and-kits/opta/tutorials/getting-started-with-rs485

1 file changed

+15
-19
lines changed

content/hardware/05.pro-solutions/solutions-and-kits/opta/tutorials/getting-started-with-rs485/content.md

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: 'Getting Started with Modbus RTU and RS485 on Arduino Opta'
3-
description: "Learn how to make use of the Arduino Opta's Modbus RTU RS485 protocol"
2+
title: 'How To Use Serial Communication Using RS485 On Arduino Opta'
3+
description: "Learn how to create a serial communication between two Optas using RS485"
44
difficulty: beginner
55
tags:
66
- Getting started
@@ -19,14 +19,14 @@ hardware:
1919

2020
## Overview
2121

22-
The Arduino Opta® is equipped with the industry standard RS485 interface. Making use of this feature is made easy with the help of the Arduino IDE and the [ArduinoRS485 library](https://www.arduino.cc/reference/en/libraries/arduinors485/). This tutorial will go through the steps to get the Modbus RTU protocol up and running using two Optas connected via RS485 and the Arduino IDE. Going through some important functions in the library and show an example sketch that makes use of the library and RS485 interface.
22+
The Arduino Opta® is equipped with the industry standard RS485 interface. Making use of this feature is made easy with the help of the Arduino IDE and the [ArduinoRS485 library](https://www.arduino.cc/reference/en/libraries/arduinors485/). This tutorial will go through the steps to get the serial communication up and running using two Optas connected via RS485 and the Arduino IDE. Going through some important functions in the library and show an example sketch that makes use of the library and RS485 interface.
2323

2424
## Goals
2525

2626
- Learn how to connect two Optas for RS485 communication
27-
- Run a Modbus-RS485 sender sketch on Opta
28-
- Run a Modbus-RS485 receiver sketch on Opta
29-
- Learn how to send values using the Modbus RTU protocol and the RS485 interface
27+
- Run a RS485 sender sketch on Opta
28+
- Run a RS485 receiver sketch on Opta
29+
- Learn how to send values using the UART protocol and the RS485 interface
3030

3131
### Required Hardware and Software
3232

@@ -41,13 +41,11 @@ The Arduino Opta® is equipped with the industry standard RS485 interface. Makin
4141

4242
First make sure the latest version of the Arduino IDE is installed. Download the IDE from [here](https://www.arduino.cc/en/software) if you need help setting up the Opta with the Arduino IDE, please have a look at our [Getting started with Opta tutorial](/tutorials/opta/getting-started).
4343

44-
To make it easier to use the RS485 protocol with Opta let's make use of a library. The library is called [ArduinoRS485 library](https://www.arduino.cc/reference/en/libraries/arduinors485/), which can be found in the Arduino IDE library manager. Once installed let's take a look at a simple sketch to use for testing out the Modbus RTU protocol.
44+
To make it easier to use the RS485 protocol with Opta let's make use of a library. The library is called [ArduinoRS485 library](https://www.arduino.cc/reference/en/libraries/arduinors485/), which can be found in the Arduino IDE library manager. Once installed let's take a look at a simple sketch to use for testing out the UART protocol.
4545

46-
If you want a more in-depth article that explains the entirety of what a Modbus and RS485 protocol is, take a look at our [Modbus article](https://docs.arduino.cc/learn/communication/modbus).
46+
### Using RS485 on Opta
4747

48-
### Using Modbus RTU on Opta
49-
50-
The sender sketch will run a RS485 connection between your two devices and it will let you send a message over the serial monitor to the receiving device. The receiving device, which will be a Opta in this example, will then take the message, open or close the corresponding relay and turn on or off a LED. If you send the number 0 through the serial monitor, the receiving Opta will open or close relay 1 depending on it's current status, while turning on or off a status LED.
48+
The sender sketch will run a RS485 connection between your two devices and it will let you send a message over the serial monitor to the receiving device. The receiving device, which will be an Opta in this example, will then take the message, open or close the corresponding relay and turn on or off a LED. If you send the number 0 through the serial monitor, the receiving Opta will open or close relay 1 depending on its current status, while turning on or off a status LED.
5149

5250
Here are some important functions in the sketch:
5351

@@ -60,9 +58,7 @@ Connect the sender and receiver Opta according to the image shown below.
6058

6159
![Connecting RS485 on Opta](assets/opta-modbus-connection.png)
6260

63-
***Modbus RTU communication is supported using Opta's RS485 physical interface. Note that Opta does not have internal terminator resistors so they need to be added if necessary following the Modbus protocol specification.***
64-
65-
### Modbus RTU RS485 Sender Sketch
61+
### UART RS485 Sender Sketch
6662

6763
Let's start by uploading the sender sketch to the device you want to designate as the sender device.
6864

@@ -91,7 +87,7 @@ void loop() {
9187
```
9288

9389

94-
### Modbus RTU RS485 Receiver Sketch
90+
### UART RS485 Receiver Sketch
9591

9692
Some important functions in the receiver sketch:
9793

@@ -149,7 +145,7 @@ void changeRelay(){
149145

150146
### Testing Out the Sketches
151147

152-
Now that both sketches has been uploaded to the devices. Plug in the USB to the sender device, make sure the receiver device is powered and then open the serial monitor in the Arduino IDE. With the serial monitor open send a value between 0-3 in the serial monitor to the sender device. Sending a 0 should open the first relay and turn on the first status LED, from left to right. Sending a 0 again will close the relay and turn off the LED.
148+
Now that both sketches have been uploaded to the devices. Plug in the USB to the sender device, make sure the receiver device is powered and then open the serial monitor in the Arduino IDE. With the serial monitor open send a value between 0-3 in the serial monitor to the sender device. Sending a 0 should open the first relay and turn on the first status LED, from left to right. Sending a 0 again will close the relay and turn off the LED.
153149

154150
The values the device can receive and the result:
155151

@@ -160,12 +156,12 @@ The values the device can receive and the result:
160156

161157
## Conclusion
162158

163-
In this tutorial we went through how to establish a Modbus RTU connection between two Optas. And then how to write sketches using the `ArduinoRS485.h` library to send and receive values between these two devices. Finally the tutorial showed how to take these values sent with RS485 to interact with the Opta.
159+
In this tutorial we went through how to establish a serial communication between two Optas using the RS485 connection, learning how to write sketches using the `ArduinoRS485.h` library to send and receive values between these two devices. Finally, the tutorial showed how to take these values sent with RS485 to interact with the Opta activating its relays and LEDs accordingly.
164160

165161
### Next Steps
166162

167-
Now that you are familiar with the Modbus RTU communication protocol on the Opta, have a look at our [Getting started with Opta tutorial]() to get a better overview of other features on the device.
163+
Now that you are familiar with the R485 on the Opta, have a look at our [Getting started with Opta tutorial](../getting-started-with-rs485/content.md) to get a better overview of other features on the device.
168164

169165
If you wish to incorporate connectivity in your Opta solutions, have a look at the [Connectivity on Opta tutorial]().
170166

171-
If you are interested in seeing the RS485 protocol being put to work in a real life scenario, have a look at our [Tank levels application note for the Opta]().
167+
If you are interested in seeing the RS485 interface, used with the Modbus protocol, being put to work in a real-life scenario, have a look at our [Tank levels application note for the Opta]().

0 commit comments

Comments
 (0)