The 2Smart Cloud platform enables not only the connection of physical devices based on ESP32 and other microcontrollers with internet access but also virtual devices or digital twins of real ones. In this article, we explain how to create a digital twin on the 2Smart Cloud platform using the low-code development tool Node-RED. We use a Xiaomi gateway as an example, but you can apply this tutorial to any Node-RED project.
For this experiment, we used the Xiaomi Mi Smart Home gateway with connected sensors operating via the ZigBee protocol: two temperature and humidity sensors, and two motion sensors.
To integrate this device set into 2Smart Cloud using Node-RED, we used the node-red-contrib-xiaomi-smart-devices module. We previously used this module when writing the “Xiaomi Gateway” bridge to integrate the same gateway into the open-source monitoring and automation platform 2Smart Standalone.
We’re empower your business with our technology expertise
$ git clone https://github.com/2SmartCloud/2smart-cloud-node-red-xiaomi-example.git
$ node-red -u ./2smart-cloud-node-red-xiaomi-example
We acknowledge that the above example is not meant to be production-ready or even an MVP for your needs. The Xiaomi gateway still connects to the manufacturer’s server, and the native mobile app provides more control features than the 2Smart Cloud app.
However, this integration example shows that you can easily connect almost anything to the cloud without writing code. Node-RED can be a handy tool for building an MVP of your product and requires minimal effort to start creating your virtual IoT devices.
We use this approach in our projects when appropriate. For instance, in the MyBox electric vehicle charging management platform, we implemented Dynamic Load Management for numerous charging stations. We integrated Unipi’s existing equipment into the MyBox platform using Node-RED, resulting in a seamless integration of powerful functionality with third-party hardware.
The Internet of Things isn’t limited to physical devices and their firmware; it also allows for creating virtual devices that operate on other services/APIs and can act as digital twins.
Beyond Node-RED, you can also create your virtual devices. An example is the 2Smart virtual weather station. This virtual device, written in NodeJS, communicates with the OpenWeather API to display current weather metrics for a selected city.
Regarding the structure of topics and the communication format for real or virtual devices with the 2Smart Cloud platform, these are described on the 2Smart GitHub. If you have any questions after reviewing the documentation, feel free to reach out to us in the 2Smart Cloud Discussion Telegram chat.
Creating digital twins on the 2Smart Cloud platform using Node-RED provides a flexible and convenient way to integrate IoT solutions. With minimal programming skills, you can easily connect and manage both physical and virtual devices. This opens up opportunities for rapid prototyping and concept testing in various fields, from smart homes to industrial applications. The capabilities of Node-RED and 2Smart Cloud enable the creation of scalable and functional systems while minimizing development time and resources.
We’re empower your business with our technology expertise
A digital twin is a virtual representation of a physical device that allows you to monitor, control, and analyze its performance in real time over the internet.
Node-RED is a low-entry barrier tool that allows for quick and easy integration and automation without requiring deep programming knowledge.
Almost any device that can connect to the internet, including physical devices based on microcontrollers (e.g., ESP32) and virtual devices created using APIs or other services.
Using tokens and credentials requires careful attention to security. We recommend changing passwords after obtaining tokens and using secure methods for storing and transmitting data.
End users can manage devices through the 2Smart Cloud mobile app, receive notifications, and monitor device status in real-time. They can share device control access with others, including those not using the mobile app.
End users of 2Smart Cloud can also control their devices via Telegram bot and phone calls, easily add devices to ecosystems like Siri and Google Home, and receive notifications from their devices not only in the mobile app but also in messengers like Telegram, Slack, and WhatsApp.
Yes, the approach using Node-RED and 2Smart Cloud is suitable for both prototyping and creating commercial products, allowing you to bring new solutions to market quickly.
You can create virtual weather stations, energy monitoring systems, smart lighting, and many other devices that interact with various APIs and services, providing real-time information and control capabilities.
Share with us your business idea and expectations about the software or additional services.