Skip to content

Commit 91ac5e5

Browse files
committed
Update Modbus
1 parent ea41e48 commit 91ac5e5

File tree

4 files changed

+18
-79
lines changed

4 files changed

+18
-79
lines changed
Loading
Loading
Loading

content/arduino-cloud/11.application-notes/modbus-energy-meter/modbus-energy-meter.md

+18-79
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ author: 'Officine Innesto, José Bagur'
1414

1515
If you really want to make your home smarter, you'll probably want start from your monthly bills (for example, energy, gas, etc...). As some say: **good for the planet, the wallet and the bottom line**. In this tutorial, we are going to learn how to connect a Modbus energy meter to the Arduino Cloud IoT using an Arduino® MKR WiFi 1010 board and an Arduino® MKR 485 Shield.
1616

17+
***This tutorial assumes you know the basics of the Arduino Cloud. If you are new check out our [Getting Started Guide](/arduino-cloud/guides/overview).***
18+
1719
## Goals
1820

1921
The goals with this tutorial are:
@@ -72,65 +74,7 @@ Now that we have finished setting up the hardware, it is time to connect our ene
7274

7375
## Setting Up the Arduino Cloud IoT
7476

75-
First, we need to register and configure our MKR WiFi 1010 board in the Arduino Cloud IoT. Let's start by navigating to [Arduino Cloud IoT](https://create.arduino.cc/iot).
76-
77-
***Note: You will need a Arduino account to use the Arduino Cloud IoT. If you do not have one, you will be redirected to the account registration site.***
78-
79-
### Configure a New Device in the Arduino Cloud IoT
80-
81-
Once we are in the Arduino Cloud IoT, we will need to select "**Devices**" tab. This will open a new page which will ask you to add a new device. Click on the "**ADD DEVICE**" button.
82-
83-
![Adding a new device to our Arduino Clout IoT account](assets/modbus-energy-meter_img07.png)
84-
85-
In the set up wizard, we will now have an option of either configuring a new Arduino® device, or a third party device. Let's select the "**Set up an Arduino device**" option.
86-
87-
![Selecting the type of device to set up](assets/modbus-energy-meter_img08.png)
88-
89-
At this point, we will need to connect our MKR WiFi 1010 board to our computer; we will also need to have installed the **Arduino Create Agent** in our computer. If the Arduino Create Agent is not installed, the set up wizard will ask us to install it. Our device should now show up as shown in the image below. Now its time to configure it, let's select the "**CONFIGURE**" button.
90-
91-
![MKR WiFi 1010 board found!](assets/modbus-energy-meter_img09.png)
92-
93-
Now we must name our device. In this case, we named our device as "**EnergyMeter001**"; names can be randomly generated also by the set up wizard. Let's continue by selecting the "**NEXT**" button.
94-
95-
![Naming our MKR WiFi 1010 board](assets/modbus-energy-meter_img10.png)
96-
97-
After selecting the "**NEXT**" button, the set up wizard will start to configure our board. This process may take a few minutes.
98-
99-
![Configuration process of our MKR WiFi 1010 board and the Arduino Cloud IoT](assets/modbus-energy-meter_img11.png)
100-
101-
Once it is done, select the "**DONE**" button, we will be redirected to the "Devices" page. In this page we are going to be able to see our device. Congratulations! The configuration of our board and the Arduino Cloud IoT is done, now we can create a "Thing" with it.
102-
103-
![Configuration process of our MKR WiFi 1010 board and the Arduino Cloud IoT](assets/modbus-energy-meter_img12.png)
104-
105-
### Create a New Thing in the Arduino Cloud IoT
106-
107-
After our board is configured in the Arduino Cloud IoT, we can move on to the next step: creating a "Thing". Let's select the "**Things**" tab and then select the "**CREATE THING**" button.
108-
109-
![Creation of a "Thing" in the Arduino Cloud IoT complete](assets/modbus-energy-meter_img13.png)
110-
111-
We will be redirected to a page with our "Thing" configuration overview. Here we can define our "Thing" name, select to what network we are connecting to, what device we are using with out "Thing" and create variables that we want to to connect from our board to our "Thing" in the Arduino Cloud IoT.
112-
113-
![Overview of a "Thing" in the Arduino Cloud IoT](assets/modbus-energy-meter_img14.png)
114-
115-
Let's start by giving a name to our "Thing" and linking our freshly configured device. We named our Thing as "**Energy Thing**", this can be done by clicking in "**Untitled**". To link out freshly configured device, we select the "**Select Device**" button located to the right. This will open up a window where we can associate a previously configured device with our "Thing" by selecting the "**ASSOCIATE**" button.
116-
117-
![Associating a device to a "Thing" in the Arduino Cloud IoT](assets/modbus-energy-meter_img15.png)
118-
119-
### Creating Variables for a "Thing" in the Arduino Cloud IoT
120-
121-
Now, let's create **variables** for the "Energy Thing". The variables we are going to create will be synced, automatically, with the Arduino Cloud IoT as long as the board is connected to Internet and the Arduino Cloud IoT. Let's create create a new variable by selecting the "**Add Variable**" button.
122-
123-
!["ADD VARIABLE" button in the Arduino Cloud IoT](assets/modbus-energy-meter_img16.png)
124-
125-
This will open up a window where we can create new variables and define its characteristics. The first variable we are going to create will be named "**voltage**"; this variable will have the following characteristics:
126-
127-
- **Variable type**: Floating Point Number.
128-
- **Variable permission**: read only.
129-
- **Variable update policy**: on change (threshold do not changes).
130-
131-
![Adding a variable to the "Energy Thing"](assets/modbus-energy-meter_img17.png)
132-
133-
Repeat this process for the variables and its characteristics shown in the table below:
77+
- Create a **Thing** with the following variables:
13478

