You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/hardware/05.pro-solutions/solutions-and-kits/opta/tutorials/getting-started-with-rs485/content.md
+15-19Lines changed: 15 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
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"
4
4
difficulty: beginner
5
5
tags:
6
6
- Getting started
@@ -19,14 +19,14 @@ hardware:
19
19
20
20
## Overview
21
21
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.
23
23
24
24
## Goals
25
25
26
26
- 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
30
30
31
31
### Required Hardware and Software
32
32
@@ -41,13 +41,11 @@ The Arduino Opta® is equipped with the industry standard RS485 interface. Makin
41
41
42
42
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).
43
43
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.
45
45
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
47
47
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.
51
49
52
50
Here are some important functions in the sketch:
53
51
@@ -60,9 +58,7 @@ Connect the sender and receiver Opta according to the image shown below.
60
58
61
59

62
60
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
66
62
67
63
Let's start by uploading the sender sketch to the device you want to designate as the sender device.
68
64
@@ -91,7 +87,7 @@ void loop() {
91
87
```
92
88
93
89
94
-
### Modbus RTU RS485 Receiver Sketch
90
+
### UART RS485 Receiver Sketch
95
91
96
92
Some important functions in the receiver sketch:
97
93
@@ -149,7 +145,7 @@ void changeRelay(){
149
145
150
146
### Testing Out the Sketches
151
147
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.
153
149
154
150
The values the device can receive and the result:
155
151
@@ -160,12 +156,12 @@ The values the device can receive and the result:
160
156
161
157
## Conclusion
162
158
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.
164
160
165
161
### Next Steps
166
162
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.
168
164
169
165
If you wish to incorporate connectivity in your Opta solutions, have a look at the [Connectivity on Opta tutorial]().
170
166
171
-
If you are interested in seeing the RS485 protocol being put to work in a reallife 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