In this blogpost, we are going to showcase how to connect the inexpensive Modbus Serial RTU temperature and humidity sensor, the XY-MD02.
We are going to connect the XY-MD02 to an enterprise Industrial IoT platform running on the edge of floor-plants based on N3uron running on balena.
Hardware needed
- Intel NUC i7
- USB stick to flash the operating system of the Intel NUC.
- USB RS485 converter (for this I used the Greluma ââZL013LUM)
- XY-MD02 Modbus sensor
Software needed
- A free balenaCloud account. Remember: your first 10 devices are free and fully-featured.
- Software to flash the Intel NUC computer. E.g. balenaEtcher
Deploy the Industrial Edge Gateway code
First of all, we are going to deploy the N3uron service along with HiveMQ and MongoDB as an Historian database on balena.
Find here the Github repository of n3uron with balena and click the blue button Deploy with balena
. Follow the steps and enjoy the magic of the over-the-air updates with balena.
Open another tab and type the https://
and your local ip address (copy it from the balenaCloud dashboard). That should redirect you to the login page of n3uron in your local machine.
Login using admin
as User and n3uron
as a Password.
Access to the Modbus Data from N3uron
In my case the XY-MD02 is connected to the machine via USB with a RS-485 to USB converter. If you have a similar configuration follow the next steps.
Go to the Navigation
menu, on System
and click Config
.
Click the Modules
and then click on the tiny blue button next to Models
. And click New model
.
Add a name such as Modbus
. And select the Module Type
as a Modbus Client
. Click Save
.
With this you defined a Connection Layer as a Modbus Client. Now it's time to configure the connection from N3uron to the device and specify the data it's going to collect.
On the second menu, you are going to see the Modbus
module you just created but some elements (Logging
and API
), click on them and click the Save
button.
Click on Modbus
and a new menu will appear, click on the tiny blue button next to Model
and create a New Channel
.
In this case the XY-MD02 Modbus device is connected through the /dev/ttyUSB0
.
Now go to Tag
on the Explorer Menu and we will create the Temperature
and Humidity
tags to gather the data generated by the Modbus sensor. On of the most tricky thing is that the Modbus address to read the Temperature of the XY-MD02 is 30002
and Humidity is the 30003
and they are Int16
. Have this in mind when you fill the gaps.
Afterthat you will be able to see data on the Real Time
option.
I hope this will help you to configure a Modbus Serial device on N3uron using a balena gateway.
Feedback
The balena platform is all about reducing friction for fleet owners. As always, let us know if you run into any issues when following this guide or getting the Industrial IoT gateway reference architecture set up in your factory or industry plant floor.
Feel free to add a comment below or contact us on the balena forums.
Top comments (0)