Using SMS API to Command MiniLink Gateway 3.0 on 1NCE Platform Without Coding.

--

By: Visit Wiangnak
Date: August 26, 2024

This article demonstrates the use of the MiniLink Gateway Version 3.0 to read temperature and humidity sensor data via the RS485 port using the Modbus RTU protocol. It showcases how to configure the board remotely through the 1NCE platform’s SMS API over 4G/LTE networks across more than 177 countries without writing any code. The process can be adapted to other types of sensors as needed.

Equipment Used for Testing

1. MiniLink IIoT Gateway Version 3.0
Detailed specifications: MiniLink IIoT Gateway Version 3.0

Figure 1: MiniLink IIoT Gateway Version 3.0 Board
Figure 2: Enclosure of MiniLink IIoT Gateway version 3.0

2. Temperature and Humidity Sensor XY-MD02

Figure 3: XY-MD02 Temperature and Humidity Sensor

3. mPCIe SIM7600E Card Supporting 4G/LTE

Figure 4: mPCIE SIM7600E Card Supporting 4G/LTE Network

Setup and Preparation

The MiniLink Gateway Version 3.0 board was connected to the XY-MD02 temperature and humidity sensor via the RS485 port. External power was supplied using a 12V DC adapter. The MiniLink board was powered through its USB-C port.

Figure 5: Sensor Connection to the Board

Upon powering the devices, the MiniLink board’s LEDs illuminated, indicating successful initialization. The mPCIe SIM7600E card then searched for a 4G/LTE network, taking 10–20 seconds to connect successfully.

Figure 6: LED Status Indicators on the Board

Test Setup

In this demonstration, the hardware setup consists of a MiniLink Gateway Board Version 3.0 and three temperature and relative humidity sensors. These sensors are configured to simulate three different usage scenarios and are connected to the board via RS485 ports equipped with isolators and automatic direction control.

On the cloud side, in addition to utilizing the 1NCE platform, a dedicated server has been prepared to receive payloads transmitted from the MiniLink Gateway via the UDP protocol. The Node-RED application is employed to manage connections and decode the received payloads, ensuring seamless data handling and integration for the demonstration.

Figure 7: Network Diagram

Modbus Table for XY-MD02 Sensor

Before diving into the usage of the SMS API, let’s first explore the Modbus RTU data table for the XY-MD02 sensor, a device designed to measure temperature and relative humidity in the air. Understanding this table is essential for configuring and utilizing the sensor effectively in your applications.

Figure 8: Modbus Table of XY-MD02 Sensor

The XY-MD02 air temperature and relative humidity sensor communicates data using the Modbus RTU protocol. It employs Function Code 0x04 (Input Register) to read sensor values. Specifically:

  • Temperature is retrieved from Register Address 0x0001.
  • Relative Humidity is retrieved from Register Address 0x0002.

Each data point is a 2-byte (16-bit) signed integer. To obtain accurate readings, the retrieved values must be divided by 10. This scaling ensures the sensor’s output reflects the correct temperature and humidity measurements in their respective units.

Note:
*StarCommand() is a simple SMS API command that eliminates the need for any coding. By sending commands through the 1NCE platform, users can remotely control and manage the MiniLink board over 4G/LTE networks. This feature supports operations in more than 177 countries, making it a versatile solution for global connectivity and remote device management.

Modbus RTU Data Reading Command

SetModbusCycle0()

Star Command used to instruct the MiniLink board to read sensor data via the RS485 port using the Modbus RTU protocol. The command is structured as follows:

SetModbusCycle0(nid, modbus id, function code, address, quantity)

This command includes five parameters:

  1. nid: The dataset number.
  2. modbus id: The Modbus ID of the sensor.
  3. function code: The function code for the Modbus RTU operation.
  4. address: The address of the device to be accessed.
  5. quantity: The number of data points to be read.
Figure 9: Command Parameters

Example of Command Usage

The command SetModbusCycle0() can be used to instruct the MiniLink board to read data using the Modbus RTU protocol. In this example, it reads Dataset 1 from a sensor with a Modbus ID of 10. The command uses the Input Register function (Function Code 0x04) to start reading from the first register address at 0x01, retrieving a total of 2 addresses. The syntax is as follows:

*SetModbusCycle0(1,10,4,1,2)

