To integrate the XY-MD02 sensor you need a tool that read Modbus protocol. This protocol is widely used in the industrial sector to facilitate communication between devices, particularly sensors and controllers. The XY-MD02 is a sensor that measures temperature and humidity and utilizes the Modbus RTU protocol. The sensor can be easily installed using a standard RS485 connection, and it is compatible with most Modbus master devices, such as programmable logic controllers (PLCs) and industrial PCs.
Node-RED is a tool that supports various protocols, including Modbus, and allows users to create and deploy visual applications for IoT devices. By using Node-RED with balena, the Industrial IoT Edge Gateway can be created, which is an easy-to-deploy application.
This makes it accessible to a wide range of users, including those who do not have coding experience. By connecting the XY-MD02 sensor to the Industrial IoT gateway using balena and a USB RS485 converter, users can easily access and integrate data from the sensor into their system, making it a valuable tool in the industrial and automation industries.
Find below the connection diagram between the XY-MD02 sensor and the RS485 to USB converter.
- 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
- A free balenaCloud account. Remember: your first 10 devices are free and fully-featured.
- Software to flash the Intel NUC computer. E.g. balenaEtcher
Click the `Deploy with balena` button to create a fleet on balenaCloud. Find the repository of the application on github.
You can follow all the instructions to deploy the Industrial iot edge gateway from this step-by-step tutorial.
Connect the XY-MD02 Modbus sensor on NodeREDThe sensor should be connected to a USB port of your Intel NUC before you power up the device.
Go to NodeRED on the port 80 of your local ip address and use `balena` and `balena` as credentials.
Select the `Modbus Reader` node and the `Debug` node.
To configure the `Modbus Reader` node, double click on it. Select the FC `FC 4: Read Input Registers` for this case on `Address` 1 and `Quantity` 2. I selected a `Poll Rate` every 2 seconds (feel free to change the poll rate).
Click on the `Server` edit button to `Add new modbus-client`.
Select `Type` as `Serial`. The `Serial Port` is `/dev/ttyUSB0`. The `Serial type` is `RTU-BUFFERED` and the `Baud rate` is 9600.
Update the Modbus read client node and click Deploy. You should see the Modbus Reader node `connected` and active.
Parse the dataTo parse the data coming from the XY-MD02 modbus sensor we will add a function that will get the data coming from the array resulting from reading the modbus data, and we will divide by 10 the number.
The temperature is in celsius degrees and the humidity is in %.
In case this is not existing go to balenaCloud, open the terminal on HostOS and type `ls /dev/ttyUSB*` and check what you see as a result.
If you don’t see any ttyUSB0 or anything else as a result, you might have a problem with the USB connection. Feel free to write to us on the balena forums to learn more about your case.
Comments
Please log in or sign up to comment.