13579
| **Variable** | **Type** | **Permission** | **Update Policy** |
13680
|:---------:|:---------------------:|:----------:|:---------------:|
@@ -140,22 +84,15 @@ This will open up a window where we can create new variables and define its char
14084
| frequency | Floating Point Number | Read Only | On change |
14185
| energy | Floating Point Number | Read Only | On change |
14286

87+
![Thing Set up](./assets/configureThing.png)
14388

144-
The created variables should appear now in the "Energy Thing" overview.
145-
146-
![Variables of the "Energy Thing"](assets/modbus-energy-meter_img18.png)
89+
- Set up your [MKR WiFi 1010](https://store.arduino.cc/products/arduino-mkr-wifi-1010) and configure your network credentials.
14790

148-
### Network Credentials for a "Thing" in the Arduino Cloud IoT
149-
150-
Now that we have created the variables for the "Energy Thing", we can configure the network details. This can be done by selecting the "**Configure**" button in the "Network" section. This will open up a window where we can add the network SSID and its password.
151-
152-
![Network credentiales of the "Energy Thing"](assets/modbus-energy-meter_img19.png)
153-
154-
### Creating an Sketch for a "Thing" in the Arduino Cloud IoT
91+
### Creating a Sketch for a "Thing" in the Arduino Cloud IoT
15592

15693
Once we are finished with all the configurations of the "Energy Thing", we can move on to creating the sketch that we are going to upload to our MKR WiFi 1010 board. To do so, we first need to go to the "**Sketch**" tab. But before, let's talk about **Modbus**.
15794

158-
![Sketch tab in the Arduino Cloud IoT](assets/modbus-energy-meter_img20.png)
95+
![Sketch tab in the Arduino Cloud IoT](./assets/openSketch.png)
15996

16097
Modbus is an open source communication protocol designed specifically for industrial sensors and machines. In simple terms, it is a method used for transmitting information over serial lines between electronic devices. Our MKR WiFi 1010 board can talk Modbus using the [Arduino Modbus library](https://www.arduino.cc/en/ArduinoModbus/ArduinoModbus). This library packs all the handlers and makes hooking up any Modbus device to some of the Arduino® boards (like the MKR family boards) really fast and easy. You can read more about Modbus [here](https://en.wikipedia.org/wiki/Modbus).
16198

@@ -417,21 +354,23 @@ To use this feature, make sure the board has power. If your board is already con
417354

418355
### Creating a Dashboard in the Arduino Cloud IoT
419356

420-
After our code has been successfully uploaded to our board, we we will need to create a **dashboard** for **visualizing** the energy meter data. Head over to the "**Dashboards**" tab and click on "Build Dashboard".
421-
422-
![Dashboards tab in the Arduino Cloud IoT](assets/modbus-energy-meter_img21.png)
423357

424-
An empty dashboard will be displayed. After changing the new dashboard's name, for example "Energy Meter Dashboard", let's add widgets to it. Let's click on the "**ADD**" button and select a "**Value**" widget.
425358

426-
![Adding a value widget into a dashboard in the Arduino Cloud IoT](assets/modbus-energy-meter_img22.png)
359+
After our code has been successfully uploaded to our board, we we will need to create a **dashboard** for **visualizing** the energy meter data.
427360

428-
Now, we need to **link** the widget we just added to our dashboard to one of the energy meter variables we defined previously in the "Energy Thing" (voltage, current, power, frequency and energy). This can be done by selecting the "**Link Variable**" button and then selecting the variable you want to link with the widget; let's start with the variable **voltage**; remember also to give a name to the widget.
361+
Create a dashboard with the following widgets:
429362

430-
![Linking a variable to a widget in the Arduino Cloud IoT](assets/modbus-energy-meter_img23.png)
363+
| **Widget** | **Linked Variable** |
364+
|:---------:|:---------------------:|
365+
| Value | voltage |
366+
| Value | current |
367+
| Value | power |
368+
| Value | frequency |
369+
| Value | energy |
431370

432-
Follow the steps described above to link the rest of the variables of the "Energy Thing" to value widgets. We should see now all of the energy meter data being displayed on the dashboard, the data shown should update every `60000` ms when our MKR WiFi 1010 board is connected to the Arduino Cloud IoT.
371+
Your dashboard should look something like this:
433372

434-
![Energy meter data shown in the Arduino Cloud IoT](assets/modbus-energy-meter_img24.png)
373+
![Dashboard](./assets/dashboardWidgets.png)
435374

436375
That's it! You have now a Modbus energy meter connected to the Arduino Cloud IoT!
437376

0 commit comments

Comments
 (0)