All Collections
Connect your Devices
Siemens IoT2040 Setup and Activation
Siemens IoT2040 Setup and Activation

Setup and connect your Siemens IoT2040 device to Ubidots and create your own Business Intelligence applications with ease.

Isabel Lopez avatar
Written by Isabel Lopez
Updated over a week ago

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. 

Available in two versions, the IoT2020 designed for educational institutions and public spaces while the IoT2040 is optimized for Industrial environments. If you'd like to learn more check out the SIMATIC IoT2000 support and forums

In this guide we detail the integration of a HVAC System with the SIMATIC IOT2000, using an Arduino UNO which will act as our sensor in this integration example and send the data to the Siemens Gateway through RS-485 interface.

Requirements

Step-by-Step

1. Setting up the Siemens SIMATIC IoT 2000 Series
2. Setting up the SIMATIC IOT2000 with Node-RED
3. Setting up the Arduino
    -Hardware Setup
    -Firmware Setup
4. NodeRED Auto Start
5. Data visualization
6. 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 created 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. Setting up the 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

  1. Go to the opkg directory using the Siemens terminal:

cd /etc/opkg

2. Edit the opkg.conf file using nano -> nano opkg.conf  . Then, add the lines below at the end of the file:

src iotdk-all http://iotdk.intel.com/repos/2.0/iotdk/allsrc iotdk-i586 http://iotdk.intel.com/repos/2.0/iotdk/i586src iotdk-quark http://iotdk.intel.com/repos/2.0/iotdk/quarksrc iotdk-x86 http://iotdk.intel.com/repos/2.0/iotdk/x86

3. Next, edit the arch.conf file using nano –> nano arch.conf . 

Add the lines below at the end of the file: 

arch i586 12
arch quark 13
arch x86 14

4.  Update the configurations made by entering and executing the below 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 using the command 

reboot
  • Node-RED

  1. To start Node-RED type the command below into the Siemens terminal:

node /usr/lib/node_modules/node-red/red &

With Node-RED, you will see the behavior below in your SIMATIC IOT2000, this may take a couple of minutes - so please be patient.

2. Once the Node-RED has 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.

3. Next, click on Node-RED menu in the upper right corner, then “Import” –> “Clipboard” and paste the code below:

[{"id":"3740cae8.aee83e","type":"serial in","z":"707c997d.74c3c8","name":"rs-485","serial":"22b59e44.024bfa","x":132,"y":249,"wires":[["b621bf61.959b7"]]},{"id":"b621bf61.959b7","type":"function","z":"707c997d.74c3c8","name":"parse function","func":"var payload = msg.payload;\n/* Splits the incoming data */\nvar values = payload.split(\",\");\n/* Saves the sensor readings */\nvar temp_value = values[0]; // temperature in celsius\nvar temp_value_f = (temp_value*1.8) + 32; // temperature in fahrenheit\nvar hum_value = values[1].replace('\\r\\n', '');\n\nvar data = {}\n/* Builds the payload to be published */\ndata.payload = {\"temperature-c\": temp_value, \"humidity\": hum_value, \"temperature-f\": temp_value_f};\ndata.topic = \"/v1.6/devices/siemens\";\nreturn data;\n\n","outputs":1,"noerr":0,"x":336,"y":249,"wires":[["288319d7.13aa06","764e3eb0.baea8"]]},{"id":"288319d7.13aa06","type":"mqtt out","z":"707c997d.74c3c8","name":"","topic":"","qos":"","retain":"","broker":"6375a8fe.40ce","x":591,"y":250,"wires":[]},{"id":"764e3eb0.baea8","type":"debug","z":"707c997d.74c3c8","name":"","active":true,"console":"false","complete":"payload","x":553.5,"y":325,"wires":[]},{"id":"22b59e44.024bfa","type":"serial-port","z":"","serialport":"/dev/ttyS2","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","newline":"\\n","bin":"false","out":"char","addchar":false},{"id":"6375a8fe.40ce","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":""}]

4. 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, please see this guide

Once the Ubidots TOKEN is assigned in the MQTT-broker node, let’s program the Arduino UNO to start sending data. 

DEPLOYMENT NOTE: At this point, DO NOT press the “Deploy” button in NodeRED. Once the Arduino starts sending data to the SIMATIC IOT2000, you can press the deploy button to save the changes made.

3. Setting up Arduino

To establish the communication between the end sensors and the Siemens SIMATIC IOT2000, we decided to choose an Arduino UNO which is one the most common microcontroller in the market. This easy to use and easy to setup hardware makes our example easy to implement and test.

The Arduino will be in charge of taking the sensor readings (temperature and humidity) and relaying them to the SIMATIC IOT2000 through RS-485 using a RS-485 Shield. To get a better idea, the data flow diagram is below: 

Hardware Setup

  1. First attach the Arduino RS-486 shield to the top of the Arduino UNO. The result will be something similar to the image below:

