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.

The below tutorial demonstrates how to setup the SIMATIC IOT2000 series hardware using the Arduino IDE and a provided sample code to send an HTTP request to Ubidots for data enablement with your Ubidots powered IoT Applications.

Requirements

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 and this tutorial therefore applied to any hardware within the series. 

Step-by-Step

  1. Setting up the Siemens SIMATIC IoT 2000 Series 
  2. Setting up the Arduino IDE
  3. Sending (POST) Data to Ubidots
  4. Data visualization in Ubidots
  5. 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 guide you in the device setup to communicate easily with Ubidots. 

2. Setting up the Arduino IDE

The SIMATIC IOT2000 is compatibly with the Arduino IDE using the Intel Galileo package. Please follow the steps below to setup the hardware properly:

1. Open the Arduino IDE

2. Open Boards Manager from Tools –> Board –> Boards Manager and install the "galileo" package. To find the correct device, search "Intel i5" within the search bar, then download and install the latest version.
If you are not familiar with how to install or manage boards in Arduino, checkout this simple guide to getting started with Arduino.

3. With the "Galileo" board installed, next select the Intel Galileo gen2 from Tools –> Board menu.

4. Attach the Micro USB to your IOT2000 and select the port com assigned from Tools –> Port –> Intel Galileo. If you'er working on Windows and your PC does not recognizes your IOT2000, you must update the drivers manually. 

5. Now with everything configured, upload the Blink Sketch to verify that everything is working properly. Go to File –> Examples –> Basics –> Blink and compile the code. 

6. Once the code is properly updated the USER LED will start blinking.

3. Sending (POST) Data to Ubidots

Once you are able to compile the Blink code into the SIMATIC IOT2000 you can continue with the following steps:

  1. Copy and paste the sample code below into the Arduino IDE. Once you have pasted the code be sure assign your unique Ubidots TOKEN where indicated. If you don't where to find your Ubidots TOKEN, please reference to this article
#include <EthernetClient.h>

const char server[] = "industrial.api.ubidots.com";
const char device_label[] = "simatic-iot2000"; // the device label to be send
const char variable_label[] = "humidity"; // the variable label to be send
const char token[] = "your_ubidots_token_here"; // assign your Ubidots Token

char* payload  = (char *) malloc(sizeof(char) * 20);  

/* Initialize the Ethernet client library */
EthernetClient client;

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ; /* wait for serial port to connect */
  }

  /* Analog input configuration */
  const int IOShield_U0 = A0;  
  int value = analogRead(IOShield_U0);
  /* Build the payload to be send. e.i -> {"humidity": 55} */
  sprintf(payload, "{\"%s\":%d}", variable_label, value);

  Serial.println("connecting...");
 
  /* if you get a connection, report back via serial: */
  if (client.connect(server, 80)) {
    Serial.println("connected");
    /* Make the HTTP request to the server*/
    client.print(F("POST /api/v1.6/devices/"));
    client.print(device_label);
    client.println(F(" HTTP/1.1"));
    client.println(F("Host: industrial.api.ubidots.com"));
    client.println(F("User-Agent: siemenes/1.1"));
    client.print(F("X-Auth-Token: "));
    client.println(token);
    client.println(F("Connection: close"));
    client.println(F("Content-Type: application/json"));
    client.println(F("Content-Length: 17"));
    client.println();
    client.print(payload);
    client.println();
    free(payload);
  }
  else {
    /* if you didn't get a connection to the server: */
    Serial.println("connection failed");
  }
}

void loop()
{
  /* if there are incoming bytes available
     from the server, read them and print them: */
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  /* if the server's disconnected, stop the client: */
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

    /* do nothing forevermore: */
    for (;;)
      ;
  }
}

IMPORTANT DEPLOYMENT NOTE: The code above is a sample code demonstrating how to send HTTP POST request to Ubidots using the EthernetClient library. To implement your own code, please reference the Ubidots REST API Reference and Siemens Support for additional resources. 

2. Next, verify and upload the code choosing the "check mark" icon and then the "right-arrow" icon found in the top-left corner of your Arduino IDE.
Click here for additional details to how to Verify and Upload your code using Arduino. 

3. To visualize the response of the server and its connectivity with the Siemens hardware, open the Serial Monitor of the Arduino IDE. You can open the serial monitor by selecting the "magnifying glass" icon in the top-right corner of our Arduino IDE.

4. Data visualization in Ubidots

Confirm your code by going to your Ubidots account to find the new device created called "simatic-iot2000" containing a variable called "humidity" which is the reading the A0 input from the Arduino Shield contained in the SIMATIC IOT2000. 

5. Summary

In just a few minutes, we integrated an industrial piece of hardware, the Siemens SIMATIC IOT2000, with Ubidots.

Now its time to create Ubidots Dashboards to visualize and interpret your data.  

Other readers have also found useful...

 

Did this answer your question?