Adding Siemens MindSphere Tracking to the DMC DrinkBot

Adding Siemens MindSphere Tracking to the DMC DrinkBot

One day every year, DMC comes together to work on various internal projects in an event we call FedEx Day. In previous years, one of our favorite projects creating our company’s robotic bartender lovingly called DrinkBot!

For FedEx Day 2019, a group of DMC Denver engineers decided that we wanted to add functionality to DrinkBot to track its usage. DrinkBot tends to travel frequently between offices, and we wanted to be able to stay up to date on its stock and wear from anywhere in the world. We decided that the best tool for this job would be Siemens Internet Of Things (IoT) platform, MindSphere.

Collecting the Data

Before we could upload the data into MindSphere, we first needed to collect it on our Siemens S7-1200 PLC. We built a buffer into our existing DrinkBot project to track all DrinkBot usage. This buffer would continue to fill with data until the data was pulled into MindSphere and the buffer was reset.

For each bottle of liquor, we tracked every time a shot was poured into a drink, as well as the time that the shot was poured. For the various sodas and mixers in DrinkBot, we included a tag tracking the amount of each mixer poured into the drink. We also tracked the current positions of the Siemens G120, and Siemens 1FK7 Servo Motor, and the total usage of these motors.

Transporting the Data

After collecting the usage data on the PLC, we needed to prepare the data to upload to MindSphere. Data processing was done on a Raspberry Pi 4. First, we pulled the data onto the Raspberry Pi using a Python script, and the Snap7 library for communicating with a PLC, as well as cleared the buffer.

The Snap7 library provides straightforward functions for accessing and updating PLC data. It is as simple as specifying the IP address of the PLC you want to communicate with, the data block you want to pull data from, and the byte addresses of the specific data you need

client = snap7.client.Client()

client.connect(ipAddress, 0, 1)

data = client.db_read(dbNumber, startingByteAddress, dataLength)

The MindSphere platform has many Application Programming Interfaces (APIs) for different services. For our task, we needed to create an asset in MindSphere for DrinkBot and update the different aspects of DrinkBot (i.e. soda usage). Our aspects were tracked on MindSphere as time series. We could then update these time series using IoT time series service API calls in C#. This would create a log of DrinkBot usage on the MindSphere platform.

Using The Data

Once we collected the DrinkBot data onto MindSphere, we needed to present it in some form. To do so, we created a custom MindSphere application. This application, using ReactJS, pulled all the DrinkBot aspect data, and created a pie chart displaying the usage of the different drinks by the machine over any given time period.

//create URL to query against
           var fetchstring = "/api/iottimeseries/v3/timeseries/{AspectId}/{Variable}?from=2019-09-03T00:00:00Z&to=2019-09-10T00:00:00Z";
           //Since query is occuring from the client, grab the cookie for credentials when querying against the time series API
           let token = Cookies.get("XSRF-TOKEN");
               {   credentials : 'include',
                       //Return message should be json
                       "Accept": "application/json",
                       //User token for access to the time series API
                       "x-xsrf-token": token
               .then(response => response.json())
               .then(responseJson => {
                   //Move the response into state data
                   this.setState({bottleShots: responseJson});

In the future, we hope to include the utilization of the motor position and runtime data, as well as expand on the dashboard to allow for greater breakdown of data.

Summary of Technology

  • Siemens S7-1200 PLC
  • Raspberry Pi 4
  • MindSphere IoT Platform

To see how we can help you get started on a project, check out our Siemens PLC programming services and contact us today!

Learn more about DMC's partnership with Siemens.


There are currently no comments, be the first to post one.

Post a comment

Name (required)

Email (required)

Enter the code shown above:

Related Blog Posts