The simplicity of Arduino combined with the reliability and history of Siemens makes the SIMATIC IOT2000 series a perfect choice retrofitting or implementing the IoT into smart(er) factories or institutions exploring connectivity or retrofitting options. New sensors on old machines or simply upgrading sensors makes the SIMATIC IOT2000 series perfect as it harmonizes, analyzes, and forwards data efficiently with common protocols like HTTP and MQTT. Based on a Yocto Linux, the SIMATIC IOT2000 series includes the IoT2020 and IoT2040 models which are compatible with most Arduino Sketches and can be uploaded directly from the Arduino IDE. The IOT2040 is ideal for factories while the IOT2020 is best in educational institutions with its additional peripherals and communication protocols.
In this guide we detail the integration of the Siemens SIMATIC IOT 2000 with Ubidots, using an external device serial communicated through RS-485 interface with the SIMATIC IOT 2000. Then we will end with configuring a flow in Node-RED to transmit the data obtained from the gateway to Ubidots over MQTT.
Available in two versions, the IoT 2020 designed for educational institutions and public spaces while the IoT 2040 is optimized for Industrial environments. If you'd like to learn more check out the SIMATIC IOT 2000 support and forums.
Requirements
Ethernet cable
SD Card
24V power supply
First, you must register with or have access to Siemens Support Portal to download all initial configurations. This Portal will also provide troubleshooting and support from Siemens on any hardware related inquires. The entire IOT2000 series is setup the same way, please follow this tutorial for any devices in the series.
Step-by-Step
Setting up the Siemens SIMATIC IoT 2000 Series
Hardware Setup
Firmware Setup - Arduino IDE
Setting up SIMATIC IOT2000 with Node-RED
Data visualization in Ubidots
Summary
1. Setting up the Siemens SIMATIC IoT 2000 Series
If this is your first time working with the Siemens SIMATIC IoT 2000 Series, we've create a separate getting started guide specifically for the Siemens SIMATIC IoT 2000 to help you in the device setup to easily communicate with Ubidots.
2. Hardware Setup
SIMATIC IOT2000 with Arduino (external device)
Based on your environment and technical requirements, choose the best device to complete your project. Make sure you device is transmitting data through RS485.
Our project calls for a simple Arduino UNO using a RS485 shield with an humidity sensor to transmit it values to Ubidots.
Hardware Setup
Fly-out Rule: To avoid any hardware issue please make sure that the SIEMENS IOT2000 is turned OFF before making the connections:
Arduino connections
1. First attach the Arduino Grove Shield to the Arduino UNO and then attach the RS485 shield.
2. Connect the Humidity Sensor to A0 pinout of the Grove Shield using a grove cable. Once everything is properly attached your Arduino stack will look similar to the below"
3. Verify if the headers of the RS485 shield are properly assigned with the configration below:
P1 -> 5V
P2 -> TX_CTRL
D2 -> TX
D3 -> RX
RS485 connections
Click here for more detailed information about the SIMATIC IOT 2000 operating instructions.
1. The X30 COM and X31 COM allow you work with RS232/RS422/RS485 interfaces; in this case we are going to work with the X30 COM - RS485.
Connector Pinout:
2. Follow the table below to make the connection between the Arduino RS485 shield and the SIMATIC IOT2000:
3. Firmware Setup - Arduino IDE
1. Open Arduino IDE.
2. Select the Arduino UNO from Tools –> Board menu
3. Connect the Arduino UNO to your computer and select the port COM assigned from Tools –> Port –> Arduino UNO.
4. Now with everything configured, copy and paste the sample code below into the Arduino IDE.
#include <SoftwareSerial.h>
int sensor = A0;
SoftwareSerial mySerial(3,2);
void setup() {
mySerial.begin (9600);
Serial.begin(9600);
pinMode(sensor, INPUT);
}
void loop() {
int sensor_value = analogRead(sensor);
mySerial.println (sensor_value);
Serial.println(sensor_value);
delay(1000);
}
5. Verify and upload the code choosing the "check mark" icon and then the "right-arrow" icon beside the check mark icon.
Now your Arduino UNO is sending data to the Siemens SIMATIC IOT 2000 properly.
4. Setting up SIMATIC IOT2000 with Node-RED
Before starting with the Node-RED flow, we must establish some configurations in the SIMATIC IOT2000. Please, follow the steps below carefully to ensure the right functionality:
Package manager:
Go to the
opkg
directory using the Siemens terminal:
cd /etc/opkg
2. Edit the opkg.conf
file by adding the lines below at the end of the file:
src iotdk-all http://iotdk.intel.com/repos/2.0/iotdk/all
src iotdk-i586 http://iotdk.intel.com/repos/2.0/iotdk/i586
src iotdk-quark http://iotdk.intel.com/repos/2.0/iotdk/quark
src iotdk-x86 http://iotdk.intel.com/repos/2.0/iotdk/x86
3. Next, edit the arch.conf
file by adding the lines below at the end of the file:
arch i586 12
arch quark 13
arch x86 14
4. Update the adjusted configurations with the below execution command:
opkg update
5. Write iot2000setup
to open the setup interface and configure the X30 COM as RS-485.
To do this, select Peripherals –> Configure External COM Port –> X30 –> RS485:
6. Assign the baud-rate to the port with the command below:
stty -F /dev/ttyS2 9600
7. Reboot the SIMATIC to save the changes with the command reboot
:
Node-RED:
1. Write the command below in your Siemen's terminal to enter to the Node-RED directory:
cd /usr/lib/node_modules/
2. Then, install the node required by writing the following command:
npm install -g node-red-contrib-modbus
This process will take a couple of minutes so please be patient.
NOTE: If you get an issue installing the node, check out these tips and tricks to troubleshoot further.
3. To start Node-RED enter and execute the command below:
node /usr/lib/node_modules/node-red/red &
Once the Node-RED has started properly, you should see the behavior below in your SIMATIC IOT2000. Note that is may take a couple of minutes:
3. Once the Node-RED is started, open a web-browser (firefox, preferably) and write the IP Address of the SIMATIC IOT2000 and the port 1880 (i.e
http://192.168.200.1:1880) to open the Node-RED web interface.
4. Next, click on the Node-RED menu in the upper right corner, then “Import” –> “Clipboard” and paste the code below:
[
{
"id":"38e1405b.5796d",
"type":"serial in",
"z":"c88a5f47.16d498",
"name":"rs-485",
"serial":"8bf5451a.2fb14",
"x":170.5,
"y":223,
"wires":[
[
"f7937636.d26448",
"ae2f3a52.32f23"
]
]
},
{
"id":"f7937636.d26448",
"type":"debug",
"z":"c88a5f47.16d498",
"name":"",
"active":true,
"console":"false",
"complete":"false",
"x":377.5,
"y":121,
"wires":[]
},
{
"id":"ae2f3a52.32f23",
"type":"function",
"z":"c88a5f47.16d498",
"name":"parse function",
"func":"var response = {};\nresponse.payload = {\"humidity\": msg.payload};\nresponse.topic = \"/v1.6/devices/siemens\";\nreturn response;",
"outputs":1,
"noerr":0,
"x":374.5,
"y":223,
"wires":[
[
"51bcbd87.0af04c"
]
]
},
{
"id":"51bcbd87.0af04c",
"type":"mqtt out",
"z":"c88a5f47.16d498",
"name":"",
"topic":"",
"qos":"",
"retain":"",
"broker":"cefb900f.f02ca8",
"x":605.5,
"y":222,
"wires":[]
},
{
"id":"8bf5451a.2fb14",
"type":"serial-port",
"z":"",
"serialport":"/dev/ttyS2",
"serialbaud":"9600",
"databits":"8",
"parity":"none",
"stopbits":"1",
"newline":"\\n",
"bin":"false",
"out":"char",
"addchar":false
},
{
"id":"cefb900f.f02ca8",
"type":"mqtt-broker",
"z":"",
"broker":"industrial.api.ubidots.com",
"port":"1883","clientid":"",
"usetls":false,
"compatmode":true,
"keepalive":"60",
"cleansession":true,
"willTopic":"",
"willQos":"0",
"willPayload":"",
"birthTopic":"",
"birthQos":"0",
"birthPayload":""
}
]
5. Assign your Ubidots TOKEN as username in the security tab of the MQTT-broker node. If you don't know how to get your Ubidots TOKEN see this guide.
Once the Ubidots TOKEN is assigned, press Deploy and the status of the serial and mqtt node should appear as connected. Also, if you wish to visualize the sensor value received, just press the debug tab:
PRO TIP: Ubidots team built a NodeRed Node to communicate data to Ubidots over MQTT in a easy way. If you desire to learn how to install this node and how to used efficiently, please refer to this guide, which explains how to PUBLISH and SUBSCRIBE data.
5. Data visualization in Ubidots
Go to the device section of your Ubidots account and see a new device created:
Enter to the device and you will see the device and variable created with the real-time data of the sensor connected:
If your desire to modify the name of the device and the variables, you can easily edit the parse function created in the Node-RED flow:
6. Summary
In what felt like too easy of a process for hardware, we just integrated the SIMATIC IOT2000 to communicate and update data to the cloud, Ubidots cloud. We built this integration with starter equipment and simple know-how, but with the right devices for your environment, you will be able to launch industrial applications in a matter of days instead of months.
Now its time to create Ubidots Dashboards to visualize and interpret your data to control and monitor your machines and environments remotely and keeping your clients happy and production at its peak.
Other readers have also found useful...