2. Connect the AM2305 sensor following the diagram below:

NOTE: Before connecting the sensor, note that the sensor has a pullup resistor, please see this guide to learn how to setup the sensor properly if you have not done so before.

AM2305 - Arduino UNO
Yellow wired - pin 10
Red wired - 3.3 V
Black wired - GND

3. [OPTIONAL] Locate the Arduino UNO + RS-485 Shield inside a case, and make the modifications to the case for the sensor and power cable. To give you a better idea, reference to the images below:

3. Now connect the RS-486 Arduino shield with the SIMATIC IOT2000. 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. For more detailed information about the SIMATIC IOT2000 operating instructions click here.

 Connector Pinout:

4. Follow the table below to make the connection between the Arduino RS485 shield and the SIMATIC IOT2000:

Firmware Setup

1. Open Arduino IDE. 

2. Select the Arduino UNO from Tools –> Board  menu 

3. Download the DHT Library in the following link. Then, click on Sketch –> Include Library –> Add .ZIP Library. Select the .ZIP file of the library previously downloaded and press “Accept” or “Choose”.

4. Connect the Arduino UNO to your computer and select the port COM assigned from Tools –> Port –> Arduino UNO.

5. Now with everything configured, copy and paste the sample code below into the Arduino IDE.

/********************************
 * Libraries included
 *******************************/
#include <SoftwareSerial.h>
#include <DHT.h>

/********************************
 * Constants and objects
 *******************************/
#define DHTPIN 10     // what pin we're connected to
#define DHTTYPE DHT22   // DHT 22 - (AM2305)

float hum;  //Stores humidity value
float temp; //Stores temperature value

// Space to store values to send
char sensor_values[20];
char str_val_temp[10];
char str_val_hum[10];

DHT dht(DHTPIN, DHTTYPE);
SoftwareSerial mySerial(3,2);

/********************************
 * Main Functions
 *******************************/
void setup() {
  mySerial.begin (9600);
  Serial.begin(9600);
  dht.begin();
}
 
void loop() {
  /* Takes the sensor readings */
  temp = dht.readTemperature(); // Read temperature as Celsius (the default)
  hum = dht.readHumidity(); // Read humidity
 
  /*---- Transforms the values of the sensors to char type -----*/
  /* 4 is mininum width, 2 is precision; float value is copied onto str_val*/
  dtostrf(temp, 4, 2, str_val_temp);
  dtostrf(hum, 4, 2, str_val_hum);

  /* Concatenates the readings and save them in one variable */
  sprintf(sensor_values, "%s,%s", str_val_temp, str_val_hum);
  /* Send the values via serial (RS-486) */
  mySerial.println (sensor_values);
  /* Prints the values in the Serial Monitor */
  Serial.print("temp, hum: ");
  Serial.println(sensor_values);
  /* update the value every */
  delay(5000);

6.  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 through RS-485 properly. If you desire to check the values sent, open the serial monitor by selecting the "magnifying glass" icon in the top right corner of our Arduino IDE.

7. Next, return back to the NodeRED Flow, and press Deploy. 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 simple way. If you desire to learn how to install this node and how to used it properly, simply refer to this guide which explains how to PUBLISH and SUBSCRIBE data to Ubidots using our NODE.

4. NodeRED Auto Start

To run NodeRED in the autostart mode, please follow the next steps:

  1. In the SIMATIC IoT2000 terminal enter and execute the following command:

iot2000setup

2. In the window below, using the keyboard arrows, locate the cursor in the “Software”option and press enter:

3. Then, select “Manage Autostart Options” :

4. Locate the cursor in the option “Auto Start node-red” and press the bar space to select the option:

5. To finish, press the “Done”, and reboot the SIMATIC IOT2000 with the command below:    

reboot

5. Data visualization 

1. Go to the device section of your Ubidots account  to find a new device created:   

2. Enter to the device and you will see the variables temperature-c, temperature-f, and humidity created with the real-time data of updating from Arduino Uno sensors connected:

3. If you desire to change the device name to a friendly one and you don’t know how, please reference the following guide. Also, you can change the device description icon using the following guide

Once the names and icons are updated to your liking, launch your application!

6. Summary

In what felt like too easy of a process for hardware, we just integrated the Siemens SIMATIC IOT2000 with starter equipment and simple know-how. With the right devices for your environment, you too can launch industrial applications in a matter of days instead of months. 

Now it's time to create Ubidots Dashboards to visualize and interpret your data to control and monitoring your machines and environments remotely - keeping your clients happy and productions at its peak.

Don't forget to checkout the Control and Automation with Ubidots to make life a little easier and more comfortable by giving your data value and using it to automate other machines or processes.

For additional insights to the Siemens IoT2040 device and Ubidots position in the Industrial IoT Landscape, check out the April 10th, Webinar: Data Drives Decisions; how to extract value from the IIoT and the Cloud.

Other readers have also found useful...

 

Did this answer your question?