Skip to main content

ECU-1051 Setup Guide: Advantech Gateway to Cloud via MQTT

Configure the Advantech ECU-1051 in EdgeLink Studio and publish its I/O tags to Ubidots over MQTT: project setup, tags, MQTT settings and troubleshooting.

Written by Sergio M

The Advantech ECU-1051 is an industrial IoT gateway that publishes its I/O tags over MQTT. This guide configures it in EdgeLink Studio and sends those tags to Ubidots, where each tag becomes a variable on the same device.

Requirements

1. Set up the Gateway and the Development Environment

  • Connect the ECU-1051 to the power supply.

  • Connect the ECU-1051 to your router (LAN) using an Ethernet cable.

  • Download and install Advantech EdgeLink Studio from the link provided at the Requirements section.


Pro Tip: Each LAN port on the gateway has a status LED which will confirm if the device is correctly connected to the router and if it's correctly powered.


2. Create the Project

Open Advantech EdgeLink Studio utility. Look for the icon that resembles a computer screen at the bottom left side of the screen, click on it and then head to the "Search" option:

Once the gateway has been found, the utility will display it along with its IP address. Copy this address to use it later. It will look like this:

Head to the icon that resembles a hammer and then head to the upper left corner to the "Create Project" option; a window will pop up where you should put your project's name, author and description, while leaving the path on its default setting. When you are done filling the fields, hit the "OK" button to save the changes.

The project will then be displayed at the "Project Configuration" tab. Right click on it and then click "Add Device".

Then a new window will pop up where you'll have to set the following parameters:

  • Name: Name of the current project.

  • Model: Select ECU-1051TL-R10A from the list that will be displayed.

  • Password: Do not change anything on this field.

  • Identity: Change from "Node ID" to "IP address".

  • IP Address: Enter the IP address that you copied earlier (when searching for the device).

  • Time Zone: Set the time zone according to your geographical position.

  • Description (optional): Set a meaningful description for your project.

When you are done, hit the "Apply" button in order to save the changes.

The following two pictures depict the steps mentioned above:

As you'll notice, all of the project's folders are now displayed at the "Project Configuration" tab:

3. Create the I/O Tags to Send Simulated Data

This guide will simulate three different devices transmitting data to the gateway by making use of the "User Tag" functionality: a temperature sensor, a humidity sensor and an engine's status.

In order to do so, head to "Data Center" → "User Tag" → "Add...". There, you are going to set:

  • Name: boilerTemperature

  • Data Type: Analog.

  • Initial Value: You can set any value.

  • Read/Write: Leave this option as it is by default.

  • Description: This is optional.

After filling the fields, hit the "Ok" button to save the changes.


[Optional]

Create the other two variables:

Variable name

Data Type

motorStatus

Discrete

boilerHumidity

Analog

You can set whatever initial value you wish and also leave "Read/Write" as it is.


4. Send data to Ubidots

It's now time to manipulate the endpoint to which the gateway is publishing in order to parse the data. Head to your Ubidots account → "Dev Center" → "Functions" and create a new UbiFunction by clicking on the "+" icon. The windows should look like this:

Edit the function's name to "mqttadvantech", set the "Method" to POST, select "Python 3.14 Lite" as runtime and on the "Token" section set "Default Token". Lastly, delete all the code and paste the following one taking into account that you should edit the "token" variable to match your Ubidots Token:

import json
import requests
from datetime import datetime as dt

BASE_URL = "https://industrial.api.ubidots.com"
token = 'PUT-YOUR-TOKEN-HERE'

def main(args: dict = {}):

payload = args["payload"]
if isinstance(payload, str):
payload = json.loads(payload)
data = payload["d"]
date_str = payload["ts"]
timestamp = int(dt.strptime(date_str, "%Y-%m-%dT%H:%M:%S%z").timestamp()*1000)
device_label = args["topic"].split("/")[4]
payload = parse_advantech_data(data)

print(device_label)
res = send_data(device_label, payload, token, **{"timestamp":timestamp})
return {"status": res.status_code, "text": res.text}

