This tutorial describes how to activate a gateway, install a driver, and activate a device based on the Tuya Edge Gateway (TEdge). You can also use a simulated device to migrate data to the cloud and send commands from the cloud to control the device.
The Modbus protocol is a standard communication protocol in the industry sector. It provides the most popular connection channels between industrial electrical devices.more
You can follow the instructions in Get Docker to install Docker for your operating system. The following procedure describes how to install Docker on two operating systems:
Create a directory.
sudo mkdir /var/tedge
View the current user.
ps aux | grep docker
Grant the current user the directory permissions.
sudo chown Username /var/tedge
Create the required directories.
sudo -u Username mkdir /var/tedge/res
sudo -u Username mkdir /var/tedge/edgex-db-data
sudo -u Username mkdir -p /var/tedge/edgex-driver-data/upload/library
sudo -u Username mkdir /var/tedge/edgex-driver-data/run_config
Pull and install the modbus-simulator image.
docker run --name "modbus-simulator" --restart=always \
-p 1502:1502 \
-d tuya/modbus-simulator:latest
Get the IP address of the simulated device Docker.
docker inspect --format '{{ .NetworkSettings.IPAddress }}' <Image ID>
Deploy core services.
docker run --name "tuya-edgex" --restart=always \
-p 58880:58880 \
-v /var/tedge/edgex-db-data:/dbdata \
-v /var/tedge/res:/res \
-v /var/tedge/edgex-driver-data/run_config:/run_config \
-v /var/tedge/edgex-driver-data/upload:/upload \
-v /var/run/docker.sock:/var/run/docker.sock \
-d tuya/tedge-server:v1.0
Deploy frontend services.
docker run --name "web-client" --restart=always \
-p 3000:3000 \
-d tuya/tedge-web:v1.0
Download the official driver and package the files for installation (x86/ARMv7).
Note:
save
command.save
command. docker pull tuya/tedge-modbus-driver:v1.0
docker save tuya/tedge-modbus-driver:v1.0 > \
/var/tedge/edgex-driver-data/upload/library/tedge-modbus-driver.tar
You can create a smart product on the Tuya IoT Platform. This section describes how to create a gateway based on the low-code development solution. For more information, see Create Products.
Log in to the Tuya IoT Platform.
On the Standard Category tab, choose Gateway Control > IoT Edge Gateway.
Enter the required information.
Get a list of licenses.
You can create a cloud development project and configure assets and user information for the project on the Cloud Development Platform. When you create a project, set Project Type to Industry Solutions. For more information, see:
Connect to the address IP address of the local host:3000 and log in to the locally deployed edge gateway.
Activate the gateway.
Search the driver library by name. Fuzzy matching is supported. Create a driver instance.
On the list of driver instances, click Stopped next to the newly created driver instance to run the driver.
Create a sub-device on the Tuya IoT Platform.
On the Standard Category tab, choose Electrical > Socket > Custom Solution.
Add the data points (DPs) Switch 1 and Countdown 1.
In the Add Product dialog box, enter the PID, product name, and product description that are used on the Tuya IoT Platform.
Search the driver library by name, such as Modbus. Fuzzy matching is supported. Create a product.
Search the newly created socket by name in the Product Type field. Fuzzy matching is supported.
Select Modbus from the Driver Instance drop-down list that is automatically loaded after you select a product type.
Select the protocol type modbus-tcp.
In the IP Address field, enter the Docker IP address of the simulated device. This IP address is generated in the Prepare for the connection section.
Set Port to 1502.
Set UnitID to the address of the simulated Modbus device.
After the sub-device is added, click Activate Online to activate the device on the Tuya IoT Platform.
Go to the Cloud page of the Tuya IoT Platform, subscribe to the device control service, and then debug APIs.
[
{"code":"switch_1","value":true},
{"code":"countdown_1","value":318}
]
Go to the Log query page of the Tuya IoT Platform and enter the device ID to view device logs.
At the edge gateway, you can view the latest status of the sub-device for the edge gateway.
Is this page helpful?
YesSuggestions