<?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>Particle &#8211; IoT Expert</title>
	<atom:link href="https://iotexpert.com/category/iot-cloud/particle/feed/" rel="self" type="application/rss+xml" />
	<link>https://iotexpert.com</link>
	<description>Engineering for the Internet of Things</description>
	<lastBuildDate>Mon, 18 Sep 2017 11:48:54 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://iotexpert.com/wp-content/uploads/2017/01/cropped-Avatar-32x32.jpg</url>
	<title>Particle &#8211; IoT Expert</title>
	<link>https://iotexpert.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Particle Photon Configuration with Tinker Firmware</title>
		<link>https://iotexpert.com/particle-photon-configuration-with-tinker-firmware/</link>
					<comments>https://iotexpert.com/particle-photon-configuration-with-tinker-firmware/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Tue, 19 Sep 2017 10:59:54 +0000</pubDate>
				<category><![CDATA[Particle]]></category>
		<category><![CDATA[Particle Photon]]></category>
		<category><![CDATA[WIFI]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=4151</guid>

					<description><![CDATA[Summary In the last article I wrote about using a CY3280 MBR3 Shield on a WICED WiFI 943907AEVAL1F development kit at the GE MegaHackathon.  In the next article I will show you the WICED HTTP firmware that I wrote to connect to the Particle Photon which they were using (I have written about Particle Photon before).  Obviously, [&#8230;]]]></description>
										<content:encoded><![CDATA[<h1>Summary</h1>
<p>In the last <a href="https://iotexpert.com/2017/09/14/cy3280-mbr3-wiced-cyw943907/" target="_blank" rel="noopener">article</a> I wrote about using a CY3280 MBR3 Shield on a WICED WiFI 943907AEVAL1F development kit at the <a href="https://iotexpert.com/2017/09/11/cypress-development-kits-ge-mega-hackthon/" target="_blank" rel="noopener">GE MegaHackathon</a>.  In the next article I will show you the WICED HTTP firmware that I wrote to connect to the <a href="https://www.particle.io/products/hardware/photon-wifi-dev-kit" target="_blank" rel="noopener">Particle Photon</a> which they were using (I have written about Particle Photon <a href="https://iotexpert.com/category/devkits/particle-photon/" target="_blank" rel="noopener">before</a>).  Obviously, I like Particle Photon because it is a WICED 43362 WiFi Radio.  In this article, I am going to show you how to get a Particle Photon going with the Tinker firmware.  Then test it with the iOS app, the web console and finally using CURL.  The CURL is just a mechanism to send HTTP Posts to the Tinker firmware, exactly what I will do in the next article on the WICED development kit.</p>
<h1>Configure the Particle Photon</h1>
<p>When you get a fresh Particle Photon out of the box you need to get it introduced to your WiFi network, and attached to your console.  To do this, start by going to setup.particle.io and following the process.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.56.00-PM.png"><img fetchpriority="high" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.56.00-PM.png" alt="Particle Photon Configuration" width="797" height="788" class="alignnone wp-image-4158 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.56.00-PM.png 797w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.56.00-PM-100x100.png 100w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.56.00-PM-600x593.png 600w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.56.00-PM-300x297.png 300w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.56.00-PM-768x759.png 768w" sizes="(max-width: 797px) 100vw, 797px" /></a></p>
<p>&nbsp;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.56.16-PM.png"><img decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.56.16-PM.png" alt="Particle Photon Configuration" width="799" height="787" class="alignnone wp-image-4157 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.56.16-PM.png 799w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.56.16-PM-600x591.png 600w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.56.16-PM-300x295.png 300w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.56.16-PM-768x756.png 768w" sizes="(max-width: 799px) 100vw, 799px" /></a></p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.56.39-PM.png"><img decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.56.39-PM.png" alt="Particle Photon Configuration" width="903" height="919" class="alignnone wp-image-4156 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.56.39-PM.png 903w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.56.39-PM-600x611.png 600w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.56.39-PM-295x300.png 295w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.56.39-PM-768x782.png 768w" sizes="(max-width: 903px) 100vw, 903px" /></a></p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-17-at-11.50.54-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-17-at-11.50.54-AM.png" alt="Particle Photon Configuration" width="976" height="846" class="alignnone wp-image-4164 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-17-at-11.50.54-AM.png 976w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-17-at-11.50.54-AM-600x520.png 600w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-17-at-11.50.54-AM-300x260.png 300w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-17-at-11.50.54-AM-768x666.png 768w" sizes="(max-width: 976px) 100vw, 976px" /></a></p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.58.55-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.58.55-PM.png" alt="Particle Photon Configuration" width="916" height="843" class="alignnone wp-image-4155 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.58.55-PM.png 916w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.58.55-PM-600x552.png 600w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.58.55-PM-300x276.png 300w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.58.55-PM-768x707.png 768w" sizes="(max-width: 916px) 100vw, 916px" /></a></p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.59.28-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.59.28-PM.png" alt="Particle Photon Configuration" width="982" height="842" class="alignnone wp-image-4154 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.59.28-PM.png 982w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.59.28-PM-600x514.png 600w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.59.28-PM-300x257.png 300w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.59.28-PM-768x659.png 768w" sizes="(max-width: 982px) 100vw, 982px" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.59.56-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.59.56-PM.png" alt="Particle Photon Configuration" width="977" height="842" class="alignnone wp-image-4153 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.59.56-PM.png 977w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.59.56-PM-600x517.png 600w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.59.56-PM-300x259.png 300w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-4.59.56-PM-768x662.png 768w" sizes="(max-width: 977px) 100vw, 977px" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-5.00.06-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-5.00.06-PM.png" alt="Particle Photon Configuration" width="976" height="846" class="alignnone wp-image-4152 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-5.00.06-PM.png 976w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-5.00.06-PM-600x520.png 600w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-5.00.06-PM-300x260.png 300w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-16-at-5.00.06-PM-768x666.png 768w" sizes="(max-width: 976px) 100vw, 976px" /></a></p>
<h1>Testing with iPhone App</h1>
<p>One you have &#8220;claimed&#8221; your Particle Photon and it is connected to the network, then you can talk to it with the Particle iOS app.  Here is what it looked like when I started the App on my phone.  You can see the device called &#8220;iotexpert-example&#8221; (remember that is what I named it from above).  The &#8220;Elkhorn_creek&#8221; Photon is the one that I wrote about in this <a href="https://iotexpert.com/2017/03/30/particle-photon-elkhorn-creek-depth/" target="_blank" rel="noopener">article</a>.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4905.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4905-576x1024.png" alt="Particle Photon iOS App" width="576" height="1024" class="alignnone wp-image-4169 size-large" srcset="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4905-576x1024.png 576w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4905-600x1067.png 600w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4905-169x300.png 169w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4905-768x1365.png 768w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4905.png 1242w" sizes="(max-width: 576px) 100vw, 576px" /></a></p>
<p>Although the console says that I have the Tinker Firmware on the app, I wanted to make sure, so I use the iOS App to re-flash the Tinker Firmware.  You can do this by clicking the new device, then press the little &#8220;&#8230;&#8221; at the top right of the screen.  Finally click &#8220;Reflash Tinker&#8221;. It is awesome how fast that happens.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4912.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4912-576x1024.png" alt="Particle Photon iOS Flash Firmware" width="576" height="1024" class="alignnone wp-image-4176 size-large" srcset="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4912-576x1024.png 576w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4912-600x1067.png 600w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4912-169x300.png 169w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4912-768x1365.png 768w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4912.png 1242w" sizes="(max-width: 576px) 100vw, 576px" /></a></p>
<p>Once I am sure about the version of the Tinker firmware, I test to make sure that things are working correctly.  First I click on &#8220;D7&#8221;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4906.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4906-576x1024.png" alt="Particle Photon iOS Tinker App" width="576" height="1024" class="alignnone wp-image-4170 size-large" srcset="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4906-576x1024.png 576w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4906-600x1067.png 600w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4906-169x300.png 169w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4906-768x1365.png 768w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4906.png 1242w" sizes="(max-width: 576px) 100vw, 576px" /></a></p>
<p>Which brings up this screen where you can select digitalRead and digitalWrite.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4907.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4907-576x1024.png" alt="Particle Photon iOS Tinker App" width="576" height="1024" class="alignnone wp-image-4171 size-large" srcset="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4907-576x1024.png 576w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4907-600x1067.png 600w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4907-169x300.png 169w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4907-768x1365.png 768w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4907.png 1242w" sizes="(max-width: 576px) 100vw, 576px" /></a></p>
<p>Then when you press the button it will switch from high to low and vice versa.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4908.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4908-576x1024.png" alt="Particle Photon iOS Tinker App" width="576" height="1024" class="alignnone wp-image-4172 size-large" srcset="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4908-576x1024.png 576w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4908-600x1067.png 600w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4908-169x300.png 169w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4908-768x1365.png 768w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4908.png 1242w" sizes="(max-width: 576px) 100vw, 576px" /></a> <a href="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4909.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4909-576x1024.png" alt="Particle Photon iOS Tinker App" width="576" height="1024" class="alignnone wp-image-4173 size-large" srcset="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4909-576x1024.png 576w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4909-600x1067.png 600w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4909-169x300.png 169w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4909-768x1365.png 768w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4909.png 1242w" sizes="(max-width: 576px) 100vw, 576px" /></a></p>
<p>You can also call the API directly by pressing &#8220;inspect&#8221; then &#8220;Data&#8221;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4911.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4911-576x1024.png" alt="Particle Photon iOS digitalwrite Data Function" width="576" height="1024" class="alignnone wp-image-4174 size-large" srcset="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4911-576x1024.png 576w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4911-600x1067.png 600w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4911-169x300.png 169w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4911-768x1365.png 768w, https://iotexpert.com/wp-content/uploads/2017/09/IMG_4911.png 1242w" sizes="(max-width: 576px) 100vw, 576px" /></a></p>
<h1>Particle Photon Console</h1>
<p>In addition to using the iOS App, you can also interact with the Photon using the console.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-17-at-11.53.13-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-17-at-11.53.13-AM.png" alt="Particle Photon Console" width="1019" height="489" class="alignnone wp-image-4165 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-17-at-11.53.13-AM.png 1019w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-17-at-11.53.13-AM-600x288.png 600w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-17-at-11.53.13-AM-300x144.png 300w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-17-at-11.53.13-AM-768x369.png 768w" sizes="(max-width: 1019px) 100vw, 1019px" /></a></p>
<p>When I click on the &#8220;iotexpert-example&#8221; it brings up this screen where I can run the Tinker firmware functions.  In this case I ran &#8220;digitialwrite&#8221; with &#8220;D7,HIGH&#8221; which turns on the LED on the Photon.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-17-at-11.52.42-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-17-at-11.52.42-AM-1024x757.png" alt="Particle Photon Console" width="1024" height="757" class="alignnone wp-image-4166 size-large" srcset="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-17-at-11.52.42-AM-1024x757.png 1024w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-17-at-11.52.42-AM-600x444.png 600w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-17-at-11.52.42-AM-300x222.png 300w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-17-at-11.52.42-AM-768x568.png 768w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-17-at-11.52.42-AM.png 1333w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/09/IMG_4911.png"></a></p>
<h1>Testing the Particle Photon with CURL</h1>
<p>The Particle Cloud exposes an API which lets you send Restful API requests to specific devices.  The Unix tool CURL lets me type command line requests (which I will mimic in the next Article using WICED).  The first command that I send is and HTTP GET which will return a JSON document that describes the configuration on my Photon.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c" ">curl https://api.particle.io/v1/devices/iotexpert-example?access_token=1311f67269d6
</pre>
<p>You can see the device name etc in the JSON below.  It also shows that the Tinker firmware has four function built into it.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">{  
   "id":"2a001b000347353137323334",
   "name":"iotexpert-example",
   "last_app":null,
   "last_ip_address":"69.23.226.142",
   "last_heard":"2017-09-17T15:38:56.406Z",
   "product_id":6,
   "connected":true,
   "platform_id":6,
   "cellular":false,
   "notes":null,
   "status":"normal",
   "current_build_target":"0.5.3",
   "variables":{  

   },
   "functions":[  
      "digitalread",
      "digitalwrite",
      "analogread",
      "analogwrite"
   ]
}</pre>
<p>Then I can send a HTTP POST using Curl to turn on the D7 LED.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c"> curl https://api.spark.io/v1/devices/2a001b000347354/digitalwrite -d access_token=1311f67269d66b -d params=D7,HIGH</pre>
<p>You can see the Blue LED right next to D7 turns on.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/09/FullSizeRender.jpg"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/09/FullSizeRender-e1505663318933-1024x768.jpg" alt="Particle Photon" width="1024" height="768" class="alignnone wp-image-4162 size-large" srcset="https://iotexpert.com/wp-content/uploads/2017/09/FullSizeRender-e1505663318933-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2017/09/FullSizeRender-e1505663318933-600x450.jpg 600w, https://iotexpert.com/wp-content/uploads/2017/09/FullSizeRender-e1505663318933-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2017/09/FullSizeRender-e1505663318933-768x576.jpg 768w, https://iotexpert.com/wp-content/uploads/2017/09/FullSizeRender-e1505663318933.jpg 2038w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Particle Photon Tinker App</h1>
<p>I wondered where the Tinker App API was documented?  It turns out that the App is available in Particle library.  You can search by typing &#8220;tinker&#8221;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-18-at-7.36.38-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-18-at-7.36.38-AM-1024x648.png" alt="" width="1024" height="648" class="alignnone size-large wp-image-4183" srcset="https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-18-at-7.36.38-AM-1024x648.png 1024w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-18-at-7.36.38-AM-600x380.png 600w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-18-at-7.36.38-AM-300x190.png 300w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-18-at-7.36.38-AM-768x486.png 768w, https://iotexpert.com/wp-content/uploads/2017/09/Screen-Shot-2017-09-18-at-7.36.38-AM.png 1087w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></p>
<p>The section of code that matters is here.  The function takes a &#8220;String&#8221; and parses it.  It demands that the 2nd character be a PIN number between 0 and 7.  The first character be a capital &#8220;D&#8221;.  Then you need to have a &#8220;HIGH&#8221; (in caps) or a &#8220;LOW&#8221; (in caps)</p>
<pre class="start-line:32 lang:c++ decode:true">/*******************************************************************************
 * Function Name  : tinkerDigitalWrite
 * Description    : Sets the specified pin HIGH or LOW
 * Input          : Pin and value
 * Output         : None.
 * Return         : 1 on success and a negative number on failure
 *******************************************************************************/
int tinkerDigitalWrite(String command)
{
	bool value = 0;
	//convert ascii to integer
	int pinNumber = command.charAt(1) - '0';
	//Sanity check to see if the pin numbers are within limits
	if (pinNumber&lt; 0 || pinNumber &gt;7) return -1;

	if(command.substring(3,7) == "HIGH") value = 1;
	else if(command.substring(3,6) == "LOW") value = 0;
	else return -2;

	if(command.startsWith("D"))
	{
		pinMode(pinNumber, OUTPUT);
		digitalWrite(pinNumber, value);
		return 1;
	}
	else if(command.startsWith("A"))
	{
		pinMode(pinNumber+10, OUTPUT);
		digitalWrite(pinNumber+10, value);
		return 1;
	}
	else return -3;
}</pre>
<p>In order to access the digitialwrite function via the network, they publish it (and some others).</p>
<pre class="lang:c++ decode:true ">/***
 * All the based tinker functions are registered. You can add you own code.
 ***/

// This #include statement was automatically added by the Spark IDE.
#include "Tinker.h"

void setup() {
	//Register all the Tinker functions
	Spark.function("digitalread", tinkerDigitalRead);
	Spark.function("digitalwrite", tinkerDigitalWrite);
	Spark.function("analogread", tinkerAnalogRead);
	Spark.function("analogwrite", tinkerAnalogWrite);
}

void loop() {
}
</pre>
<p>When I first thought about the Tinker firmware I thought that it must be reasonably complex.  But it is not because it takes advantage of the Particle cloud functionality.  All in all what they did is very elegant and simple..</p>
<p>Now that it looks like my Particle Photon is working, in the next article I will show you WICED firmware to read the CapSense buttons and then Turn On/Off the LED on the Photon.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/particle-photon-configuration-with-tinker-firmware/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Particle Photon:  Elkhorn Creek Depth</title>
		<link>https://iotexpert.com/particle-photon-elkhorn-creek-depth/</link>
					<comments>https://iotexpert.com/particle-photon-elkhorn-creek-depth/#comments</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Thu, 30 Mar 2017 16:12:10 +0000</pubDate>
				<category><![CDATA[Particle]]></category>
		<category><![CDATA[Particle Photon]]></category>
		<category><![CDATA[Thing Speak]]></category>
		<category><![CDATA[WIFI]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=3296</guid>

					<description><![CDATA[Summary In the previous article I showed you all of the components of the Particle Photon Ecosystem.  All that is cool.  But what can you build?  I have written extensively about the Elkhorn Creek in my backyard, and the system that I built to monitor the water level.  As part of that series of articles I explained that [&#8230;]]]></description>
										<content:encoded><![CDATA[<h1>Summary</h1>
<p>In the previous article I showed you all of the components of the <a href="http://particle.io" target="_blank">Particle</a> Photon Ecosystem.  All that is cool.  But what can you build?  I have written extensively about the <a href="http://www.elkhorn-creek.org/creekServer/creekPlots/current.html" target="_blank">Elkhorn Creek</a> in my backyard, and the <a href="https://iotexpert.com/category/solutions/elkhorn-creek/" target="_blank">system</a> that I built to monitor the water level.  As part of that series of articles I explained that I have a 4-20ma current loop that turns pressure into water level read <a href="https://iotexpert.com/2016/01/25/the-elkhorn-creek/" target="_blank">here</a> .  In this article I will:</p>
<ul>
<li>Attach the Photon to my Creek System Current Loop</li>
<li>Write the Firmware in the Particle Cloud IDE to publish W</li>
<li>Send events to the Particle Cloud &amp; monitor</li>
<li>Use Webhooks to send the data to ThingSpeak.com</li>
</ul>
<h1>Attach Particle Photon to Creek System</h1>
<p>To interface to a 4-20mA current look you just attach it to a 51.1 ohm resistor to serve as a trans-impedence amplifier.  Here is the PSoC Creator schematic for the board:  Using this schematic, the system will generate a voltage between (51.1 Ohms * 4ma = 204.4mV) and (51.1Ohm * 20mA = 1022 mV).   This voltage can then be attached to an Analog To Digital Convertor, then converted digitally into a Pressure, then a water depth.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2016/02/creekOverallSchematic.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2016/02/creekOverallSchematic.png" alt="" width="902" height="666" class="alignnone size-full wp-image-553" srcset="https://iotexpert.com/wp-content/uploads/2016/02/creekOverallSchematic.png 902w, https://iotexpert.com/wp-content/uploads/2016/02/creekOverallSchematic-600x443.png 600w, https://iotexpert.com/wp-content/uploads/2016/02/creekOverallSchematic-300x222.png 300w" sizes="(max-width: 902px) 100vw, 902px" /></a></p>
<p>I decided that the easiest thing to do with the Particle Photon was to attach the pin A0 to the highside input.  This was easy as I put a loop on the <a href="https://iotexpert.com/2016/02/07/the-creek-board-1-1/" target="_blank">Creek Board</a>.  The loop is labeled &#8220;PRES&#8221;.  The picture is a bit ugly as I was standing in the dark in the rafters of my barn.  Sorry.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/03/IMG_3990.jpg"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/03/IMG_3990-e1490221901847.jpg" alt="Particle Photon attached to Elkhorn Creek Water Level 1.1" width="3024" height="4032" class="alignnone wp-image-3307 size-full" /></a></p>
<h1>Particle Photon Firmware</h1>
<p>When you look at the main loop of the firmware, lines 23-40 it does three things</p>
<ul>
<li>Reads the ADC voltage on Pin A0</li>
<li>Applies an Infinite Impulse Response Filter (IIR) with coefficients of 7/8 and 1/8.  This is low pass filter.</li>
<li>Turns the voltage into depth.  This is done by turning (4-20ma) into (0-15 psi) then PSI into Feet</li>
</ul>
<p>Then, on lines 34-39, I use the system time to figure out if it is time to publish again.  I publish every &#8220;INTERVAL&#8221;.</p>
<p>In order to test the Particle Cloud interface to the Photon, I setup all of the intermediate calculation of depth as &#8220;Particle.variable&#8221;s which allows me to inspect them remotely.</p>
<pre class="lang:c++ range:1-100 decode:true" title="Particle Photon Firmware">uint32_t nextTime; // when do you want to publish the data again
const uint32_t INTERVAL = (5*60*1000); // every 5 minutes in milliseconds
const double  MVPERCOUNT = (3330.0/4096.0); // 3300mv and 2^12 counts
uint32_t current;
uint32_t filter=0;
double depth;
double percent;
double psi;
double voltage;
double percentTemp;

void setup() {
    nextTime =  millis() + INTERVAL;
    // setup variables so that they can be polled
    Particle.variable("filter",filter);
    Particle.variable("adc",current);
    Particle.variable("percent",percent);
    Particle.variable("voltage",voltage);
    Particle.variable("psi",psi);
    Particle.variable("depth",depth);
}

void loop() {
   
   char buff[128];
   
    current = analogRead(A0);
    filter = ((filter&gt;&gt;3) * 7) + (current&gt;&gt;3); // IIR Filter with 7/8 and 1/8 coeffecients
    voltage  = ((double)filter) * MVPERCOUNT; // Convert ADC to Milivolts
    percent = ( voltage - (51.1*4.0) ) / (51.1 * (20.0-4.0)); // 51.1 ohm resistor... 4-20ma 
    psi = percent * 15.0; // Range of pressure sensor
    depth = psi / 0.53; // Magic 0.53psi per foot

   if(millis() &gt; nextTime)
   {
        sprintf(buff,"%.1f",depth);
        Particle.publish("CreekDepth",buff);
        nextTime = millis() + INTERVAL;
   }
}</pre>
<h1>Sending Events to the Particle Cloud &amp; Monitor</h1>
<p>Once I flashed the firmware with the very cool Over-The-Air Bootloader, I go to the Particle Console and click on my device.  As soon as I do that I see the &#8220;Particle.variable&#8221;s that I defined in the firmware.  One by one I press &#8220;get&#8221; and after a second the data is displayed on the screen.  I am not exactly sure how the exactly works, but it is cool.</p>
<h1><a href="https://iotexpert.com/wp-content/uploads/2017/03/consoleCloud.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/03/consoleCloud.png" alt="Particle Cloud Device Console" width="1500" height="790" class="alignnone wp-image-3308 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/03/consoleCloud.png 1500w, https://iotexpert.com/wp-content/uploads/2017/03/consoleCloud-600x316.png 600w, https://iotexpert.com/wp-content/uploads/2017/03/consoleCloud-300x158.png 300w, https://iotexpert.com/wp-content/uploads/2017/03/consoleCloud-768x404.png 768w, https://iotexpert.com/wp-content/uploads/2017/03/consoleCloud-1024x539.png 1024w" sizes="(max-width: 1500px) 100vw, 1500px" /></a></h1>
<p>After inspecting the variables, I go the Logs page and look to see what the events are.  You can see that every 5 minutes (about) there is an event called &#8220;CreekDepth&#8221; with a -0.0 or so. That is good as it means that the Particle Photon is publishing regularly.  The answer is 0.0 (or about 0.0) as the Elkhorn Creek if not doing anything right now.  The other events are part of the web hook that I setup (and will talk about in the next section).</p>
<h1><a href="https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-22-at-6.46.47-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-22-at-6.46.47-PM.png" alt="Particle Cloud Device Event Log" width="1483" height="1136" class="alignnone wp-image-3309 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-22-at-6.46.47-PM.png 1483w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-22-at-6.46.47-PM-600x460.png 600w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-22-at-6.46.47-PM-300x230.png 300w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-22-at-6.46.47-PM-768x588.png 768w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-22-at-6.46.47-PM-1024x784.png 1024w" sizes="(max-width: 1483px) 100vw, 1483px" /></a></h1>
<h1>Using WebHooks to send data to ThingSpeak.com</h1>
<p>Unless I am missing something, the Particle Cloud does not store your actual data.  They do have a mechanism to take Events from your devices and trigger a &#8220;WebHook&#8221;.  This is basically a RESTFul API call to another cloud.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/03/webhooks-overview.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/03/webhooks-overview.png" alt="Particle Cloud Webhooks" width="800" height="431" class="alignnone size-full wp-image-3324" srcset="https://iotexpert.com/wp-content/uploads/2017/03/webhooks-overview.png 800w, https://iotexpert.com/wp-content/uploads/2017/03/webhooks-overview-600x323.png 600w, https://iotexpert.com/wp-content/uploads/2017/03/webhooks-overview-300x162.png 300w, https://iotexpert.com/wp-content/uploads/2017/03/webhooks-overview-768x414.png 768w" sizes="(max-width: 800px) 100vw, 800px" /></a></p>
<p>They call these &#8220;integrations&#8221; and you configure them on the Console.  When you press &#8220;Integrations&#8221; you end up with this screen which gives you the option of editing a current webhook or creating a new one.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-23-at-6.00.05-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-23-at-6.00.05-AM.png" alt="Particle Cloud Integrations" width="1038" height="412" class="alignnone wp-image-3313 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-23-at-6.00.05-AM.png 1038w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-23-at-6.00.05-AM-600x238.png 600w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-23-at-6.00.05-AM-300x119.png 300w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-23-at-6.00.05-AM-768x305.png 768w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-23-at-6.00.05-AM-1024x406.png 1024w" sizes="(max-width: 1038px) 100vw, 1038px" /></a></p>
<p>When you click on &#8220;new integration&#8221; it gives you the option of connecting to Google, Microsoft Azure or Webhook.  I havent tried Google or Azure so for this article Ill stick with a Webhook.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-23-at-5.58.37-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-23-at-5.58.37-AM.png" alt="Particle Cloud New Integration" width="1104" height="365" class="alignnone wp-image-3312 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-23-at-5.58.37-AM.png 1104w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-23-at-5.58.37-AM-600x198.png 600w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-23-at-5.58.37-AM-300x99.png 300w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-23-at-5.58.37-AM-768x254.png 768w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-23-at-5.58.37-AM-1024x339.png 1024w" sizes="(max-width: 1104px) 100vw, 1104px" /></a></p>
<p>I started with a WebHook to the <a href="https://thingspeak.com" target="_blank">ThingSpeak</a> Cloud (because they show a nice <a href="https://docs.particle.io/guide/tools-and-features/webhooks/" target="_blank">example</a> in the documentation).  ThingSpeak is run by the <a href="https://www.mathworks.com" target="_blank">MathWorks</a> people (same as Matlab).  They call ThingSpeak &#8220;an open IoT with Matlab Analytics&#8221;.  OK sounds cool.  In order to use it to collect and display data I start by creating a new account.  Then I click on the &#8220;New Channel&#8221; button to create an &#8220;Elkhorn Creek Depth&#8221; channel.  On this screen I say that there will be only one field &#8220;CreekDepth&#8221;.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-23-at-6.21.36-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-23-at-6.21.36-AM.png" alt="ThingSpeak Create New Channel" width="663" height="551" class="alignnone wp-image-3314 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-23-at-6.21.36-AM.png 663w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-23-at-6.21.36-AM-600x499.png 600w, https://iotexpert.com/wp-content/uploads/2017/03/Screen-Shot-2017-03-23-at-6.21.36-AM-300x249.png 300w" sizes="(max-width: 663px) 100vw, 663px" /></a></p>
<p>In order to write data into this channel you need to have the API keys which give your Restful API call the authority to write into the database.  Press &#8220;API Keys&#8221; and you will see this screen.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/03/new-channel.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/03/new-channel.png" alt="ThingSpeak Channel API Keys" width="1355" height="1125" class="alignnone wp-image-3318 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/03/new-channel.png 1355w, https://iotexpert.com/wp-content/uploads/2017/03/new-channel-600x498.png 600w, https://iotexpert.com/wp-content/uploads/2017/03/new-channel-300x249.png 300w, https://iotexpert.com/wp-content/uploads/2017/03/new-channel-768x638.png 768w, https://iotexpert.com/wp-content/uploads/2017/03/new-channel-1024x850.png 1024w" sizes="(max-width: 1355px) 100vw, 1355px" /></a></p>
<p>Now that I have an active channel (and I know the channel number and API write key) I go back to the Particle Cloud Integrations tab and create a Webhook.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/03/webhook.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/03/webhook.png" alt="Particle Cloud Edit Integration" width="1310" height="1125" class="alignnone wp-image-3316 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/03/webhook.png 1310w, https://iotexpert.com/wp-content/uploads/2017/03/webhook-600x515.png 600w, https://iotexpert.com/wp-content/uploads/2017/03/webhook-300x258.png 300w, https://iotexpert.com/wp-content/uploads/2017/03/webhook-768x660.png 768w, https://iotexpert.com/wp-content/uploads/2017/03/webhook-1024x879.png 1024w" sizes="(max-width: 1310px) 100vw, 1310px" /></a></p>
<p>Each time the &#8220;CreekDepth&#8221; event occurs, the Particle Cloud will do an API call to the ThingSpeak cloud and insert the new data.  On the ThingSpeak Cloud there is a chart of the data, and a handy-dandy way to insert the chart into your webpage.  Here it is for the Elkhorn Creek showing the last 6 hours of data which is flat at the time of this writing, but maybe when you read this page it will be raining in Kentucky and you will see something interesting.</p>
<h1><iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/channels/246112/charts/1?bgcolor=%23ffffff&amp;color=%23d62020&amp;dynamic=true&amp;results=60&amp;type=line&amp;yaxismax=15&amp;yaxismin=0"></iframe></h1>
<p>I guess at this point I have a number of questions which I will leave to the future:</p>
<ul>
<li>Exactly what is the form of the request made to the ThingSpeak cloud?</li>
<li>What is the mapping between the event &#8211;&gt; API Request</li>
<li>What is the protocol for Particle.variables?</li>
<li>How does the Microsoft integration work?</li>
<li>How does the Google integration work?</li>
<li>How do I save power on the Photon?</li>
</ul>
<p>I suppose Ill leave these questions to future posts.  If you have other questions leave them as I comment and Ill take a crack at trying to figure them out.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/particle-photon-elkhorn-creek-depth/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