def parse_advantech_data(data):
payload = {}
for tag in data:
var_label = tag["tag"]
value = tag["value"]
payload[var_label] = {
"value": value
}
return payload

def send_data(device, payload, token, **params):
url = f"{BASE_URL}/api/v1.6/devices/{device}/"
headers = {"X-Auth-Token": token, "Content-Type": "application/json"}
res = make_request("post", url, headers=headers, params=params, body_json=payload, attempts=5)
return res

def make_request(
method,
url,
params=None,
headers=None,
body=None,
body_json=None,
attempts=1,
timeout=10,
):
"""
Function to make a request with timeout and retries
"""

req_session = requests.Session()
req_adapter = requests.adapters.HTTPAdapter(max_retries=attempts)
req_session.mount("https://", req_adapter)

response = req_session.request(
method=method.upper(),
url=url,
params=params,
headers=headers,
data=body,
json=body_json,
timeout=timeout,
)

req_session.close()
response.raise_for_status()

return response

5. Configure the MQTT

The next step is to configure the MQTT parameters and in order to do so, head to "Cloud" → "SimpleMQTT". Then a new tab will pop up and, in it, you'll have to scroll down and edit the following settings:

  • Enable: Mark the checkbox in order to enable MQTT settings.

  • Host: functions.ubidots.com

  • User Name: Your Ubidots account username.

  • Password: Your Ubidots Token.

  • Data Topic: /prv/<your-ubidots-username>/mqttadvantech/gatewayadvantech

  • Publish period: Any publishing period that you wish, keep in mind that this variable is expressed in seconds.

After filling all the mentioned fields, head to "Tag Name" and, just below it, you'll find a text displaying "Double click to edit". Do as it says and then a screen will prompt you to select which tags are going to be published through MQTT: get to the "User Tags" section and select all the tags that you created for this purpose, then hit the "OK" button and then "Apply".

As stated before, this guide emulates three different variables, so this part might differ a little to yours:

After applying the MQTT settings, you can collapse all of the project's sub-folders while leaving the gateway selected. Then hit "Save", followed by "Project Download" in order to burn the firmware to the gateway:

The following window will pop up. In it, select "Force Download", hit "Download" and the firmware will start to be loaded onto the gateway. A pop-up might ask you about installing aditional hardware drivers, accept it and let the uploading finish.

6. Visualize Data on Ubidots

Head over to the "Devices" section in your Ubidots account, where you'll see a device labeled "gatewayadvantech" with data being ingested.

How do I send real PLC or Modbus data instead of simulated tags?

This guide uses User Tags so you can test without field wiring. For a real installation, add your PLC or Modbus device to the project in EdgeLink Studio and create I/O Tags for its registers. Then, in the SimpleMQTT Tag Name list, select those I/O Tags instead of the User Tags.

The UbiFunction doesn't change: each tag the gateway publishes becomes a variable on the same Ubidots device. For a worked Modbus TCP example, see EdgeLink Studio Modbus TCP Setup: ECU-1051 and ADAM-6717.

Troubleshooting: why is no data reaching Ubidots?

  • The gateway doesn't show up in EdgeLink Studio's search. Check the LAN port's status LED, and check that the PC and the gateway are on the same network.

  • No device appears in Ubidots. Check the SimpleMQTT settings: Host functions.ubidots.com, User Name your Ubidots username, Password your token. The Data Topic must be /prv/<your-ubidots-username>/<function-label>/<device-label>, with the function label exactly as it appears in your function's endpoint URL. The function takes the device label from the last level of the topic.

  • The function runs but no values are saved. Open the function's logs. A 401 or 403 response means the token in the code is wrong. A date error means the gateway's clock or time zone isn't set: the function expects the ts field in a format such as 2024-01-31T12:00:00+0000.

  • Some values are missing. Check that every tag you want is selected in the SimpleMQTT Tag Name list. Also check the Publish period, which is in seconds.

Other Advantech guides

Did this answer your question?