Command for Configuring Data Transmission:

*SetIPCycle0()

This Star Command is used to configure the MiniLink board to transmit Uplink Payload data to a specified server’s IP address using a designated protocol.

The default communication protocol is UDP, but other protocols such as TCP or MQTT can also be selected. The command format is as follows:

*SetIPCycle0(IP, Port)

This command has two parameters:

  • IP: The destination server’s IP address.
  • Port: The service port number for the communication protocol.

Example of Using the Command:

The command SetIPCycle0() is used to instruct the MiniLink board to send data to a server with the IP address 10.0.0.1 and port 123456, using the default protocol (UDP Protocol).

*SetIPCycle0(10.10.10.1, 123456)

1NCE Platform for Sending SMS API

After learning how to use the StarCommand() function to instruct the MiniLink board to read data via the Modbus RTU protocol and configure communication with the destination server, the next step involves demonstrating how to send commands to the MiniLink board via SMS API on the 1NCE platform using 4G/LTE internet connectivity.

To begin, visit the website https://portal.1nce.com and log in using the provided Username and Password.

Figure 10: Login Screen of the 1NCE Platform

Once you are on the Dashboard, click the “My SIMs” menu at the top. Then, search for and click on the desired SIM number. The system will display various details related to the active SIM.

Click on the “SMS” menu to access a window displaying details about the SMS functionality.

Figure 11: SMS Details Page

Example of Usage:

Setting Up Data Transmission

To configure the MiniLink board to send data to a server with the IP address 10.10.10.1 and port number 123456 using the default UDP protocol, use the *SetIPCycle0() command.

Type the command *SetIPCycle0(10.10.10.1, 123456) in the Payload field, then click the “Send” button to transmit the data.

Figure 12: Console Log Window of the Board

After successfully sending the message, the Console Log window of the MiniLink board will display the details of the received SMS message. At this point, the MiniLink board is ready for use. By default, the communication protocol is set to UDP, and the data transmission cycle is set to every 5 minutes.

Example Case 1: Reading Data from One Temperature Sensor

Figure 13: Network Diagram of Test Case 1

In this example, the user will instruct the MiniLink board to read data from one temperature and humidity sensor (XY-MD02) using the Modbus RTU protocol. The communication will be set up through the RS485 serial port with a baud rate of 9600 bps (8N1).

The sensor is configured with a Modbus ID of 10 and uses the Input Register (Function Code 0x04). The data reading begins from the first register address (0x01) for 2 registers. The board will then send the data through the 4G/LTE network to a UDP server every 5 minutes, as per the default setting.

To send the command, type the StarCommand() into the Payload field and click the Send button.

*SetModbusCycle(1,10,4,1,2)
Figure 14: SMS Details Log

After the message is successfully sent, the Console Log window of the MiniLink board will display the details of the received SMS message. The MiniLink board will then begin reading data from the sensor as instructed and send the information to the UDP Server on the Cloud.

When reviewing the results in the Node-RED program, where the author has set up a UDP Server, it can be observed that a msg.payload in Buffer format is received every 5 minutes.

Figure 15: Node-RED Flow and Console Log

The msg.payload displayed on Node-RED needs to be decoded before it can be interpreted. To achieve this, the author created a flow and wrote a function to convert the data into a more readable format. Specifically, the temperature and humidity values must be divided by 10 to obtain the correct values.

Figure 16: Node-RED Flow and Function Script
Figure 17: Node-RED Console Log

The data obtained from decoding the payload will be in JSON format, ready for storage in a real-time database such as InfluxDB.

Example Case 2: Reading Data from Two Temperature Sensors with the Same Data Transmission Interval

Figure 18: Network Diagram of Test Case 2

In this example, the author will configure the MiniLink board to read data from two temperature and humidity sensors (XY-MD02) using the Modbus RTU protocol. The communication is set up through a Serial RS485 port with a baud rate of 9600 bps (8N1).

The first sensor is assigned Modbus ID = 10, and the second sensor is set to Modbus ID = 1. Both sensors use the Input Register (Function Code 0x04) and start reading data from the first register address (0x01), with two addresses being read. The data is then transmitted via the 4G/LTE internet network to the UDP Server every 5 minutes, as per the default setting.

