Connecting a Siemens energy meter to an IoT backend platform with the nodeG5 edge MQTT Gateway
Cloud monitoring energy usage via Modbus RTU
-
In this tutorial, we will set up a Siemens model 7KT1651 Energy Meter as a Modbus RTU slave and interface to our nodeG5 gateway Modbus master.
-
The gateway is able to support up to 32 Modbus devices, including meters and remote I/O terminal. The standard industrial Modbus/RTU protocol runs on Serial RS-485 interface, providing a robust & reliable interface.
-
We will also look at connecting the nodeG5 IOT Gateway to a designated Cloud Service. Supported clients are AWS IoT, Azure IoT Hub and Ubidots.
-
Users have the option of backhaul via either wired Ethernet, WIFI or cellular (4G/3G) for remote sites/redundancy.
Hardware Wiring
MODBUS D-
MODBUS D+
IN (Digital Input)
GND
Siemens 7KT1651
nodeG5
Above shows the Serial RS-485 connection usually implemented using shielded twisted pair cable.
Note maximum cable length depends on baudrate and cable quality, e.g. using 24AWG shielded twisted pair, about 100Kbit/sec at 1000m.
Image courtesy of eng-tip.com
Siemens Meter Configuration
Please refer to the Siemens user manual to access and set the P07 Modbus interface as follows:
Address: 1
Baudrate: 19200
Parity: None/ No Parity
All slave devices connected on the RS-485 network must each have a unique address ranging from 1 to 247. Also, the baudrate and parity for all slave devices and master must be the same.
Connect Meter to Gateway
Our gateway uses a configuration file (\user\iotasset.json) to map the required Modbus registers to be read during each polling cycle. This flexibility allows wide compatibility with most Modbus RTU devices from different manufacturers.
To write this iotasset.json file we will be referencing the Modbus register table from the product user manual (see sample below):
And here is a sample of the iotasset.json. In the top example, we are configuring to read Current (A) register from the meter Modbus address 1, register 3000 (Siemens mandates a -1 offset) and name data field name, as "M1_Current".
The gateway is able to apply a customer multiplier (x0.1 in this case) and offset (0 in this case) to match the requirements of their cloud service.
We will now configure the gateway's serial port to operate as required for the attached Modbus devices. Go to the Port Settings tab and enter the following settings.
Then, go to the IOT Hardware menu to set the Hardware interface to "Modbus master" and register the polling configuration as required by the user (Note that all other interfaces like CAN bus and Zigbee can also run concurrently).
After these settings are updated, REBOOT the gateway. The user can then check the Modbus sensor data collected (JSON Data) or delete for testing.
Once you have configured your iotasset.json file the new device configurations can be updated to your nodeG5 gateway securely over the air. The gateway HTTPS connected webconsole must be accessible, either via local network (LAN or WLAN) and over cellular network with assigned public IP address (If you do not have an Internet connection, you can follow the alternative steps here).
Log into your web console and go to the <IOT Hardware> tab, click on 'UPDATE FIRMWARE' in the Firmware Update section
In the new window, click on 'CHOOSE FILE' and select from your local folder the updated iotasset.txt file then click on 'UPLOAD FIRMWARE FILE'. After the upload is successful you will need to close the page and log in again for security purpose.
{
"MODBUS":[
{
"Key":"M1_Current",
"IOTMODE":"1",
"MODBUSTYPE":"RTU",
"RTUPORT":"A",
"NODEID":"1",
"MODBUSFC":"3",
"REGADDR":"2999",
"NUMREGS":"2",
"DATATYPE":"FLOAT32ABCD",
"SCALEMUL":"0.1",
"SCALEADD":"0"
},
{
"Key":"M1_Voltage",
"IOTMODE":"1",
"MODBUSTYPE":"RTU",
"RTUPORT":"A",
"NODEID":"1",
"MODBUSFC":"3",
"REGADDR":"3027",
"NUMREGS":"2",
"DATATYPE":"FLOAT32ABCD"
},
{
"Key":"M1_ActivePower",
"IOTMODE":"1",
"MODBUSTYPE":"RTU",
"RTUPORT":"A",
"NODEID":"1",
"MODBUSFC":"3",
"REGADDR":"3053",
"NUMREGS":"2",
"DATATYPE":"FLOAT32ABCD"
}
]
}
Connect to a Cloud Service
Now that the connectivity between the Siemens Meter and the nodeG5 gateway has been set, we will then look at getting the data onto a suitably designed dashboard for monitoring on a custom cloud platform like Azure, AWS or Google Compute or an end solution like Ubidots. We support an open customer software and 3rd party API (e.g. REST API for HTTP, HTTPS and MQTT) integration to connect to a chosen cloud data or dashboard service (or to use for on board data processing).
Direct deployment on Azure or Ubidots can also be done as both these IoT clients have been integrated on the nodeG5 Gateway. For this project, we are going to showcase using Ubidots as the setting is a straightforward inclusion of the secure Device Token from user's Ubidots account into the IOT Client menu.
To Obtain your Ubidots Device Token
> Log in to your Ubidots account.
> Then go to <Users\Organizations> and create a new organization by pressing the plus (+) icon located at the upper right side of the platform.
> Enter the organization once it gets created.
> Next, go to the <Tokens> tab to create a new token pressing the plus (+) icon.
> Assign the token name of your preference, and press ACCEPT.
> Copy the token created.
Enter in your the Device Token and Device Name into the IOT Client tab on your nodeG5 web configuration menu. Click on UPDATE to establish the connection to Ubidots Cloud Service.
The nodeG5 will start sending the JSON data from the Siemens meter to Ubidots and you will be able to see your new nodeG5 created and listed under your ‘Devices’ in your Ubidots account.
Your Customised Reports Dashboard can now be easily built from the different register data (e.g. current from meter at Modbus address 1) using the friendly yet flexible Ubidots platform.
Guides to connect other Cloud Platforms
Connecting to Microsoft Azure
Use MQTT to connect to AWS IoT Services