<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Raspberry Pi Archives | DMC, Inc.</title>
	<atom:link href="https://static.dmcinfo.com/blog/tag/raspberry-pi/feed/index.xml" rel="self" type="application/rss+xml" />
	<link></link>
	<description></description>
	<lastBuildDate>Wed, 22 Jul 2026 18:28:14 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.2</generator>

<image>
	<url>https://static.dmcinfo.com/wp-content/uploads/2025/04/site-icon-150x150.png</url>
	<title>Raspberry Pi Archives | DMC, Inc.</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Adding Siemens MindSphere Tracking to the DMC DrinkBot</title>
		<link>https://static.dmcinfo.com/blog/20875/adding-siemens-mindsphere-tracking-to-the-dmc-drinkbot/</link>
		
		<dc:creator><![CDATA[DMC]]></dc:creator>
		<pubDate>Thu, 03 Oct 2019 11:42:46 +0000</pubDate>
				<category><![CDATA[Denver]]></category>
		<category><![CDATA[Manufacturing Automation & Intelligence]]></category>
		<category><![CDATA[PLC]]></category>
		<category><![CDATA[Siemens PLC]]></category>
		<category><![CDATA[2019]]></category>
		<category><![CDATA[Cloud Foundry]]></category>
		<category><![CDATA[Fedex]]></category>
		<category><![CDATA[Mindsphere]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[Siemens]]></category>
		<category><![CDATA[Snap7]]></category>
		<guid isPermaLink="false">https://static.dmcinfo.com/blog/20875/adding-siemens-mindsphere-tracking-to-the-dmc-drinkbot/</guid>

					<description><![CDATA[<p>One day every year, DMC comes together to work on various internal projects&#160;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 [&#8230;]</p>
<p>The post <a href="https://static.dmcinfo.com/blog/20875/adding-siemens-mindsphere-tracking-to-the-dmc-drinkbot/">Adding Siemens MindSphere Tracking to the DMC DrinkBot</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">One day every year, DMC comes together to work on various internal projects&nbsp;in an event we call <a href="https://static.dmcinfo.com/latest-thinking/blog/id/9648/employees-lead-company-improvements-during-fedex-day-2018">FedEx Day</a>. In previous years, one of our favorite projects creating our company’s robotic bartender lovingly called <a href="https://static.dmcinfo.com/latest-thinking/blog/id/9580/dmc-engineers-serve-up-a-siemens-s7-powered-drinkbot">DrinkBot</a>!</p>



<p class="wp-block-paragraph"><iframe allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" frameborder="0" height="315" src="https://www.youtube.com/embed/Lt64CD1nu0k" width="560"><!--cke_bookmark_227S--><!--cke_bookmark_227E--></iframe></p>



<p class="wp-block-paragraph">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, <a href="https://new.siemens.com/global/en/products/software/mindsphere.html" target="_blank">MindSphere</a>.</p>



<h2 id="h-collecting-the-data" class="wp-block-heading">Collecting the Data</h2>



<p class="wp-block-paragraph">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.</p>



<p class="wp-block-paragraph">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.</p>



<h2 id="h-transporting-the-data" class="wp-block-heading">Transporting the Data</h2>



<p class="wp-block-paragraph">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.</p>



<p class="wp-block-paragraph">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</p>


<hr />


<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">Python</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly># Create a Snap7 client object
client = snap7.client.Client()

# Connect to the PLC
client.connect(ipAddress, 0, 1)

# Read data from a PLC Data Block (DB)
data = client.db_read(
    dbNumber,
    startingByteAddress,
    dataLength
)</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #6A9955"># Create a Snap7 client object</span></span>
<span class="line"><span style="color: #D4D4D4">client = snap7.client.Client()</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955"># Connect to the PLC</span></span>
<span class="line"><span style="color: #D4D4D4">client.connect(ipAddress, </span><span style="color: #B5CEA8">0</span><span style="color: #D4D4D4">, </span><span style="color: #B5CEA8">1</span><span style="color: #D4D4D4">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955"># Read data from a PLC Data Block (DB)</span></span>
<span class="line"><span style="color: #D4D4D4">data = client.db_read(</span></span>
<span class="line"><span style="color: #D4D4D4">    dbNumber,</span></span>
<span class="line"><span style="color: #D4D4D4">    startingByteAddress,</span></span>
<span class="line"><span style="color: #D4D4D4">    dataLength</span></span>
<span class="line"><span style="color: #D4D4D4">)</span></span></code></pre></div>


<hr />


<p class="wp-block-paragraph">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.</p>



<h2 id="h-using-the-data" class="wp-block-heading">Using The Data</h2>



<p class="wp-block-paragraph">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.</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">JavaScript</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>// Create URL to query against
const fetchString =
    "/api/iottimeseries/v3/timeseries/" +
    "{AspectId}/{Variable}" +
    "?from=2019-09-03T00:00:00Z" +
    "&amp;to=2019-09-10T00:00:00Z";

// Since the query occurs from the client,
// grab the XSRF token from the browser cookie
const token = Cookies.get("XSRF-TOKEN");

fetch(fetchString, {
    credentials: "include",

    headers: {
        // Expect JSON response
        "Accept": "application/json",

        // Authentication token for the API
        "x-xsrf-token": token
    }
})
.then(response => response.json())
.then(responseJson => {
    // Store the received data in React state
    this.setState({
        bottleShots: responseJson
    });
});</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #6A9955">// Create URL to query against</span></span>
<span class="line"><span style="color: #569CD6">const</span><span style="color: #D4D4D4"> </span><span style="color: #4FC1FF">fetchString</span><span style="color: #D4D4D4"> =</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #CE9178">&quot;/api/iottimeseries/v3/timeseries/&quot;</span><span style="color: #D4D4D4"> +</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #CE9178">&quot;{AspectId}/{Variable}&quot;</span><span style="color: #D4D4D4"> +</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #CE9178">&quot;?from=2019-09-03T00:00:00Z&quot;</span><span style="color: #D4D4D4"> +</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #CE9178">&quot;&amp;to=2019-09-10T00:00:00Z&quot;</span><span style="color: #D4D4D4">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955">// Since the query occurs from the client,</span></span>
<span class="line"><span style="color: #6A9955">// grab the XSRF token from the browser cookie</span></span>
<span class="line"><span style="color: #569CD6">const</span><span style="color: #D4D4D4"> </span><span style="color: #4FC1FF">token</span><span style="color: #D4D4D4"> = </span><span style="color: #9CDCFE">Cookies</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">get</span><span style="color: #D4D4D4">(</span><span style="color: #CE9178">&quot;XSRF-TOKEN&quot;</span><span style="color: #D4D4D4">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #DCDCAA">fetch</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">fetchString</span><span style="color: #D4D4D4">, {</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #9CDCFE">credentials:</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">&quot;include&quot;</span><span style="color: #D4D4D4">,</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #9CDCFE">headers:</span><span style="color: #D4D4D4"> {</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #6A9955">// Expect JSON response</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #CE9178">&quot;Accept&quot;</span><span style="color: #9CDCFE">:</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">&quot;application/json&quot;</span><span style="color: #D4D4D4">,</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #6A9955">// Authentication token for the API</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #CE9178">&quot;x-xsrf-token&quot;</span><span style="color: #9CDCFE">:</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">token</span></span>
<span class="line"><span style="color: #D4D4D4">    }</span></span>
<span class="line"><span style="color: #D4D4D4">})</span></span>
<span class="line"><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">then</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">response</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">=&gt;</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">response</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">json</span><span style="color: #D4D4D4">())</span></span>
<span class="line"><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">then</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">responseJson</span><span style="color: #D4D4D4"> </span><span style="color: #569CD6">=&gt;</span><span style="color: #D4D4D4"> {</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #6A9955">// Store the received data in React state</span></span>
<span class="line"><span style="color: #D4D4D4">    </span><span style="color: #569CD6">this</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">setState</span><span style="color: #D4D4D4">({</span></span>
<span class="line"><span style="color: #D4D4D4">        </span><span style="color: #9CDCFE">bottleShots:</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">responseJson</span></span>
<span class="line"><span style="color: #D4D4D4">    });</span></span>
<span class="line"><span style="color: #D4D4D4">});</span></span></code></pre></div>



<p class="wp-block-paragraph">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.</p>



<h2 id="h-summary-of-technology" class="wp-block-heading">Summary of Technology</h2>



<ul class="wp-block-list">
<li>Siemens S7-1200 PLC</li>



<li>Raspberry Pi 4</li>



<li>MindSphere IoT Platform</li>
</ul>



<p class="wp-block-paragraph">To see how we can help you get started on a project, check out our&nbsp;<a href="https://static.dmcinfo.com/services/manufacturing-automation-and-intelligence/plc-programming/siemens-s7-plc-programming">Siemens PLC programming services</a>&nbsp;and&nbsp;<a href="https://static.dmcinfo.com/contact">contact</a>&nbsp;us today!</p>



<p class="wp-block-paragraph"><a href="https://static.dmcinfo.com/about/partners/siemens-solution-partner">Learn more about DMC&#8217;s partnership with Siemens</a><strong>.</strong></p>



<p class="wp-block-paragraph"></p>
<p>The post <a href="https://static.dmcinfo.com/blog/20875/adding-siemens-mindsphere-tracking-to-the-dmc-drinkbot/">Adding Siemens MindSphere Tracking to the DMC DrinkBot</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