The command will be entered into the Payload field, and the Send button should be clicked to transmit the command.

*SetModbusCycle0(1,10,4,1,2),(2,1,4,1,2)
Figure 19: SMS Details Log

After successfully sending the message, the Console Log window of the MiniLink board will display the details of the received SMS. The MiniLink board will then begin reading data from both sensors as specified and transmit the information to the UDP Server on the Cloud.

Figure 20: Console Log of the Board

Example Case 3: Reading Data from 3 Temperature Sensors, Each with Different Data Transmission Intervals and Destination Server IP Addresses.

Figure 21: Network Diagram of Test Case 3

In this example, the author will configure the MiniLink board to read data from three temperature and humidity sensors (XY-MD02) using the Modbus RTU protocol. The communication will be set up over a Serial RS485 port with a baud rate of 9600 bps (8N1).

To read the sensor values, the Input Register (Function Code 0x04) will be used, starting from the first register address (0x01) for 2 addresses. The data will then be transmitted over the 4G/LTE network to a UDP server.

The device configuration is as follows:

  • First sensor: Set Modbus ID = 10
  • Second sensor: Set Modbus ID = 1
  • Third sensor: Set Modbus ID = 2

Data Transmission Intervals:

  • First and second sensors: Send data every 5 minutes (default setting)
  • Third sensor: Send data every 3 minutes

Data Destination Configuration:

  • First and second sensors: Send data to a server with IP Address 10.10.10.1 and port 123456 using the UDP protocol
  • Third sensor: Send data to a server with IP Address 20.20.20.1 and port 456123 using the UDP protocol

Based on these settings, the author will generate the corresponding *StarCommand() instructions to direct the MiniLink board to operate as specified. The commands will be entered into the Payload field, and each command will be sent by clicking the “Send” button one at a time.

*SetIPCycle0(10.10.10.1, 123456)
*SetModbusCycle0(1,10,4,1,2),(2,1,4,1,2)

*SetIPCycle1(20.20.20.1, 456123)
*SetTimeCycle1(180000)
*SetModbusCycle1(1,3,2,4,1,2)

Conclusion on Usage

The MiniLink Gateway Version 3.0 for IIoT applications is a convenient and efficient solution that significantly reduces the time required to develop IoT solutions, without the need for additional coding. The flexible *StarCommand() function allows for easy control of various operations, making it an ideal choice for remote management. In the future, the author plans to present additional functionalities. For those looking for an IoT board that supports 4G/LTE connectivity, the MiniLink board is an excellent option worth considering.

Example of Practical Application of MiniLink Gateway Version 3.0

The Weather Station project is designed to monitor and report critical environmental data such as wind speed, wind direction, rainfall, sunlight intensity, temperature, and relative humidity. The data collected is transmitted via 4G/LTE networks using 1NCE’s eSIM, ensuring fast and reliable data transfer to the cloud system. This solution is ideal for applications in agriculture, environmental management, or remote weather monitoring, providing real-time insights for areas with limited connectivity or infrastructure.

Figure 22: Weather Station

The Water Quality Monitoring Station project is designed to monitor water quality in real-time for industrial applications. Sensors measure various parameters such as pH, TDS (Total Dissolved Solids), and DO (Dissolved Oxygen). The collected data is transmitted via 4G/LTE networks to a cloud system for storage and analysis. This system is ideal for monitoring production processes, quality control, and ensuring compliance with environmental standards. It enables operators to access data remotely, respond quickly to abnormalities, and improve water management efficiency in factories.

Figure 23: Water Quality Monitoring Station in the Factory

The Online Solar Cell Monitoring Station project enables real-time monitoring of the performance and status of solar energy systems. It retrieves data from solar inverters via 4G/LTE network connectivity, then sends the information to a cloud system for analysis and record-keeping. This design is ideal for tracking energy production, minimizing damage from potential issues, and enhancing maintenance efficiency. Additionally, the system supports remote access, making it easier to manage and oversee solar power stations in any location.

Figure 24: Solar Cell System Monitoring Station

The author intends to present the use of IoT, LoRaWAN, and NB-IoT for developing SMART CITY solutions. This presentation aims to inspire those interested in advancing and innovating new technologies in urban development.

Stay updated with the latest news on our website through this link.

--

--

No responses yet