<?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>Misc &#8211; IoT Expert</title>
	<atom:link href="https://iotexpert.com/category/misc/feed/" rel="self" type="application/rss+xml" />
	<link>https://iotexpert.com</link>
	<description>Engineering for the Internet of Things</description>
	<lastBuildDate>Tue, 15 Jun 2021 10:39:20 +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>Misc &#8211; IoT Expert</title>
	<link>https://iotexpert.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>A Standing Desk</title>
		<link>https://iotexpert.com/11238-2/</link>
					<comments>https://iotexpert.com/11238-2/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Mon, 14 Jun 2021 12:00:44 +0000</pubDate>
				<category><![CDATA[Misc]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=11238</guid>

					<description><![CDATA[Summary The installation of the AITERMINAL Electric Standing Desk Frame Dual Motor Height Adjustable Desk Motorized Stand Up Desk-White (Frame Only).  Which is only relevant to IoT in that I worked on this rather than finishing the really cool article that is coming next week.\ It allows me improved place to work The Story Last [&#8230;]]]></description>
										<content:encoded><![CDATA[<h1>Summary</h1>
<p>The installation of the AITERMINAL Electric Standing Desk Frame Dual Motor Height Adjustable Desk Motorized Stand Up Desk-White (Frame Only).  Which is only relevant to IoT in that</p>
<ol>
<li>I worked on this rather than finishing the really cool article that is coming next week.\</li>
<li>It allows me improved place to work</li>
</ol>
<h1>The Story</h1>
<p>Last week in California I used a standup desk&#8230; which I enjoyed.  I have one at my office in Lexington as well.  But, if you remember from this picture, I don&#8217;t have a standing setup at home.</p>
<p><a href="https://iotexpert.com/img_0157/"><img fetchpriority="high" decoding="async" src="https://iotexpert.com/wp-content/uploads/2020/09/IMG_0157-1024x636.jpg" alt="" width="1024" height="636" class="alignnone size-large wp-image-10683" srcset="https://iotexpert.com/wp-content/uploads/2020/09/IMG_0157-1024x636.jpg 1024w, https://iotexpert.com/wp-content/uploads/2020/09/IMG_0157-300x186.jpg 300w, https://iotexpert.com/wp-content/uploads/2020/09/IMG_0157-768x477.jpg 768w, https://iotexpert.com/wp-content/uploads/2020/09/IMG_0157-1536x954.jpg 1536w, https://iotexpert.com/wp-content/uploads/2020/09/IMG_0157-2048x1272.jpg 2048w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Since my desk is one solid top, I didn&#8217;t really know how I could make a change to standup.  But, one afternoon browsing on Amazon I found this:</p>
<p><a href="https://iotexpert.com/11238-2/screen-shot-2021-06-13-at-2-42-38-pm/" rel="attachment wp-att-11250"><img decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/06/Screen-Shot-2021-06-13-at-2.42.38-PM-1024x606.jpg" alt="" width="1024" height="606" class="alignnone size-large wp-image-11250" srcset="https://iotexpert.com/wp-content/uploads/2021/06/Screen-Shot-2021-06-13-at-2.42.38-PM-1024x606.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/06/Screen-Shot-2021-06-13-at-2.42.38-PM-300x177.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/06/Screen-Shot-2021-06-13-at-2.42.38-PM-768x454.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/06/Screen-Shot-2021-06-13-at-2.42.38-PM-1536x908.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/06/Screen-Shot-2021-06-13-at-2.42.38-PM-2048x1211.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/06/Screen-Shot-2021-06-13-at-2.42.38-PM-600x355.jpg 600w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></p>
<p>&nbsp;</p>
<p><a href="https://iotexpert.com/11238-2/screen-shot-2021-06-13-at-2-42-46-pm/" rel="attachment wp-att-11249"><img decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/06/Screen-Shot-2021-06-13-at-2.42.46-PM-1024x692.jpg" alt="" width="1024" height="692" class="alignnone size-large wp-image-11249" srcset="https://iotexpert.com/wp-content/uploads/2021/06/Screen-Shot-2021-06-13-at-2.42.46-PM-1024x692.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/06/Screen-Shot-2021-06-13-at-2.42.46-PM-300x203.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/06/Screen-Shot-2021-06-13-at-2.42.46-PM-768x519.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/06/Screen-Shot-2021-06-13-at-2.42.46-PM-600x405.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/06/Screen-Shot-2021-06-13-at-2.42.46-PM.jpg 1400w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Basically it is a stand-up-desk, but with no table top.  So I ordered it.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="https://iotexpert.com/11238-2/51fg7sb-sol-_ac_sl1500_/" rel="attachment wp-att-11248"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/06/51fG7sB-SOL._AC_SL1500_-1024x815.jpg" alt="" width="1024" height="815" class="alignnone size-large wp-image-11248" srcset="https://iotexpert.com/wp-content/uploads/2021/06/51fG7sB-SOL._AC_SL1500_-1024x815.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/06/51fG7sB-SOL._AC_SL1500_-300x239.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/06/51fG7sB-SOL._AC_SL1500_-768x611.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/06/51fG7sB-SOL._AC_SL1500_-600x478.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/06/51fG7sB-SOL._AC_SL1500_.jpg 1403w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>It came in an absolutely giant box.</p>
<p><a href="https://iotexpert.com/11238-2/img_0799/" rel="attachment wp-att-11242"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0799-1024x768.jpg" alt="" width="1024" height="768" class="alignnone size-large wp-image-11242" srcset="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0799-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0799-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0799-768x576.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0799-1536x1152.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0799-2048x1536.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0799-600x450.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>With a few statistics on the side</p>
<p><a href="https://iotexpert.com/11238-2/img_0800/" rel="attachment wp-att-11243"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0800-1024x768.jpg" alt="" width="1024" height="768" class="alignnone size-large wp-image-11243" srcset="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0800-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0800-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0800-768x576.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0800-1536x1152.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0800-2048x1536.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0800-600x450.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>The first thing to do is get out the &#8220;Modus Toolbox&#8221; thanks to my friends in Ukraine</p>
<p><a href="https://iotexpert.com/11238-2/img_0826/" rel="attachment wp-att-11257"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0826-1024x768.jpg" alt="" width="1024" height="768" class="alignnone size-large wp-image-11257" srcset="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0826-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0826-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0826-768x576.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0826-1536x1152.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0826-2048x1536.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0826-600x450.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>So, my lab assistant got to it.</p>
<p><a href="https://iotexpert.com/11238-2/img_0795/" rel="attachment wp-att-11241"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0795-768x1024.jpg" alt="" width="768" height="1024" class="alignnone size-large wp-image-11241" srcset="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0795-768x1024.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0795-225x300.jpg 225w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0795-1152x1536.jpg 1152w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0795-1536x2048.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0795-600x800.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0795-scaled.jpg 1920w" sizes="auto, (max-width: 768px) 100vw, 768px" /></a></p>
<p>Then we made a disaster area, by removing all the crap on my desk.</p>
<p><a href="https://iotexpert.com/11238-2/img_0792/" rel="attachment wp-att-11240"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0792-1024x768.jpg" alt="" width="1024" height="768" class="alignnone size-large wp-image-11240" srcset="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0792-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0792-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0792-768x576.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0792-1536x1152.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0792-2048x1536.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0792-600x450.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>After that we took the tabletop to the barn and ran a track saw on it.</p>
<p><a href="https://iotexpert.com/11238-2/img_0823/" rel="attachment wp-att-11256"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0823-768x1024.jpg" alt="" width="768" height="1024" class="alignnone size-large wp-image-11256" srcset="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0823-768x1024.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0823-225x300.jpg 225w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0823-1152x1536.jpg 1152w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0823-1536x2048.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0823-600x800.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0823-scaled.jpg 1920w" sizes="auto, (max-width: 768px) 100vw, 768px" /></a></p>
<p>Once the desk was removed&#8230; things were REALLY screwed up on the wall.</p>
<p><a href="https://iotexpert.com/11238-2/img_0794/" rel="attachment wp-att-11251"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0794-1024x768.jpg" alt="" width="1024" height="768" class="alignnone size-large wp-image-11251" srcset="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0794-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0794-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0794-768x576.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0794-1536x1152.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0794-2048x1536.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0794-600x450.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>And the side cabinet.</p>
<p><a href="https://iotexpert.com/11238-2/img_0801/" rel="attachment wp-att-11244"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0801-768x1024.jpg" alt="" width="768" height="1024" class="alignnone size-large wp-image-11244" srcset="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0801-768x1024.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0801-225x300.jpg 225w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0801-1152x1536.jpg 1152w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0801-1536x2048.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0801-600x800.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0801-scaled.jpg 1920w" sizes="auto, (max-width: 768px) 100vw, 768px" /></a></p>
<p>Here is Nicholas installing the sawed off table top onto the desk.</p>
<p><a href="https://iotexpert.com/11238-2/img_0811-2/" rel="attachment wp-att-11245"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0811-768x1024.jpg" alt="" width="768" height="1024" class="alignnone size-large wp-image-11245" srcset="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0811-768x1024.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0811-225x300.jpg 225w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0811-1152x1536.jpg 1152w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0811-1536x2048.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0811-600x800.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0811-scaled.jpg 1920w" sizes="auto, (max-width: 768px) 100vw, 768px" /></a></p>
<p>Here is the desk back in place.  You can see that I have started repairing the drywall.</p>
<p><a href="https://iotexpert.com/11238-2/img_0812/" rel="attachment wp-att-11246"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0812-768x1024.jpg" alt="" width="768" height="1024" class="alignnone size-large wp-image-11246" srcset="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0812-768x1024.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0812-225x300.jpg 225w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0812-1152x1536.jpg 1152w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0812-1536x2048.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0812-600x800.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0812-scaled.jpg 1920w" sizes="auto, (max-width: 768px) 100vw, 768px" /></a></p>
<p>Which is always an ugly job.</p>
<p><a href="https://iotexpert.com/11238-2/img_0814/" rel="attachment wp-att-11247"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0814-1024x768.jpg" alt="" width="1024" height="768" class="alignnone size-large wp-image-11247" srcset="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0814-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0814-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0814-768x576.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0814-1536x1152.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0814-2048x1536.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0814-600x450.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Now that the wall is fixed, Nicholas worked to repair the networking infrastructure.</p>
<p><a href="https://iotexpert.com/11238-2/img_0816/" rel="attachment wp-att-11252"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0816-1024x768.jpg" alt="" width="1024" height="768" class="alignnone size-large wp-image-11252" srcset="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0816-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0816-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0816-768x576.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0816-1536x1152.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0816-2048x1536.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0816-600x450.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>And here is back together, with the desk in the standing position</p>
<p><a href="https://iotexpert.com/11238-2/img_0820/" rel="attachment wp-att-11254"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0820-1024x768.jpg" alt="" width="1024" height="768" class="alignnone size-large wp-image-11254" srcset="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0820-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0820-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0820-768x576.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0820-1536x1152.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0820-2048x1536.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0820-600x450.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a> <a href="https://iotexpert.com/11238-2/img_0821/" rel="attachment wp-att-11255"></a></p>
<p>And a close up.</p>
<p><a href="https://iotexpert.com/11238-2/img_0821/" rel="attachment wp-att-11255"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0821-768x1024.jpg" alt="" width="768" height="1024" class="alignnone size-large wp-image-11255" srcset="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0821-768x1024.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0821-225x300.jpg 225w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0821-1152x1536.jpg 1152w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0821-1536x2048.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0821-600x800.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0821-scaled.jpg 1920w" sizes="auto, (max-width: 768px) 100vw, 768px" /></a></p>
<p>It is awesome because it is almost perfectly integrated into the old desk.  Notice that we trimmed about 5 inches off the back of the desk.</p>
<p><a href="https://iotexpert.com/11238-2/img_0827/" rel="attachment wp-att-11258"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0827-scaled-e1623612270196-1024x768.jpg" alt="" width="1024" height="768" class="alignnone wp-image-11258 size-large" srcset="https://iotexpert.com/wp-content/uploads/2021/06/IMG_0827-scaled-e1623612270196-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0827-scaled-e1623612270196-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0827-scaled-e1623612270196-768x576.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0827-scaled-e1623612270196-1536x1152.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0827-scaled-e1623612270196-2048x1536.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/06/IMG_0827-scaled-e1623612270196-600x450.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/11238-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>EW21: Lesson 0: Introduction &#038; Resources</title>
		<link>https://iotexpert.com/ew21-lesson-0-introduction-resources/</link>
					<comments>https://iotexpert.com/ew21-lesson-0-introduction-resources/#comments</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Wed, 24 Feb 2021 15:27:25 +0000</pubDate>
				<category><![CDATA[Embedded World 2021]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=10777</guid>

					<description><![CDATA[Summary Hello everyone.  This is lesson 0 of a series of 7 lessons about creating an IoT application using the Infineon ModusToolbox Software Environment to create a WiFi enabled drone.  In the next two hours we will build a remote control that uses the PSoC 6 MCU, WiFi, MQTT, CapSense and a 3-D Magnetic Joystick. [&#8230;]]]></description>
										<content:encoded><![CDATA[<h1>Summary</h1>
<p>Hello everyone.  This is lesson 0 of a series of 7 lessons about creating an IoT application using the Infineon ModusToolbox Software Environment to create a WiFi enabled drone.  In the next two hours we will build a remote control that uses the PSoC 6 MCU, WiFi, MQTT, CapSense and a 3-D Magnetic Joystick.  Then we will build the drone which will use a PSoC 6, WiFi, MQTT, CapSense and a BLDC motor controller.</p>
<p>What I will do today is take you lesson by lesson through the class and talk about how it all works and what you need to do.  When I built the class it was absolutely my goal to have every button click and line of code described.  That being said,  it is likely that I made some errors.  So, during the class you will be able to send messages to my team who will answer the questions, or ask me and I&#8217;ll answer live.  If you missed the class, that’s OK, you will be able to watch it on replay.  In addition if you have a question after the live stream is over, leave a comment here and I&#8217;ll answer.</p>
<p>I will attempt to go slowly enough for you to follow along, but if I go to fast, don’t worry you should be able to follow along with the instructions on this website.</p>
<p>Every lesson will have this table in it and you will be able to click to follow along with the different lessons.</p>
<p><span><h1>Embedded World 2021 - Infineon ModusToolbox PSoC 6 Drone </h1>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >#</th>
<th >Description</th>
</tr>
</thead>
<tbody>
<tr><td >0</td>
<td ><a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/" target="_blank" rel="noopener">Introduction &amp; Resources</a></td>
</tr>

<tr><td >1</td>
<td ><a href="https://iotexpert.com/ew21-lesson-1-freertos-capsense/" target="_blank" rel="noopener">FreeRTOS &amp; CapSense</a></td>
</tr>

<tr><td >2</td>
<td ><a href="https://iotexpert.com/ew21-lesson-2-joystick/" target="_blank" rel="noopener">3-D Magnetic Sensing XENSIV Joystick</a></td>
</tr>

<tr><td >3</td>
<td ><a href="https://iotexpert.com/ew21-lesson-3-wifi/" target="_blank" rel="noopener">WiFi</a></td>
</tr>

<tr><td >4</td>
<td ><a href="https://iotexpert.com/ew21-lesson-4-mqtt/" target="_blank" rel="noopener">MQTT</a></td>
</tr>

<tr><td >5</td>
<td ><a href="https://iotexpert.com/ew21-lesson-5-low-power/" target="_blank" rel="noopener">Low Power</a></td>
</tr>

<tr><td >6</td>
<td ><a href="https://iotexpert.com/ew21-lesson-6-motor-control/" target="_blank" rel="noopener">BLDC Motor Control</a></td>
</tr>

<tr><td >7</td>
<td ><a href="https://iotexpert.com/ew21-lesson-7-ws2812-led-strip/" target="_blank" rel="noopener">WS2812 Strip LEDs</a></td>
</tr>
</tbody></table></div></p>
<p>&nbsp;</p></span></p>
<p>Here is the overall system architecture:</p>
<p><a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/arch-1/" rel="attachment wp-att-10972"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/arch-1-1-1024x433.png" alt="" width="1024" height="433" class="alignnone size-large wp-image-10972" srcset="https://iotexpert.com/wp-content/uploads/2021/02/arch-1-1-1024x433.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/arch-1-1-300x127.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/arch-1-1-768x324.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/arch-1-1-1536x649.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/arch-1-1-600x253.png 600w, https://iotexpert.com/wp-content/uploads/2021/02/arch-1-1.png 1631w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>The Remote Control</h1>
<p>The remote control is built with two Infineon development boards</p>
<div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >Kit</th>
<th >Features</th>
</tr>
</thead>
<tbody>
<tr><td ><a href="https://www.cypress.com/documentation/development-kitsboards/psoc-6-wi-fi-bt-prototyping-kit-cy8cproto-062-4343w" target="_blank" rel="noopener">CY8CPROTO-062-4343W</a></td>
<td >PSoC 6,CYW4343W WiFi Bluetooth Combo Radio,CapSense</td>
</tr>

<tr><td ><a href="https://www.infineon.com/cms/en/product/evaluation-boards/tle493d-w2b6-ms2go/" target="_blank" rel="noopener">TLE493D-W2B6</a></td>
<td >XENSIV 3-D Magnetic Sensor</td>
</tr>
</tbody></table></div>
<p>Here are some pictures.</p>
<p>CY8CPROTO-062-4343W.  The top left of the board is a KitProg programmer.  The middle third on the left is the 4343W and the PSoC 6.  The bottom right are the CapSense buttons.  Just to the right of the programmer is a SD Card holder and S512FL Quad SPI Flash.</p>
<p><a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/img_0496/" rel="attachment wp-att-11018"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0496-1024x806.jpg" alt="" width="1024" height="806" class="alignnone size-large wp-image-11018" srcset="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0496-1024x806.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0496-300x236.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0496-768x605.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0496-1536x1210.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0496-2048x1613.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0496-600x473.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>This the the top of the TLE-493D-W2B6 3-D magnetic sensor board.  On the far right, the tiny 6 pin chip is the actual sensor.  The big hole to the left of the sensor is to mount a magnet.  The two chips on the left are used as a bridge to USB (if you are developing).  I attach to this device using the I2C interface pins.</p>
<p><a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/img_0503/" rel="attachment wp-att-11027"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0503-1024x402.jpg" alt="" width="1024" height="402" class="alignnone size-large wp-image-11027" srcset="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0503-1024x402.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0503-300x118.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0503-768x302.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0503-1536x604.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0503-2048x805.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0503-600x236.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Here is the back where you can see the SCL, SDA, Power and Ground labeled.  Unfortunately, they are in the wrong order to plug directly into the PSoC kit so Greg had to make a little wire switcher.</p>
<p><a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/img_0504/" rel="attachment wp-att-11026"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0504-1024x397.jpg" alt="" width="1024" height="397" class="alignnone size-large wp-image-11026" srcset="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0504-1024x397.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0504-300x116.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0504-768x297.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0504-1536x595.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0504-2048x793.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0504-600x232.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Here is the board with the really really cool 3-d printed joystick.  Simply two pieces of plastic with a magnet in the bottom.</p>
<p><a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/img_0494/" rel="attachment wp-att-11020"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0494-1024x914.jpg" alt="" width="1024" height="914" class="alignnone size-large wp-image-11020" srcset="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0494-1024x914.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0494-300x268.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0494-768x686.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0494-1536x1371.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0494-2048x1828.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0494-600x536.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>This picture show how the magnetic sense board is mounted onto the kit</p>
<p><a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/img_0505/" rel="attachment wp-att-11029"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0505-686x1024.jpg" alt="" width="686" height="1024" class="alignnone size-large wp-image-11029" srcset="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0505-686x1024.jpg 686w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0505-201x300.jpg 201w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0505-768x1146.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0505-1029x1536.jpg 1029w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0505-1372x2048.jpg 1372w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0505-600x895.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0505-scaled.jpg 1716w" sizes="auto, (max-width: 686px) 100vw, 686px" /></a></p>
<p>Here is the whole thing assembled.</p>
<p><a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/img_0493-2/" rel="attachment wp-att-11021"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0493-1024x595.jpg" alt="" width="1024" height="595" class="alignnone size-large wp-image-11021" srcset="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0493-1024x595.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0493-300x174.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0493-768x446.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0493-1536x893.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0493-2048x1191.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0493-600x349.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>The Crazy Drone</h1>
<p>The drone was built with</p>
<div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >Kit</th>
<th >Features</th>
</tr>
</thead>
<tbody>
<tr><td ><a href="https://www.cypress.com/documentation/development-kitsboards/psoc-62s2-wi-fi-bt-pioneer-kit-cy8ckit-062s2-43012" target="_blank" rel="noopener">CY8CKIT-062S2-43012</a></td>
<td >PSoC 6 + CYW43012 Low Power Bluetooth WiFI Combo</td>
</tr>

<tr><td ><span><a href="https://www.infineon.com/cms/en/product/evaluation-boards/bldc_shield_tle9879/" target="_blank" rel="noopener">TLE9879WXA40</a></td>
<td >BLDC Control Shield</span></td>
</tr>
</tbody></table></div>
<p>Here is a picture of the CY8CKIT-062S2-43012.  On the far right in the middle is the PSoC 6 and CYW43012.  In the lower right are the CapSense Buttons and Slider.  The KitProg IC is just below the top Arduino Header.</p>
<p><a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/img_0495/" rel="attachment wp-att-11017"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0495-1024x748.jpg" alt="" width="1024" height="748" class="alignnone size-large wp-image-11017" srcset="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0495-1024x748.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0495-300x219.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0495-768x561.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0495-1536x1122.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0495-600x438.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0495.jpg 2018w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>In order to drive the BLDC motor I use the TLE9879WXA40 Motor Shield.  This has everything needed to do Field Oriented Control of a 3-phase BLDC motor.  The Blue, Green and White wires are the 3-phases of the BLDC.  The Red and Black are simply +12V and Ground.  You interface from the PSoC to the BLDC shield via a SPI interface (attached to the Arduino pins).</p>
<p><a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/img_0497/" rel="attachment wp-att-11019"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0497-1024x781.jpg" alt="" width="1024" height="781" class="alignnone size-large wp-image-11019" srcset="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0497-1024x781.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0497-300x229.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0497-768x585.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0497-1536x1171.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0497-2048x1561.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0497-600x457.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>The BLDC motor is mounted into a 3-d printed holder.  The mount is attached to hollow carbon fiber tubes that run on bearings that you see below.  The wires run down through the tubes.</p>
<p><a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/img_0502/" rel="attachment wp-att-11016"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0502-768x1024.jpg" alt="" width="768" height="1024" class="alignnone size-large wp-image-11016" srcset="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0502-768x1024.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0502-225x300.jpg 225w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0502-1152x1536.jpg 1152w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0502-1536x2048.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0502-600x800.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0502-scaled.jpg 1920w" sizes="auto, (max-width: 768px) 100vw, 768px" /></a></p>
<p>At the bottom, the blue box just provides +12v to the drone and the PSoC board.</p>
<p><a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/img_0500/" rel="attachment wp-att-11015"></a> <a href="https://iotexpert.com/?attachment_id=11014" rel="attachment wp-att-11014"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0501-1024x662.jpg" alt="" width="1024" height="662" class="alignnone size-large wp-image-11014" srcset="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0501-1024x662.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0501-300x194.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0501-768x496.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0501-1536x993.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0501-2048x1324.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0501-600x388.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Here is a closer picture of the BLDC motor.</p>
<p><a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/img_0499/" rel="attachment wp-att-11013"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0499-1024x768.jpg" alt="" width="1024" height="768" class="alignnone size-large wp-image-11013" srcset="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0499-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0499-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0499-768x576.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0499-1536x1152.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0499-2048x1536.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0499-600x450.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Here is a picture of the whole crazy thing running.  If you look in the background you can see a top secret new PSoC motor controller.  Is that an Easter egg?</p>
<p><a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/img_0491-2/" rel="attachment wp-att-11024"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0491-2-1024x947.jpg" alt="" width="1024" height="947" class="alignnone size-large wp-image-11024" srcset="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0491-2-1024x947.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0491-2-300x277.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0491-2-768x710.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0491-2-1536x1420.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0491-2-2048x1894.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0491-2-600x555.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>And yes, it will cut your fingers off if you aren&#8217;t careful.</p>
<p><a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/img_0492-2/" rel="attachment wp-att-11022"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0492-2-1024x674.jpg" alt="" width="1024" height="674" class="alignnone size-large wp-image-11022" srcset="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0492-2-1024x674.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0492-2-300x198.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0492-2-768x506.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0492-2-1536x1012.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0492-2-600x395.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0492-2.jpg 1998w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Resources</h1>
<p>You will need a few things for this class:</p>
<ul>
<li><a href="https://www.cypress.com/products/modustoolbox-software-environment" target="_blank" rel="noopener">ModusToolbox Software Environment</a></li>
<li><a href="https://www.cypress.com/documentation/development-kitsboards/psoc-6-wi-fi-bt-prototyping-kit-cy8cproto-062-4343w" target="_blank" rel="noopener">PSoC 6 WiFi-BT Prototyping Kit (CY8CPROTO-062-4343W)</a></li>
<li>(optional) <a href="https://www.cypress.com/documentation/development-kitsboards/psoc-62s2-wi-fi-bt-pioneer-kit-cy8ckit-062s2-43012" target="_blank" rel="noopener">PSoC 62S2 WiFi-BT Pioneer Kit  (CY8CKIT-062S2-43012)</a></li>
<li>(optional) <a href="https://www.infineon.com/cms/en/product/evaluation-boards/tle493d-w2b6-ms2go/" target="_blank" rel="noopener">XENSIV TLE493D-W2B6 MS2GO and JOYSTICK FOR 3D 2 GO KIT</a></li>
<li>(optional) <a href="https://www.infineon.com/cms/en/product/evaluation-boards/bldc_shield_tle9879/" target="_blank" rel="noopener">BLDC SHIELD TLE9879TOBO1</a></li>
<li>(optional) Readytosky 2212 920KV Brushless Motors and Readytosky 10&#215;4.5 1045 Propeller</li>
</ul>
<h1>ModusToolbox Software Environment</h1>
<p>You can download Modus Toolbox from <a href="https://www.cypress.com/products/modustoolbox-software-environment" target="_blank" rel="noopener">here</a></p>
<p><a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/screen-shot-2021-02-24-at-7-20-59-am/" rel="attachment wp-att-11041"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-7.20.59-AM-1008x1024.jpg" alt="" width="1008" height="1024" class="alignnone size-large wp-image-11041" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-7.20.59-AM-1008x1024.jpg 1008w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-7.20.59-AM-295x300.jpg 295w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-7.20.59-AM-768x781.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-7.20.59-AM-1511x1536.jpg 1511w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-7.20.59-AM-600x610.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-7.20.59-AM.jpg 1716w" sizes="auto, (max-width: 1008px) 100vw, 1008px" /></a></p>
<h1>CY8CPROTO-062-4343W</h1>
<p>You can read all about this development kit on the <a href="https://www.cypress.com/documentation/development-kitsboards/psoc-6-wi-fi-bt-prototyping-kit-cy8cproto-062-4343w" target="_blank" rel="noopener">website</a> or in the <a href="https://www.cypress.com/file/457891/download" target="_blank" rel="noopener">KitGuide</a></p>
<p><a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/screen-shot-2021-02-24-at-6-48-47-am/" rel="attachment wp-att-11031"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.48.47-AM-817x1024.jpg" alt="" width="817" height="1024" class="alignnone size-large wp-image-11031" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.48.47-AM-817x1024.jpg 817w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.48.47-AM-239x300.jpg 239w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.48.47-AM-768x963.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.48.47-AM-1225x1536.jpg 1225w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.48.47-AM-1634x2048.jpg 1634w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.48.47-AM-600x752.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.48.47-AM.jpg 1752w" sizes="auto, (max-width: 817px) 100vw, 817px" /></a></p>
<h1>CY8CKIT-062S2-43012</h1>
<p>You can read all about this development kit on the <a href="https://www.cypress.com/documentation/development-kitsboards/psoc-62s2-wi-fi-bt-pioneer-kit-cy8ckit-062s2-43012" target="_blank" rel="noopener">website</a> or in the <a href="https://www.cypress.com/file/487006/download" target="_blank" rel="noopener">KitGuide</a></p>
<p><a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/screen-shot-2021-02-24-at-6-55-57-am/" rel="attachment wp-att-11032"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.55.57-AM-1024x713.jpg" alt="" width="1024" height="713" class="alignnone size-large wp-image-11032" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.55.57-AM-1024x713.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.55.57-AM-300x209.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.55.57-AM-768x535.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.55.57-AM-1536x1070.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.55.57-AM-2048x1426.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.55.57-AM-600x418.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p><a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/screen-shot-2021-02-24-at-6-56-23-am/" rel="attachment wp-att-11033"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.56.23-AM-1024x745.png" alt="" width="1024" height="745" class="alignnone size-large wp-image-11033" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.56.23-AM-1024x745.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.56.23-AM-300x218.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.56.23-AM-768x559.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.56.23-AM-1536x1118.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.56.23-AM-2048x1490.png 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.56.23-AM-600x437.png 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a> <a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/screen-shot-2021-02-24-at-6-56-41-am/" rel="attachment wp-att-11034"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.56.41-AM-1024x668.png" alt="" width="1024" height="668" class="alignnone size-large wp-image-11034" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.56.41-AM-1024x668.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.56.41-AM-300x196.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.56.41-AM-768x501.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.56.41-AM-1536x1002.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.56.41-AM-2048x1336.png 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.56.41-AM-600x391.png 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a> <a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/screen-shot-2021-02-24-at-6-56-48-am/" rel="attachment wp-att-11035"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.56.48-AM-1024x714.png" alt="" width="1024" height="714" class="alignnone size-large wp-image-11035" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.56.48-AM-1024x714.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.56.48-AM-300x209.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.56.48-AM-768x536.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.56.48-AM-1536x1071.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.56.48-AM-2048x1428.png 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.56.48-AM-600x418.png 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a> <a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/screen-shot-2021-02-24-at-6-56-56-am/" rel="attachment wp-att-11036"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.56.56-AM-1024x684.png" alt="" width="1024" height="684" class="alignnone size-large wp-image-11036" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.56.56-AM-1024x684.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.56.56-AM-300x200.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.56.56-AM-768x513.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.56.56-AM-1536x1025.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.56.56-AM-2048x1367.png 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-6.56.56-AM-600x400.png 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>TLE9879QXA40 BLDC Motor Controller</h1>
<p>You can read all about this development kit on the <a href="https://www.infineon.com/cms/en/product/evaluation-boards/bldc_shield_tle9879/" target="_blank" rel="noopener">website</a> or in the <a href="https://www.infineon.com/dgdl/Infineon-TLE9879QXA40-DS-v01_00-EN.pdf?fileId=5546d4625a888733015a89d10a283f20" target="_blank" rel="noopener">KitGuide</a></p>
<p><a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/img_0506/" rel="attachment wp-att-11037"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0506-1024x861.jpg" alt="" width="1024" height="861" class="alignnone size-large wp-image-11037" srcset="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0506-1024x861.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0506-300x252.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0506-768x645.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0506-1536x1291.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0506-2048x1721.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0506-600x504.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>XENSIV TLE493D</h1>
<p>You can read all about this development kit on the <a href="https://www.infineon.com/cms/en/product/evaluation-boards/tle493d-w2b6-ms2go/" target="_blank" rel="noopener">website</a> or in the <a href="https://www.infineon.com/dgdl/Infineon-Infineon-3DMS2GO_TLE493D-W2B6-UM-v01_01-EN-UserManual-v01_01-EN.pdf?fileId=5546d462636cc8fb016418342fea3f54" target="_blank" rel="noopener">KitGuide</a></p>
<p><a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/screen-shot-2021-02-24-at-7-08-06-am/" rel="attachment wp-att-11038"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-7.08.06-AM-1024x492.jpg" alt="" width="1024" height="492" class="alignnone size-large wp-image-11038" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-7.08.06-AM-1024x492.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-7.08.06-AM-300x144.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-7.08.06-AM-768x369.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-7.08.06-AM-1536x738.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-7.08.06-AM-2048x984.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-7.08.06-AM-600x288.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/ew21-lesson-0-introduction-resources/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>EW21: Lesson 1: FreeRTOS + CapSense</title>
		<link>https://iotexpert.com/ew21-lesson-1-freertos-capsense/</link>
					<comments>https://iotexpert.com/ew21-lesson-1-freertos-capsense/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Wed, 24 Feb 2021 15:26:52 +0000</pubDate>
				<category><![CDATA[Embedded World 2021]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=10776</guid>

					<description><![CDATA[Summary In lesson 1 we will create our first project, which like every good embedded project, will start with the blinking LED.  Then I will show you how to add a CapSense slider and two buttons.  At the end of lesson one you will have the &#8220;CapSense Task&#8221; colored green.  Here is the architecture: Learning [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><span><h1>Embedded World 2021 - Infineon ModusToolbox PSoC 6 Drone </h1>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >#</th>
<th >Description</th>
</tr>
</thead>
<tbody>
<tr><td >0</td>
<td ><a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/" target="_blank" rel="noopener">Introduction &amp; Resources</a></td>
</tr>

<tr><td >1</td>
<td ><a href="https://iotexpert.com/ew21-lesson-1-freertos-capsense/" target="_blank" rel="noopener">FreeRTOS &amp; CapSense</a></td>
</tr>

<tr><td >2</td>
<td ><a href="https://iotexpert.com/ew21-lesson-2-joystick/" target="_blank" rel="noopener">3-D Magnetic Sensing XENSIV Joystick</a></td>
</tr>

<tr><td >3</td>
<td ><a href="https://iotexpert.com/ew21-lesson-3-wifi/" target="_blank" rel="noopener">WiFi</a></td>
</tr>

<tr><td >4</td>
<td ><a href="https://iotexpert.com/ew21-lesson-4-mqtt/" target="_blank" rel="noopener">MQTT</a></td>
</tr>

<tr><td >5</td>
<td ><a href="https://iotexpert.com/ew21-lesson-5-low-power/" target="_blank" rel="noopener">Low Power</a></td>
</tr>

<tr><td >6</td>
<td ><a href="https://iotexpert.com/ew21-lesson-6-motor-control/" target="_blank" rel="noopener">BLDC Motor Control</a></td>
</tr>

<tr><td >7</td>
<td ><a href="https://iotexpert.com/ew21-lesson-7-ws2812-led-strip/" target="_blank" rel="noopener">WS2812 Strip LEDs</a></td>
</tr>
</tbody></table></div></p>
<p>&nbsp;</p></span></p>
<h1>Summary</h1>
<p>In lesson 1 we will create our first project, which like every good embedded project, will start with the blinking LED.  Then I will show you how to add a CapSense slider and two buttons.  At the end of lesson one you will have the &#8220;CapSense Task&#8221; colored green.  Here is the architecture:</p>
<p><a href="https://iotexpert.com/ew21-lesson-1-freertos-capsense/l1-arch/" rel="attachment wp-att-10974"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/l1-arch-1024x433.png" alt="" width="1024" height="433" class="alignnone size-large wp-image-10974" srcset="https://iotexpert.com/wp-content/uploads/2021/02/l1-arch-1024x433.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/l1-arch-300x127.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/l1-arch-768x324.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/l1-arch-1536x649.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/l1-arch-600x253.png 600w, https://iotexpert.com/wp-content/uploads/2021/02/l1-arch.png 1631w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Learning Objectives</h1>
<p>By the end of this lesson I would like you to know about:</p>
<ol>
<li>Creating and building your first ModusToolbox PSoC 6 MCU Project</li>
<li>The organization of a ModusToolbox project</li>
<li>An introduction to CapSense</li>
</ol>
<h1>Procedure</h1>
<p>We will follow these steps:</p>
<ol>
<li>Update manifest.loc</li>
<li>Create the new project</li>
<li>A Tour of your project</li>
<li>Test the basic project</li>
<li>Add a CapSense task header file</li>
<li>Add a CapSense task dot-c file</li>
<li>Update main.c</li>
<li>Test the CapSense</li>
</ol>
<ol></ol>
<h3>1. Update the manifest.loc</h3>
<p>After you install ModusToolbox, there is a subdirectory in your home directory called &#8220;.modustoolbox&#8221;.  You will almost never need to look in this directory.  However, it contains two interesting things:</p>
<ol>
<li>A cache of the libraries (more on this later)</li>
<li>A file called &#8220;manifest.loc&#8221; which will allow you to extend the functionality of Modus Toolbox.</li>
</ol>
<p>By adding a URL to the manifest.loc you can add in new</p>
<ol>
<li>Middleware</li>
<li>Board Support Packages</li>
<li>Example Projects</li>
</ol>
<p>To make the Embedded World easier, I have extended ModusToolbox to give you access to some example projects and libraries that I created.  To get access you need to add the line &#8220;https://github.com/iotexpert/mtb2-iotexpert-manifests/raw/master/iotexpert-super-manifest.xml&#8221; into the manifest.loc file.  You can do that with any editor.  Here is how it looks on my Mac.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">arh ~ $ cd .modustoolbox/
arh .modustoolbox $ ls
cache		manifest.loc	manifest.loc~
arh .modustoolbox $ more manifest.loc
https://github.com/iotexpert/mtb2-iotexpert-manifests/raw/master/iotexpert-super-manifest.xml
</pre>
<h3>2. Create the new project</h3>
<p>Now I start the new project creator from the start menu.  Our first project will be using the CY8CPROTO-062-4343W, pick it and press next.</p>
<p><a href="https://iotexpert.com/ew21-lesson-1-freertos-capsense/screen-shot-2021-02-22-at-5-40-40-pm/" rel="attachment wp-att-10840"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-5.40.40-PM-1024x710.jpg" alt="" width="1024" height="710" class="alignnone size-large wp-image-10840" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-5.40.40-PM-1024x710.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-5.40.40-PM-300x208.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-5.40.40-PM-768x532.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-5.40.40-PM-1536x1064.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-5.40.40-PM-2048x1419.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-5.40.40-PM-600x416.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>In the filter box type &#8220;IoT&#8221; which will filter to my template projects.  To start with we will use the &#8220;IoT Expert FreeRTOS Template&#8221; which is a basic project I created that gives you a blinking LED, a UART console and FreeRTOS.  Pick that and give it a sensible name.</p>
<p><a href="https://iotexpert.com/ew21-lesson-1-freertos-capsense/screen-shot-2021-02-22-at-5-42-12-pm/" rel="attachment wp-att-10841"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-5.42.12-PM-1024x709.jpg" alt="" width="1024" height="709" class="alignnone size-large wp-image-10841" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-5.42.12-PM-1024x709.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-5.42.12-PM-300x208.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-5.42.12-PM-768x532.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-5.42.12-PM-1536x1063.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-5.42.12-PM-2048x1418.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-5.42.12-PM-600x415.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>After a bit of processing you will have a new application, press close.</p>
<p><a href="https://iotexpert.com/ew21-lesson-1-freertos-capsense/screen-shot-2021-02-22-at-6-00-13-pm/" rel="attachment wp-att-10842"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.00.13-PM-1024x223.png" alt="" width="1024" height="223" class="alignnone size-large wp-image-10842" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.00.13-PM-1024x223.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.00.13-PM-300x65.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.00.13-PM-768x167.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.00.13-PM-1536x334.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.00.13-PM-2048x445.png 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.00.13-PM-600x130.png 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>For this class I am going to use Visual Studio Code.  ModusToolbox also has an Eclipse IDE which you can use, or you can use the command line, IAR, or MicroVision &#8211; it&#8217;s entirely up to you.  To tell Visual Studio code about my project I will run &#8220;make vscode&#8221; which will build a vscode project.  Then I run vscode with &#8220;code .&#8221;</p>
<p><a href="https://iotexpert.com/ew21-lesson-1-freertos-capsense/screen-shot-2021-02-22-at-6-08-43-pm/" rel="attachment wp-att-10844"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.08.43-PM-888x1024.jpg" alt="" width="888" height="1024" class="alignnone size-large wp-image-10844" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.08.43-PM-888x1024.jpg 888w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.08.43-PM-260x300.jpg 260w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.08.43-PM-768x885.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.08.43-PM-1332x1536.jpg 1332w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.08.43-PM-600x692.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.08.43-PM.jpg 1530w" sizes="auto, (max-width: 888px) 100vw, 888px" /></a><a href="https://iotexpert.com/ew21-lesson-1-freertos-capsense/screen-shot-2021-02-22-at-6-06-49-pm/" rel="attachment wp-att-10843"></a></p>
<p>The make vscode will build all of the files you need including a workspace.  Click&#8221;Open Workspace&#8221;</p>
<p><a href="https://iotexpert.com/?attachment_id=10846" rel="attachment wp-att-10846"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.10.16-PM.png" alt="" width="946" height="292" class="alignnone size-large wp-image-10846" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.10.16-PM.png 946w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.10.16-PM-300x93.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.10.16-PM-768x237.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.10.16-PM-600x185.png 600w" sizes="auto, (max-width: 946px) 100vw, 946px" /></a></p>
<h3>3. A Tour of your Project</h3>
<p>Start a file browser and look around inside your project.</p>
<p><a href="https://iotexpert.com/ew21-lesson-1-freertos-capsense/screen-shot-2021-02-22-at-6-06-49-pm/" rel="attachment wp-att-10843"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.06.49-PM-1024x773.jpg" alt="" width="1024" height="773" class="alignnone size-large wp-image-10843" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.06.49-PM-1024x773.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.06.49-PM-300x226.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.06.49-PM-768x580.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.06.49-PM-1536x1159.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.06.49-PM-600x453.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.06.49-PM.jpg 1638w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>You can also see these in Visual Studio Code.</p>
<p><a href="https://iotexpert.com/ew21-lesson-1-freertos-capsense/screen-shot-2021-02-22-at-6-12-36-pm/" rel="attachment wp-att-10847"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.12.36-PM-1024x817.jpg" alt="" width="1024" height="817" class="alignnone size-large wp-image-10847" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.12.36-PM-1024x817.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.12.36-PM-300x239.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.12.36-PM-768x613.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.12.36-PM-1536x1225.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.12.36-PM-2048x1634.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.12.36-PM-600x479.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h3>4. Test the basic project</h3>
<p>Now click the debug icon along the left and click the play button to build the project, program it and launch the debugger.</p>
<p>(You can use the drop-down menu to select &#8220;Program (KitProg3_MiniProg4)&#8221; and then click the play button if you just want to build and program without launching the debugger.)</p>
<p><a href="https://iotexpert.com/ew21-lesson-1-freertos-capsense/screen-shot-2021-02-22-at-6-16-29-pm/" rel="attachment wp-att-10850"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.16.29-PM.png" alt="" width="832" height="588" class="alignnone size-full wp-image-10850" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.16.29-PM.png 832w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.16.29-PM-300x212.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.16.29-PM-768x543.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.16.29-PM-600x424.png 600w" sizes="auto, (max-width: 832px) 100vw, 832px" /></a></p>
<p>Notice on the console a bunch of stuff comes ripping out&#8230; then it programs your development board.</p>
<p><a href="https://iotexpert.com/ew21-lesson-1-freertos-capsense/screen-shot-2021-02-22-at-6-13-07-pm/" rel="attachment wp-att-10848"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.13.07-PM-1024x763.png" alt="" width="1024" height="763" class="alignnone size-large wp-image-10848" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.13.07-PM-1024x763.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.13.07-PM-300x223.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.13.07-PM-768x572.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.13.07-PM-1536x1144.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.13.07-PM-600x447.png 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.13.07-PM.png 1842w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Once that is done the debugger starts and runs until the start of main.  Press play to get things going.</p>
<p><a href="https://iotexpert.com/ew21-lesson-1-freertos-capsense/screen-shot-2021-02-22-at-6-16-52-pm/" rel="attachment wp-att-10851"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.16.52-PM-1024x815.jpg" alt="" width="1024" height="815" class="alignnone size-large wp-image-10851" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.16.52-PM-1024x815.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.16.52-PM-300x239.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.16.52-PM-768x611.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.16.52-PM-1536x1223.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.16.52-PM-2048x1631.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.16.52-PM-600x478.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h3>5. Add a CapSense task header file</h3>
<p>Now that we have a functioning blinking LED project, let&#8217;s add CapSense.  Remember from the architecture picture above that I am going to have a task just for CapSense.  Start by making the public header file called &#8220;capsense_task.h&#8221;</p>
<p><a href="https://iotexpert.com/ew21-lesson-1-freertos-capsense/screen-shot-2021-02-22-at-6-19-09-pm/" rel="attachment wp-att-10853"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.19.09-PM.png" alt="" width="880" height="828" class="alignnone size-large wp-image-10853" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.19.09-PM.png 880w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.19.09-PM-300x282.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.19.09-PM-768x723.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.19.09-PM-600x565.png 600w" sizes="auto, (max-width: 880px) 100vw, 880px" /></a></p>
<p>In that file there will only be the definition of the task.</p>
<p><a href="https://iotexpert.com/ew21-lesson-1-freertos-capsense/screen-shot-2021-02-22-at-6-19-46-pm/" rel="attachment wp-att-10852"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.19.46-PM-1024x474.png" alt="" width="1024" height="474" class="alignnone size-large wp-image-10852" data-wp-editing="1" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.19.46-PM-1024x474.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.19.46-PM-300x139.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.19.46-PM-768x355.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.19.46-PM-1536x711.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.19.46-PM-600x278.png 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.19.46-PM.png 2032w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h3>6. Add a CapSense task dot-c file</h3>
<p>Now we will create capsense_task.c.  In that file, you will need some includes to bring in the Infineon drivers.  After the includes I will define several functions</p>
<ol>
<li>capsense_init: Starts up the CapSense block</li>
<li>process_touch: Figures out what is being touched on the buttons and slider</li>
<li>capsense_isr: Used by the CapSense middleware to process the CapSense interrupt</li>
<li>capsense_end_of_scan_callback: Tells your application when the scanning is done</li>
<li>capsense_register_deepsleep: This allows the CPU to know when it can go to Deep Sleep without interfering with CapSense</li>
</ol>
<p>Finally I will define a semaphore to use to block my task until the CapSense scanning is done.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#include &lt;stdio.h&gt;

#include "cybsp.h"
#include "cyhal.h"
#include "cycfg.h"
#include "cycfg_capsense.h"

#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"

#include "capsense_task.h"

static void capsense_init(void);
static void process_touch(void);
static void capsense_isr(void);
static void capsense_end_of_scan_callback(cy_stc_active_scan_sns_t* active_scan_sns_ptr);
static void capsense_register_deepsleep(void);
static QueueHandle_t capsense_done; // Semaphore set in Capsense Callback End of Scan</pre>
<p>The capsense_task function is called by FreeRTOS when it starts up.  This function does what it says</p>
<ol>
<li>Sets up a sempahore</li>
<li>Initializes the CapSense</li>
<li>Starts scanning</li>
<li>Waits for a scan to complete using a semaphore</li>
<li>Process the widgets</li>
<li>Looks at the touches</li>
<li>Starts another scan</li>
<li>Waits, then loops back</li>
</ol>
<pre class="EnlighterJSRAW" data-enlighter-language="c">/*******************************************************************************
* Function Name: task_capsense
********************************************************************************
* Summary:
*  Task that initializes the CapSense block and processes the touch input.
*
* Parameters:
*  void *param : Task parameter defined during task creation (unused)
*
*******************************************************************************/
void capsense_task(void* param)
{
    (void)param;

    capsense_done = xQueueCreateCountingSemaphore(1,0);

    capsense_init();

    Cy_CapSense_ScanAllWidgets(&amp;cy_capsense_context);

    for(;;)
    {
        xSemaphoreTake(capsense_done,portMAX_DELAY);

        Cy_CapSense_ProcessAllWidgets(&amp;cy_capsense_context);
        process_touch();
        Cy_CapSense_ScanAllWidgets(&amp;cy_capsense_context);
        vTaskDelay(50); // ~20hz update
    }
}
</pre>
<p>To initialize the CapSense you need to</p>
<ol>
<li>Initialize the  CapSense block</li>
<li>Setup the CapSense interrupt</li>
<li>Register the DeepSleep function</li>
<li>Ask to be called back when a scan finishes</li>
<li>Enable the CapSense block</li>
</ol>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">/*******************************************************************************
* Function Name: capsense_init
********************************************************************************
* Summary:
*  This function initializes the CSD HW block, and configures the CapSense
*  interrupt.
*******************************************************************************/
static void capsense_init(void)
{
    Cy_CapSense_Init(&amp;cy_capsense_context);
    
    static const cy_stc_sysint_t capSense_intr_config =
    {
        .intrSrc = csd_interrupt_IRQn,
        .intrPriority = 7,
    };

    /* Initialize CapSense interrupt */
    Cy_SysInt_Init(&amp;capSense_intr_config, &amp;capsense_isr);
    NVIC_ClearPendingIRQ(capSense_intr_config.intrSrc);
    NVIC_EnableIRQ(capSense_intr_config.intrSrc);

    capsense_register_deepsleep();
    Cy_CapSense_RegisterCallback(CY_CAPSENSE_END_OF_SCAN_E,
                                              capsense_end_of_scan_callback, &amp;cy_capsense_context);
    
    Cy_CapSense_Enable(&amp;cy_capsense_context);
}
</pre>
<p>Infineon provides the ISR which is part of the CapSense scanning engine</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">/*******************************************************************************
* Function Name: capsense_isr
********************************************************************************
* Summary:
*  Wrapper function for handling interrupts from CSD block.
*
*******************************************************************************/
static void capsense_isr(void)
{
    Cy_CapSense_InterruptHandler(CYBSP_CSD_HW, &amp;cy_capsense_context);
}</pre>
<p>When a scan is done we want to unlock the capsense_task by giving the semaphore.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">/*******************************************************************************
* Function Name: capsense_end_of_scan_callback
********************************************************************************
* Summary:
*  CapSense end of scan callback function. This function sends a command to
*  CapSense task to process scan.
*
* Parameters:
*  cy_stc_active_scan_sns_t * active_scan_sns_ptr (unused)
*
*******************************************************************************/
static void capsense_end_of_scan_callback(cy_stc_active_scan_sns_t* active_scan_sns_ptr)
{
    BaseType_t xYieldRequired;

    (void)active_scan_sns_ptr;
    xYieldRequired = xSemaphoreGiveFromISR(capsense_done,&amp;xYieldRequired);

    portYIELD_FROM_ISR(xYieldRequired);
}</pre>
<p>The DeepSleep registration function looks like this:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">/*******************************************************************************
* Function Name: capsense_register_deepsleep
********************************************************************************
* Summary:
*  Wrapper function for setting up the Deep Sleep callback for CapSense.
*  This is necessary so that a transition from active to Deep Sleep does not
*  occur during a CapSense scan.
*
*  See the "MTB CAT1 Peripheral driver library documentation &gt; PDL API Reference &gt; SysPM"
*  link in the Quick Panel Documentation for information on setting up the SysPm callbacks
*******************************************************************************/
static void capsense_register_deepsleep(void)
{
    static cy_stc_syspm_callback_params_t callback_params =
    {
        .base       = CYBSP_CSD_HW,
        .context    = &amp;cy_capsense_context
    };

    static cy_stc_syspm_callback_t capsense_deep_sleep_cb =
    {
        Cy_CapSense_DeepSleepCallback,
        CY_SYSPM_DEEPSLEEP,
        0,
        &amp;callback_params,
        NULL,
        NULL
    };

    Cy_SysPm_RegisterCallback(&amp;capsense_deep_sleep_cb);
}</pre>
<p>The last bit of magic is the processing of the touches.  We will</p>
<ol>
<li>Look at the buttons</li>
<li>If they are pressed do a print out</li>
<li>Look a the slider (which gives you a value between 0 and 300).</li>
<li>If the slider is being pressed, print out the value</li>
<li>Save the current state of the buttons and slider for next time around.</li>
</ol>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">/*******************************************************************************
* Function Name: process_touch
*******************************************************************************/
static void process_touch(void)
{
    /* Variables used to store previous touch information */
    static uint32_t button0_status_prev = 0;
    static uint32_t button1_status_prev = 0;
    static uint16_t slider_pos_prev = 0;

    uint32_t button0_status = 0;
    uint32_t button1_status = 0;
    uint16_t slider_pos = 0;
    uint8_t slider_touched = 0;
    cy_stc_capsense_touch_t *slider_touch;

// Process the buttons

    button0_status = Cy_CapSense_IsWidgetActive(CY_CAPSENSE_BUTTON0_WDGT_ID,&amp;cy_capsense_context);
    button1_status = Cy_CapSense_IsSensorActive( CY_CAPSENSE_BUTTON1_WDGT_ID, CY_CAPSENSE_BUTTON1_SNS0_ID, &amp;cy_capsense_context);

    if((0u != button0_status) &amp;&amp; (0u == button0_status_prev))
    {
        printf("Button 0 pressed\n");
    }

    if((0u != button1_status) &amp;&amp; (0u == button1_status_prev))
    {
        printf("Button 1 pressed\n");
    }

// Process the slider
    slider_touch = Cy_CapSense_GetTouchInfo( CY_CAPSENSE_LINEARSLIDER0_WDGT_ID, &amp;cy_capsense_context);
    slider_pos = (slider_touch-&gt;ptrPosition-&gt;x / 3); // Transform 0-300 into 0-100
    slider_touched = slider_touch-&gt;numPosition;

    if((0u != slider_touched) &amp;&amp; (slider_pos_prev != slider_pos ))
    {
        printf("Slider position %d\n",slider_pos);
    }

    button0_status_prev = button0_status;
    button1_status_prev = button1_status;
    slider_pos_prev = slider_pos;
}</pre>
<h3>7. Update main.c</h3>
<p>In main.c we need to include the capsense_task header file</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">#include "capsense_task.h"
</pre>
<p>And startup the capsense_task</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">xTaskCreate(capsense_task, "CapSense", configMINIMAL_STACK_SIZE*4, NULL, 1, 0 );
</pre>
<h3>8. Test the CapSense</h3>
<p>Program your kit and you will be able to press the buttons and slider.</p>
<p><a href="https://iotexpert.com/ew21-lesson-1-freertos-capsense/screen-shot-2021-02-22-at-6-32-39-pm/" rel="attachment wp-att-10855"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.32.39-PM-1024x330.png" alt="" width="1024" height="330" class="alignnone size-large wp-image-10855" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.32.39-PM-1024x330.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.32.39-PM-300x97.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.32.39-PM-768x248.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.32.39-PM-1536x496.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.32.39-PM-600x194.png 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-6.32.39-PM.png 1618w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Resources for Project</h1>
<p>Remember above when I started the project creator there was a list of projects.  This exact completed project is available to you as &#8220;IoT Expert Embedded World 2021 Lesson1&#8221;</p>
<p><a href="https://iotexpert.com/ew21-lesson-1-freertos-capsense/screen-shot-2021-02-22-at-4-32-53-pm/" rel="attachment wp-att-10814"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.32.53-PM-1024x584.png" alt="" width="1024" height="584" class="alignnone size-large wp-image-10814" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.32.53-PM-1024x584.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.32.53-PM-300x171.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.32.53-PM-768x438.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.32.53-PM-1536x876.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.32.53-PM-2048x1168.png 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.32.53-PM-600x342.png 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>You can also clone this project from git@github.com:iotexpert/ew21-lesson1.git or https://github.com/iotexpert/ew21-lesson1.git</p>
<div>For reference, here is the whole capsense_task.c file in one chunk</div>
<div>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#include &lt;stdio.h&gt;

#include "cybsp.h"
#include "cyhal.h"
#include "cycfg.h"
#include "cycfg_capsense.h"

#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"

#include "capsense_task.h"

static void capsense_init(void);
static void process_touch(void);
static void capsense_isr(void);
static void capsense_end_of_scan_callback(cy_stc_active_scan_sns_t* active_scan_sns_ptr);
static void capsense_register_deepsleep(void);

static QueueHandle_t capsense_done; // Semaphore set in Capsense Callback End of Scan

/*******************************************************************************
* Function Name: task_capsense
********************************************************************************
* Summary:
*  Task that initializes the CapSense block and processes the touch input.
*
* Parameters:
*  void *param : Task parameter defined during task creation (unused)
*
*******************************************************************************/
void capsense_task(void* param)
{
    (void)param;

    capsense_done = xQueueCreateCountingSemaphore(1,0);

    capsense_init();

    Cy_CapSense_ScanAllWidgets(&amp;cy_capsense_context);

    for(;;)
    {
        xSemaphoreTake(capsense_done,portMAX_DELAY);

        Cy_CapSense_ProcessAllWidgets(&amp;cy_capsense_context);
        process_touch();
        Cy_CapSense_ScanAllWidgets(&amp;cy_capsense_context);
        vTaskDelay(50); // ~20hz update
    }
}

/*******************************************************************************
* Function Name: process_touch
*******************************************************************************/
static void process_touch(void)
{
    /* Variables used to store previous touch information */
    static uint32_t button0_status_prev = 0;
    static uint32_t button1_status_prev = 0;
    static uint16_t slider_pos_prev = 0;

    uint32_t button0_status = 0;
    uint32_t button1_status = 0;
    uint16_t slider_pos = 0;
    uint8_t slider_touched = 0;
    cy_stc_capsense_touch_t *slider_touch;

// Process the buttons

    button0_status = Cy_CapSense_IsWidgetActive(CY_CAPSENSE_BUTTON0_WDGT_ID,&amp;cy_capsense_context);
    button1_status = Cy_CapSense_IsSensorActive( CY_CAPSENSE_BUTTON1_WDGT_ID, CY_CAPSENSE_BUTTON1_SNS0_ID, &amp;cy_capsense_context);

    if((0u != button0_status) &amp;&amp; (0u == button0_status_prev))
    {
        printf("Button 0 pressed\n");
    }

    if((0u != button1_status) &amp;&amp; (0u == button1_status_prev))
    {
        printf("Button 1 pressed\n");
    }

// Process the slider
    slider_touch = Cy_CapSense_GetTouchInfo( CY_CAPSENSE_LINEARSLIDER0_WDGT_ID, &amp;cy_capsense_context);
    slider_pos = (slider_touch-&gt;ptrPosition-&gt;x / 3); // Transform 0-300 into 0-100
    slider_touched = slider_touch-&gt;numPosition;

    if((0u != slider_touched) &amp;&amp; (slider_pos_prev != slider_pos ))
    {
        printf("Slider position %d\n",slider_pos);
    }

    button0_status_prev = button0_status;
    button1_status_prev = button1_status;
    slider_pos_prev = slider_pos;
}


/*******************************************************************************
* Function Name: capsense_init
********************************************************************************
* Summary:
*  This function initializes the CSD HW block, and configures the CapSense
*  interrupt.
*******************************************************************************/
static void capsense_init(void)
{
    Cy_CapSense_Init(&amp;cy_capsense_context);
    
    static const cy_stc_sysint_t capSense_intr_config =
    {
        .intrSrc = csd_interrupt_IRQn,
        .intrPriority = 7,
    };

    /* Initialize CapSense interrupt */
    Cy_SysInt_Init(&amp;capSense_intr_config, &amp;capsense_isr);
    NVIC_ClearPendingIRQ(capSense_intr_config.intrSrc);
    NVIC_EnableIRQ(capSense_intr_config.intrSrc);

    capsense_register_deepsleep();

    Cy_CapSense_RegisterCallback(CY_CAPSENSE_END_OF_SCAN_E,
                                              capsense_end_of_scan_callback, &amp;cy_capsense_context);
    
    Cy_CapSense_Enable(&amp;cy_capsense_context);
}

/*******************************************************************************
* Function Name: capsense_end_of_scan_callback
********************************************************************************
* Summary:
*  CapSense end of scan callback function. This function sends a command to
*  CapSense task to process scan.
*
* Parameters:
*  cy_stc_active_scan_sns_t * active_scan_sns_ptr (unused)
*
*******************************************************************************/
static void capsense_end_of_scan_callback(cy_stc_active_scan_sns_t* active_scan_sns_ptr)
{
    BaseType_t xYieldRequired;

    (void)active_scan_sns_ptr;
    xYieldRequired = xSemaphoreGiveFromISR(capsense_done,&amp;xYieldRequired);

    portYIELD_FROM_ISR(xYieldRequired);
}

/*******************************************************************************
* Function Name: capsense_isr
********************************************************************************
* Summary:
*  Wrapper function for handling interrupts from CSD block.
*
*******************************************************************************/
static void capsense_isr(void)
{
    Cy_CapSense_InterruptHandler(CYBSP_CSD_HW, &amp;cy_capsense_context);
}

/*******************************************************************************
* Function Name: capsense_register_deepsleep
********************************************************************************
* Summary:
*  Wrapper function for setting up the Deep Sleep callback for CapSense.
*  This is necessary so that a transition from active to Deep Sleep does not
*  occur during a CapSense scan.
*
*  See the "MTB CAT1 Peripheral driver library documentation &gt; PDL API Reference &gt; SysPM"
*  link in the Quick Panel Documentation for information on setting up the SysPm callbacks
*******************************************************************************/
static void capsense_register_deepsleep(void)
{
    static cy_stc_syspm_callback_params_t callback_params =
    {
        .base       = CYBSP_CSD_HW,
        .context    = &amp;cy_capsense_context
    };

    static cy_stc_syspm_callback_t capsense_deep_sleep_cb =
    {
        Cy_CapSense_DeepSleepCallback,
        CY_SYSPM_DEEPSLEEP,
        0,
        &amp;callback_params,
        NULL,
        NULL
    };

    Cy_SysPm_RegisterCallback(&amp;capsense_deep_sleep_cb);
}
</pre>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/ew21-lesson-1-freertos-capsense/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>EW21: Lesson 2: Joystick</title>
		<link>https://iotexpert.com/ew21-lesson-2-joystick/</link>
					<comments>https://iotexpert.com/ew21-lesson-2-joystick/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Wed, 24 Feb 2021 15:26:13 +0000</pubDate>
				<category><![CDATA[Embedded World 2021]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=10781</guid>

					<description><![CDATA[Summary In lesson 2 we will add the Infineon XENSIV 3-D Magnetic Sensor with a Joystick to the project .  At the end of lesson two you will have the &#8220;JoyStick Task&#8221; colored green.  Here is the architecture: Learning Objectives In this lesson I will teach you about Libraries &#38; the Library Manager Multiple RTOS [&#8230;]]]></description>
										<content:encoded><![CDATA[<div>
<p><span><h1>Embedded World 2021 - Infineon ModusToolbox PSoC 6 Drone </h1>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >#</th>
<th >Description</th>
</tr>
</thead>
<tbody>
<tr><td >0</td>
<td ><a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/" target="_blank" rel="noopener">Introduction &amp; Resources</a></td>
</tr>

<tr><td >1</td>
<td ><a href="https://iotexpert.com/ew21-lesson-1-freertos-capsense/" target="_blank" rel="noopener">FreeRTOS &amp; CapSense</a></td>
</tr>

<tr><td >2</td>
<td ><a href="https://iotexpert.com/ew21-lesson-2-joystick/" target="_blank" rel="noopener">3-D Magnetic Sensing XENSIV Joystick</a></td>
</tr>

<tr><td >3</td>
<td ><a href="https://iotexpert.com/ew21-lesson-3-wifi/" target="_blank" rel="noopener">WiFi</a></td>
</tr>

<tr><td >4</td>
<td ><a href="https://iotexpert.com/ew21-lesson-4-mqtt/" target="_blank" rel="noopener">MQTT</a></td>
</tr>

<tr><td >5</td>
<td ><a href="https://iotexpert.com/ew21-lesson-5-low-power/" target="_blank" rel="noopener">Low Power</a></td>
</tr>

<tr><td >6</td>
<td ><a href="https://iotexpert.com/ew21-lesson-6-motor-control/" target="_blank" rel="noopener">BLDC Motor Control</a></td>
</tr>

<tr><td >7</td>
<td ><a href="https://iotexpert.com/ew21-lesson-7-ws2812-led-strip/" target="_blank" rel="noopener">WS2812 Strip LEDs</a></td>
</tr>
</tbody></table></div></p>
<p>&nbsp;</p></span></p>
<h1>Summary</h1>
<p>In lesson 2 we will add the Infineon XENSIV 3-D Magnetic Sensor with a Joystick to the project .  At the end of lesson two you will have the &#8220;JoyStick Task&#8221; colored green.  Here is the architecture:</p>
<p><a href="https://iotexpert.com/ew21-lesson-2-joystick/l2-arch/" rel="attachment wp-att-10977"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/l2-arch-1024x433.png" alt="" width="1024" height="433" class="alignnone size-large wp-image-10977" srcset="https://iotexpert.com/wp-content/uploads/2021/02/l2-arch-1024x433.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/l2-arch-300x127.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/l2-arch-768x324.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/l2-arch-1536x649.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/l2-arch-600x253.png 600w, https://iotexpert.com/wp-content/uploads/2021/02/l2-arch.png 1631w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Learning Objectives</h1>
<p>In this lesson I will teach you about</p>
<ol>
<li>Libraries &amp; the Library Manager</li>
<li>Multiple RTOS Tasks</li>
<li>XENSIV 3-D Magnetic JoyStick</li>
</ol>
<h1>Procedure</h1>
<p>I am going to follow these steps:</p>
<ol>
<li>Look at the Sensor GUI</li>
<li>Start a new project</li>
<li>Add the TLx493D library</li>
<li>Create the joystick_task public header</li>
<li>Create the joystick_task implementation file</li>
<li>Test</li>
</ol>
<h3>1.Look at the Sensor GUI</h3>
<p>Start the GUI and click the connect button.</p>
<p><a href="https://iotexpert.com/ew21-lesson-2-joystick/screen-shot-2021-02-23-at-7-10-53-am/" rel="attachment wp-att-10881"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-7.10.53-AM-1024x652.png" alt="" width="1024" height="652" class="alignnone size-large wp-image-10881" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-7.10.53-AM-1024x652.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-7.10.53-AM-300x191.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-7.10.53-AM-768x489.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-7.10.53-AM-600x382.png 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-7.10.53-AM.png 1234w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Press start and you will now see x,y,z values.</p>
<p><a href="https://iotexpert.com/ew21-lesson-2-joystick/screen-shot-2021-02-23-at-7-11-26-am/" rel="attachment wp-att-10882"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-7.11.26-AM-1024x812.png" alt="" width="1024" height="812" class="alignnone size-large wp-image-10882" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-7.11.26-AM-1024x812.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-7.11.26-AM-300x238.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-7.11.26-AM-768x609.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-7.11.26-AM-1536x1219.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-7.11.26-AM-600x476.png 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-7.11.26-AM.png 1578w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Click on the joystick view to see how it looks as a joystick.</p>
<p><a href="https://iotexpert.com/ew21-lesson-2-joystick/screen-shot-2021-02-23-at-7-11-41-am/" rel="attachment wp-att-10883"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-7.11.41-AM-1024x807.jpg" alt="" width="1024" height="807" class="alignnone size-large wp-image-10883" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-7.11.41-AM-1024x807.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-7.11.41-AM-300x236.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-7.11.41-AM-768x605.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-7.11.41-AM-1536x1210.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-7.11.41-AM-600x473.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-7.11.41-AM.jpg 1584w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h3>2. Start a new project</h3>
<p>Start the new project creator and pick out &#8220;CY8CPROTO-062-4343W&#8221;</p>
<p><a href="https://iotexpert.com/ew21-lesson-2-joystick/screen-shot-2021-02-23-at-6-06-28-am/" rel="attachment wp-att-10864"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.06.28-AM-1024x700.jpg" alt="" width="1024" height="700" class="alignnone size-large wp-image-10864" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.06.28-AM-1024x700.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.06.28-AM-300x205.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.06.28-AM-768x525.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.06.28-AM-1536x1050.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.06.28-AM-600x410.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.06.28-AM.jpg 2046w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>This time I will start from the previous project.  Press the &#8220;Import&#8221; button and select your old project to open.</p>
<p><a href="https://iotexpert.com/ew21-lesson-2-joystick/screen-shot-2021-02-23-at-6-07-16-am/" rel="attachment wp-att-10866"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.07.16-AM-1024x698.jpg" alt="" width="1024" height="698" class="alignnone size-large wp-image-10866" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.07.16-AM-1024x698.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.07.16-AM-300x204.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.07.16-AM-768x523.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.07.16-AM-1536x1047.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.07.16-AM-2048x1396.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.07.16-AM-600x409.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Give your project a new name (notice that we are starting from 1 as the template)</p>
<p><a href="https://iotexpert.com/ew21-lesson-2-joystick/screen-shot-2021-02-23-at-6-07-37-am/" rel="attachment wp-att-10867"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.07.37-AM-1024x164.png" alt="" width="1024" height="164" class="alignnone size-large wp-image-10867" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.07.37-AM-1024x164.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.07.37-AM-300x48.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.07.37-AM-768x123.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.07.37-AM-1536x246.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.07.37-AM-600x96.png 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.07.37-AM.png 2036w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
</div>
<p>Open up the command line and make vscode.</p>
<p><a href="https://iotexpert.com/ew21-lesson-2-joystick/screen-shot-2021-02-23-at-6-09-37-am/" rel="attachment wp-att-10868"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.09.37-AM-768x1024.jpg" alt="" width="768" height="1024" class="alignnone size-large wp-image-10868" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.09.37-AM-768x1024.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.09.37-AM-225x300.jpg 225w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.09.37-AM-1152x1536.jpg 1152w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.09.37-AM-600x800.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.09.37-AM.jpg 1520w" sizes="auto, (max-width: 768px) 100vw, 768px" /></a></p>
<p>Do a command line build/program by running &#8220;make -j program&#8221;.</p>
<p><a href="https://iotexpert.com/ew21-lesson-2-joystick/screen-shot-2021-02-23-at-6-12-01-am/" rel="attachment wp-att-10869"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.12.01-AM-1024x944.jpg" alt="" width="1024" height="944" class="alignnone size-large wp-image-10869" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.12.01-AM-1024x944.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.12.01-AM-300x276.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.12.01-AM-768x708.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.12.01-AM-600x553.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.12.01-AM.jpg 1502w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>It will finish compiling and then program your board.</p>
<p><a href="https://iotexpert.com/ew21-lesson-2-joystick/screen-shot-2021-02-23-at-6-11-48-am/" rel="attachment wp-att-10870"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.11.48-AM-762x1024.jpg" alt="" width="762" height="1024" class="alignnone size-large wp-image-10870" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.11.48-AM-762x1024.jpg 762w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.11.48-AM-223x300.jpg 223w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.11.48-AM-768x1032.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.11.48-AM-1143x1536.jpg 1143w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.11.48-AM-600x806.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.11.48-AM.jpg 1508w" sizes="auto, (max-width: 762px) 100vw, 762px" /></a></p>
<p>Now look at the serial terminal and make sure that the CapSense is still working</p>
<p><a href="https://iotexpert.com/ew21-lesson-2-joystick/screen-shot-2021-02-23-at-6-41-00-am/" rel="attachment wp-att-10879"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.41.00-AM-1024x366.png" alt="" width="1024" height="366" class="alignnone size-large wp-image-10879" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.41.00-AM-1024x366.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.41.00-AM-300x107.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.41.00-AM-768x274.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.41.00-AM-600x214.png 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.41.00-AM.png 1142w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<div>
<h3>3. Add the<span style="font-size: 16px;"> TLx493D library</span></h3>
<p>In order to interact with the TLx493D it would be much simpler if you had a library.  Well, I have just the solution for that.  Start the library browser and filter for IoT.  Notice that one of your choices is the TLx493D 3D Magnetic Sensor library.  Check the box, then press Update. Once the update finishes, press Close.</p>
<p><a href="https://iotexpert.com/ew21-lesson-2-joystick/screen-shot-2021-02-23-at-6-13-10-am/" rel="attachment wp-att-10871"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.13.10-AM-1024x790.jpg" alt="" width="1024" height="790" class="alignnone size-large wp-image-10871" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.13.10-AM-1024x790.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.13.10-AM-300x231.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.13.10-AM-768x592.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.13.10-AM-1536x1185.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.13.10-AM-2048x1580.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.13.10-AM-600x463.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>After running the update you will notice some new stuff.  First there is a file in your &#8220;deps&#8221; directory.  We will look at that in a second.  Also notice that there is a new directory in the mtb_shared directory.</p>
</div>
<p><a href="https://iotexpert.com/ew21-lesson-2-joystick/screen-shot-2021-02-23-at-6-24-46-am/" rel="attachment wp-att-10873"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.24.46-AM-929x1024.jpg" alt="" width="929" height="1024" class="alignnone size-large wp-image-10873" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.24.46-AM-929x1024.jpg 929w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.24.46-AM-272x300.jpg 272w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.24.46-AM-768x846.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.24.46-AM-1394x1536.jpg 1394w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.24.46-AM-600x661.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.24.46-AM.jpg 1488w" sizes="auto, (max-width: 929px) 100vw, 929px" /></a></p>
<p>When you look at the dot-MTB file you will see that it is just a</p>
<ol>
<li>URL to GitHub</li>
<li>A branch name = &#8220;master&#8221;</li>
<li>A location to put it = mtb_shared/TLx493D_3Dmagnetic/master</li>
</ol>
<p>This is JUST A SIMPLE GIT REPOSITORY.</p>
<p><a href="https://iotexpert.com/ew21-lesson-2-joystick/screen-shot-2021-02-23-at-6-25-58-am/" rel="attachment wp-att-10874"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.25.58-AM-1024x252.png" alt="" width="1024" height="252" class="alignnone size-large wp-image-10874" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.25.58-AM-1024x252.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.25.58-AM-300x74.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.25.58-AM-768x189.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.25.58-AM-1536x378.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.25.58-AM-2048x504.png 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.25.58-AM-600x148.png 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>When you open vscode and look in the repository you will see normal c-code.</p>
<p><a href="https://iotexpert.com/ew21-lesson-2-joystick/screen-shot-2021-02-23-at-6-27-02-am/" rel="attachment wp-att-10875"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.27.02-AM-1024x768.jpg" alt="" width="1024" height="768" class="alignnone size-large wp-image-10875" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.27.02-AM-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.27.02-AM-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.27.02-AM-768x576.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.27.02-AM-1536x1152.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.27.02-AM-2048x1536.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.27.02-AM-600x450.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<div>
<h3>4. Create the Joystick_task public header</h3>
<p>We want to have a task called &#8220;joystick_task&#8221;.  So create the public header file for that task.</p>
<p><a href="https://iotexpert.com/ew21-lesson-2-joystick/screen-shot-2021-02-23-at-6-31-42-am/" rel="attachment wp-att-10877"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.31.42-AM.png" alt="" width="850" height="710" class="alignnone size-full wp-image-10877" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.31.42-AM.png 850w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.31.42-AM-300x251.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.31.42-AM-768x642.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.31.42-AM-600x501.png 600w" sizes="auto, (max-width: 850px) 100vw, 850px" /></a></p>
</div>
<p>Then add the long and extensive code.  Just a function prototype for the joystick task.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">#pragma once

void joystick_task(void *param);
</pre>
<div>
<h3>5. Create the joystick_task implementation file</h3>
</div>
<p>Now the actual code for the joystick is straight forward</p>
<ol>
<li>Some includes</li>
<li>The task definition</li>
<li>Initialize the interface to the joystick with TLxI2CInit</li>
<li>Initialize the library with TLx493xInit</li>
<li>Loop repeatedly</li>
<li>Read one frame from the joystick sensor</li>
<li>Convert the frame to x-y coordinates</li>
<li>If there is a new position print it.</li>
<li>Save the old data</li>
<li>Wait a bit</li>
<li>Loop back to the start</li>
</ol>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#include "cybsp.h"
#include "FreeRTOS.h"
#include "task.h"
#include &lt;stdio.h&gt;

#include "joystick_task.h"

#include "PSoC_TLx_interface.h"
#include "TLxJoystick.h"

#define JOYSTICK_INTERVAL_MS    (100)   /* in milliseconds*/
#define JOYSTICK_HYSTERESIS		(1)

/*******************************************************************************
* Function Name: task_joystick
********************************************************************************
* Summary:
*  Task that initializes the Joystick block and processes the input.
*
* Parameters:
*  void *param : Task parameter defined during task creation (unused)
*
*******************************************************************************/
void joystick_task(void* param)
{
    (void)param;

    cy_rslt_t result;

    TLx493D_data_frame_t frame;
    TLxJoyStickXY_t joystick_curr;
    TLxJoyStickXY_t joystick_prev;

    /* Initialize I2C interface to talk to the TLx493D sensor */
    TLxI2CInit(CYBSP_I2C_SDA,
                        CYBSP_I2C_SCL,
                        0 /* Use Default Sensor Address */,
                        0 /* Use Default Speed */,
                        NULL /* Use Auto-assigned clock */);


    /* Configure the TLx493D sensor */
    result = TLx493D_init();
    if (result != CY_RSLT_SUCCESS)
    {
    	printf("Joystick not detected. Exiting Joystick task.\n");
    	vTaskDelete(NULL);
    }
    
    /* Set Sensor to Master Control Mode */
    TLx493D_set_operation_mode(TLx493D_OP_MODE_MCM);

    /* Repeatedly running part of the task */
    for(;;)
    {
        TLx493D_read_frame(&amp;frame);

        TLxJoystickCovertXY(&amp;frame,&amp;joystick_curr);

        /* Only update/print new value if it has changed by more than the hysteresis value */
        if((joystick_curr.x &gt; (joystick_prev.x + JOYSTICK_HYSTERESIS)) || (joystick_curr.x &lt; (joystick_prev.x - JOYSTICK_HYSTERESIS)))
        {
            printf("Joystick Position: %d\n", joystick_curr.x);

            joystick_prev.x = joystick_curr.x;
            joystick_prev.y = joystick_curr.y;
        }
        vTaskDelay(JOYSTICK_INTERVAL_MS);
    }
}
</pre>
<div>
<h3>6. Edit main.c</h3>
<p>In main.c you need to include the joystick_task.h and then start the task</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">#include "cyhal.h"
#include "cybsp.h"
#include "cy_retarget_io.h"
#include &lt;stdio.h&gt;
#include "FreeRTOS.h"
#include "task.h"
#include "capsense_task.h"
#include "joystick_task.h"

volatile int uxTopUsedPriority ;

void blink_task(void *arg)
{
    cyhal_gpio_init(CYBSP_USER_LED,CYHAL_GPIO_DIR_OUTPUT,CYHAL_GPIO_DRIVE_STRONG,0);

    for(;;)
    {
    	cyhal_gpio_toggle(CYBSP_USER_LED);
    	vTaskDelay(500);
    }
}


int main(void)
{
    uxTopUsedPriority = configMAX_PRIORITIES - 1 ; // enable OpenOCD Thread Debugging

    /* Initialize the device and board peripherals */
    cybsp_init() ;
    __enable_irq();

    cy_retarget_io_init(CYBSP_DEBUG_UART_TX, CYBSP_DEBUG_UART_RX, CY_RETARGET_IO_BAUDRATE);

    // Stack size in WORDs
    // Idle task = priority 0
    xTaskCreate(blink_task,    "blink"     ,configMINIMAL_STACK_SIZE*1  ,0 /* args */ ,0 /* priority */, 0 /* handle */);
    xTaskCreate(capsense_task, "CapSense"  ,configMINIMAL_STACK_SIZE*4  , NULL, 1, 0);
    xTaskCreate(joystick_task, "Joystick"  ,configMINIMAL_STACK_SIZE*4  , NULL, 1, 0);

    vTaskStartScheduler();
}</pre>
<h3>7. Test</h3>
<p>When you test, you will see that the joystick moves around and prints new values.  Plus the CapSense still works.</p>
<p><a href="https://iotexpert.com/ew21-lesson-2-joystick/screen-shot-2021-02-23-at-6-36-50-am/" rel="attachment wp-att-10878"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.36.50-AM.png" alt="" width="972" height="816" class="alignnone size-full wp-image-10878" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.36.50-AM.png 972w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.36.50-AM-300x252.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.36.50-AM-768x645.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.36.50-AM-600x504.png 600w" sizes="auto, (max-width: 972px) 100vw, 972px" /></a></p>
<h1>Resources for Project</h1>
<p>You can find this completed project in your project creator dialog by filtering for &#8220;IoT Expert Embedded&#8221;.  This is lesson2</p>
<p><a href="https://iotexpert.com/?attachment_id=10819" rel="attachment wp-att-10819"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.33.24-PM-1024x585.png" alt="" width="1024" height="585" class="alignnone size-large wp-image-10819" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.33.24-PM-1024x585.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.33.24-PM-300x171.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.33.24-PM-768x439.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.33.24-PM-1536x878.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.33.24-PM-2048x1171.png 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.33.24-PM-600x343.png 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>You can also clone this project at git@github.com:iotexpert/ew21-lesson2.git or https://github.com/iotexpert/ew21-lesson2</p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/ew21-lesson-2-joystick/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>EW21: Lesson 3: WiFi</title>
		<link>https://iotexpert.com/ew21-lesson-3-wifi/</link>
					<comments>https://iotexpert.com/ew21-lesson-3-wifi/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Wed, 24 Feb 2021 15:25:45 +0000</pubDate>
				<category><![CDATA[Embedded World 2021]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=10782</guid>

					<description><![CDATA[Summary In lesson 3 we will add a task to manage the &#8220;Cloud&#8221;, this is IoT after all.  We will start by adding the connection to the WiFi network using the AnyCloud Wireless Connection Manager within ModusToolbox.  At the end of lesson three you will have the &#8220;Cloud Task&#8221; colored green &#8211; well actually partially [&#8230;]]]></description>
										<content:encoded><![CDATA[<div>
<p><span><h1>Embedded World 2021 - Infineon ModusToolbox PSoC 6 Drone </h1>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >#</th>
<th >Description</th>
</tr>
</thead>
<tbody>
<tr><td >0</td>
<td ><a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/" target="_blank" rel="noopener">Introduction &amp; Resources</a></td>
</tr>

<tr><td >1</td>
<td ><a href="https://iotexpert.com/ew21-lesson-1-freertos-capsense/" target="_blank" rel="noopener">FreeRTOS &amp; CapSense</a></td>
</tr>

<tr><td >2</td>
<td ><a href="https://iotexpert.com/ew21-lesson-2-joystick/" target="_blank" rel="noopener">3-D Magnetic Sensing XENSIV Joystick</a></td>
</tr>

<tr><td >3</td>
<td ><a href="https://iotexpert.com/ew21-lesson-3-wifi/" target="_blank" rel="noopener">WiFi</a></td>
</tr>

<tr><td >4</td>
<td ><a href="https://iotexpert.com/ew21-lesson-4-mqtt/" target="_blank" rel="noopener">MQTT</a></td>
</tr>

<tr><td >5</td>
<td ><a href="https://iotexpert.com/ew21-lesson-5-low-power/" target="_blank" rel="noopener">Low Power</a></td>
</tr>

<tr><td >6</td>
<td ><a href="https://iotexpert.com/ew21-lesson-6-motor-control/" target="_blank" rel="noopener">BLDC Motor Control</a></td>
</tr>

<tr><td >7</td>
<td ><a href="https://iotexpert.com/ew21-lesson-7-ws2812-led-strip/" target="_blank" rel="noopener">WS2812 Strip LEDs</a></td>
</tr>
</tbody></table></div></p>
<p>&nbsp;</p></span></p>
<h1>Summary</h1>
<p>In lesson 3 we will add a task to manage the &#8220;Cloud&#8221;, this is IoT after all.  We will start by adding the connection to the WiFi network using the AnyCloud Wireless Connection Manager within ModusToolbox.  At the end of lesson three you will have the &#8220;Cloud Task&#8221; colored green &#8211; well actually partially green.  Here is the architecture:</p>
<p><a href="https://iotexpert.com/ew21-lesson-3-wifi/l3-arch-2/" rel="attachment wp-att-10979"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/l3-arch-1-1024x433.png" alt="" width="1024" height="433" class="alignnone size-large wp-image-10979" srcset="https://iotexpert.com/wp-content/uploads/2021/02/l3-arch-1-1024x433.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/l3-arch-1-300x127.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/l3-arch-1-768x324.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/l3-arch-1-1536x649.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/l3-arch-1-600x253.png 600w, https://iotexpert.com/wp-content/uploads/2021/02/l3-arch-1.png 1631w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Learning Objectives</h1>
<ol>
<li>AnyCloud Wireless Libraries</li>
<li>Architecture of the PSoC 6 + 43xxxx WiFi Combo</li>
<li>Wireless Connection Manager</li>
</ol>
<h1>Procedure</h1>
<p>In this lesson we will follow these steps:</p>
<ol>
<li>Create a new project by copying lesson 2</li>
<li>Add the WiFi Libraries</li>
<li>Copy the wireless configuration templates files into your project</li>
<li>Look at the Wireless Library Documentation</li>
<li>Update the Makefile</li>
<li>Add cloud_task.h</li>
<li>Add cloud_task.c</li>
<li>Update main.c</li>
<li>Test</li>
</ol>
<h3>1. Create a new project by copying lesson 2</h3>
<p>Start the new project creator and select the CY8CPROTO-062-4343W</p>
<p><a href="https://iotexpert.com/ew21-lesson-3-wifi/screen-shot-2021-02-23-at-8-58-21-am/" rel="attachment wp-att-10885"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-8.58.21-AM-1024x706.jpg" alt="" width="1024" height="706" class="alignnone size-large wp-image-10885" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-8.58.21-AM-1024x706.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-8.58.21-AM-300x207.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-8.58.21-AM-768x530.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-8.58.21-AM-1536x1059.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-8.58.21-AM-2048x1413.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-8.58.21-AM-600x414.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Click the import button.  Then select your previous project and press open.</p>
<p><a href="https://iotexpert.com/ew21-lesson-3-wifi/screen-shot-2021-02-23-at-8-58-49-am/" rel="attachment wp-att-10886"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-8.58.49-AM-1024x699.png" alt="" width="1024" height="699" class="alignnone size-large wp-image-10886" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-8.58.49-AM-1024x699.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-8.58.49-AM-300x205.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-8.58.49-AM-768x525.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-8.58.49-AM-600x410.png 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-8.58.49-AM.png 1306w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Select your new template and give it a reasonable name.</p>
<p><a href="https://iotexpert.com/ew21-lesson-3-wifi/screen-shot-2021-02-23-at-8-59-04-am/" rel="attachment wp-att-10887"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-8.59.04-AM-1024x143.png" alt="" width="1024" height="143" class="alignnone size-large wp-image-10887" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-8.59.04-AM-1024x143.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-8.59.04-AM-300x42.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-8.59.04-AM-768x107.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-8.59.04-AM-1536x214.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-8.59.04-AM-2048x286.png 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-8.59.04-AM-600x84.png 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Now program your project to make sure that things are still working.</p>
<p><a href="https://iotexpert.com/ew21-lesson-3-wifi/screen-shot-2021-02-23-at-9-03-00-am/" rel="attachment wp-att-10889"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.03.00-AM-1024x687.jpg" alt="" width="1024" height="687" class="alignnone size-large wp-image-10889" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.03.00-AM-1024x687.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.03.00-AM-300x201.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.03.00-AM-768x515.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.03.00-AM-600x403.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.03.00-AM.jpg 1434w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
</div>
<p>Here is the serial terminal.</p>
<p><a href="https://iotexpert.com/ew21-lesson-3-wifi/screen-shot-2021-02-23-at-9-03-21-am/" rel="attachment wp-att-10890"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.03.21-AM-1024x469.png" alt="" width="1024" height="469" class="alignnone size-large wp-image-10890" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.03.21-AM-1024x469.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.03.21-AM-300x137.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.03.21-AM-768x352.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.03.21-AM-1536x703.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.03.21-AM-600x275.png 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.03.21-AM.png 1560w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<div>
<h3>2. Add the WiFi Libraries</h3>
<p>Start up the library manager and go to the Libraries tab.  Click on wireless connection manager.  Notice that it will bring in a bunch of other libraries that it depends on.</p>
<p><a href="https://iotexpert.com/ew21-lesson-3-wifi/screen-shot-2021-02-23-at-9-05-31-am/" rel="attachment wp-att-10891"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.05.31-AM-943x1024.jpg" alt="" width="943" height="1024" class="alignnone size-large wp-image-10891" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.05.31-AM-943x1024.jpg 943w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.05.31-AM-276x300.jpg 276w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.05.31-AM-768x834.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.05.31-AM-600x651.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.05.31-AM.jpg 1144w" sizes="auto, (max-width: 943px) 100vw, 943px" /></a></p>
<h3>3. Copy the wireless configuration templates into your project</h3>
<p>MBED TLS and LWIP have about a billion options.  We provide a template for those options which you will need to copy into your project.  The templates are located in the wifi-mw-core library in the &#8220;config&#8221; directory.  Copy and paste them into your project.</p>
<p><a href="https://iotexpert.com/ew21-lesson-3-wifi/screen-shot-2021-02-23-at-9-11-26-am/" rel="attachment wp-att-10892"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.11.26-AM-340x1024.jpg" alt="" width="340" height="1024" class="alignnone size-large wp-image-10892" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.11.26-AM-340x1024.jpg 340w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.11.26-AM-100x300.jpg 100w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.11.26-AM-768x2315.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.11.26-AM-510x1536.jpg 510w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.11.26-AM-600x1809.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.11.26-AM.jpg 826w" sizes="auto, (max-width: 340px) 100vw, 340px" /></a></p>
</div>
<p>Here is a clip of the lwip configuration options.  I wouldn&#8217;t recommend changing anything unless you are sure you know what you are doing.</p>
<p><a href="https://iotexpert.com/ew21-lesson-3-wifi/screen-shot-2021-02-23-at-9-12-37-am/" rel="attachment wp-att-10893"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.12.37-AM-819x1024.jpg" alt="" width="819" height="1024" class="alignnone size-large wp-image-10893" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.12.37-AM-819x1024.jpg 819w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.12.37-AM-240x300.jpg 240w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.12.37-AM-768x960.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.12.37-AM-1228x1536.jpg 1228w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.12.37-AM-600x750.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.12.37-AM.jpg 1350w" sizes="auto, (max-width: 819px) 100vw, 819px" /></a></p>
<div>
<h3>4. Look at the Wireless Library Documentation</h3>
<p>All of the Infineon libraries will have a directory called &#8220;doc&#8221; and inside of that directory there will be a file called api_reference_manual.html</p>
<p><a href="https://iotexpert.com/ew21-lesson-3-wifi/screen-shot-2021-02-23-at-9-41-17-am/" rel="attachment wp-att-10900"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.41.17-AM.png" alt="" width="700" height="810" class="alignnone size-full wp-image-10900" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.41.17-AM.png 700w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.41.17-AM-259x300.png 259w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.41.17-AM-600x694.png 600w" sizes="auto, (max-width: 700px) 100vw, 700px" /></a></p>
<p>When you open the file you will  see our doxygen generated documentation.  Here the WiFi connection manager documentation.</p>
<p><a href="https://iotexpert.com/ew21-lesson-3-wifi/screen-shot-2021-02-23-at-9-41-42-am/" rel="attachment wp-att-10901"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.41.42-AM-1024x659.jpg" alt="" width="1024" height="659" class="alignnone size-large wp-image-10901" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.41.42-AM-1024x659.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.41.42-AM-300x193.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.41.42-AM-768x494.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.41.42-AM-1536x988.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.41.42-AM-2048x1318.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.41.42-AM-600x386.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h3>5. Update the Makefile</h3>
</div>
<p>The makefile controls all of the libraries.  To enable these libraries you need to add the following &#8220;components&#8221; to the list if they aren&#8217;t already there. (Note that all of this information is in the Quick Start section of the library&#8217;s documentation).</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">COMPONENTS= FREERTOS LWIP MBEDTLS</pre>
<p>And you need to tell the system about the configuration.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">DEFINES+= MBEDTLS_USER_CONFIG_FILE='"mbedtls_user_config.h"' 
DEFINES+=CYBSP_WIFI_CAPABLE
DEFINES+=CY_RTOS_AWARE</pre>
<div>
<h3>6. Add the cloud_task.h</h3>
</div>
<p>Just like the other lessons you will need to create a public header file for the cloud task.</p>
<p><a href="https://iotexpert.com/ew21-lesson-3-wifi/screen-shot-2021-02-23-at-9-14-48-am/" rel="attachment wp-att-10895"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.14.48-AM.png" alt="" width="778" height="504" class="alignnone size-full wp-image-10895" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.14.48-AM.png 778w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.14.48-AM-300x194.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.14.48-AM-768x498.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.14.48-AM-600x389.png 600w" sizes="auto, (max-width: 778px) 100vw, 778px" /></a></p>
<p>Inside of that file there will be only one function prototype for the task.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#pragma once

void cloud_task(void *param);</pre>
<div>
<h3>7. Add the cloud_task.c</h3>
<p>Make the cloud_task.c file to add the cloud infrastructure to your project.</p>
</div>
<p><a href="https://iotexpert.com/ew21-lesson-3-wifi/screen-shot-2021-02-23-at-9-15-42-am/" rel="attachment wp-att-10896"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.15.42-AM.png" alt="" width="760" height="532" class="alignnone size-full wp-image-10896" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.15.42-AM.png 760w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.15.42-AM-300x210.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.15.42-AM-600x420.png 600w" sizes="auto, (max-width: 760px) 100vw, 760px" /></a></p>
<p>At the top of the file we will have some includes.  And I will define some macros that tell WiFi which AP to attach to. When you do this on your own, you will need to update those to match your WiFi AP SSID and password. The task itself is really simple for now, just connect to WiFi and then do nothing.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#include &lt;stdio.h&gt;

#include "FreeRTOS.h"
#include "task.h"

#include "cy_wcm.h"

#include "cloud_task.h"

#define CLOUD_WIFI_AP        "ew2021"
#define CLOUD_WIFI_PW        "ew2021ap"
#define CLOUD_WIFI_SECURITY  CY_WCM_SECURITY_WPA2_MIXED_PSK
#define CLOUD_WIFI_BAND      CY_WCM_WIFI_BAND_ANY

static void cloud_connectWifi();

void cloud_task(void* param)
{
    (void)param;

    cloud_connectWifi();

    while(1)
    {
        vTaskDelay(1);

    }
}</pre>
<p>The connect to WiFi function will</p>
<ol>
<li>Setup the Access Point information</li>
<li>Initialize the wireless connection manager</li>
<li>Then go into a loop that will attempt to connect until there is success.</li>
<li>Once a connection is made, it will print out the IP information.</li>
</ol>
<pre class="EnlighterJSRAW" data-enlighter-language="c">static void cloud_connectWifi()
{
    cy_rslt_t result;

    cy_wcm_connect_params_t connect_param = {
        .ap_credentials.SSID = CLOUD_WIFI_AP,
        .ap_credentials.password = CLOUD_WIFI_PW,
        .ap_credentials.security = CLOUD_WIFI_SECURITY,
        .BSSID = {0},
        .band = CLOUD_WIFI_BAND,
    };
    cy_wcm_config_t config = {.interface = CY_WCM_INTERFACE_TYPE_STA}; // We are a station (not a Access Point)

    cy_wcm_init(&amp;config); // Initialize the connection manager

    printf("\nWi-Fi Connection Manager initialized.\n");

    do
    {
        cy_wcm_ip_address_t ip_address;

        printf("Connecting to Wi-Fi AP '%s'\n", connect_param.ap_credentials.SSID);
        result = cy_wcm_connect_ap(&amp;connect_param, &amp;ip_address);

        if (result == CY_RSLT_SUCCESS)
        {
            printf("Successfully connected to Wi-Fi network '%s'.\n",
                    connect_param.ap_credentials.SSID);

            // Print IP Address
            if (ip_address.version == CY_WCM_IP_VER_V4)
            {
                printf("IPv4 Address Assigned: %d.%d.%d.%d\n", (uint8_t)ip_address.ip.v4,
                        (uint8_t)(ip_address.ip.v4 &gt;&gt; 8), (uint8_t)(ip_address.ip.v4 &gt;&gt; 16),
                        (uint8_t)(ip_address.ip.v4 &gt;&gt; 24));
            }
            else if (ip_address.version == CY_WCM_IP_VER_V6)
            {
                printf("IPv6 Address Assigned: %0X:%0X:%0X:%0X\n", (unsigned int)ip_address.ip.v6[0],
                        (unsigned int)ip_address.ip.v6[1], (unsigned int)ip_address.ip.v6[2],
                        (unsigned int)ip_address.ip.v6[3]);
            }
            break; /* Exit the for loop once the connection has been made */
        }
        else
        {
            printf("WiFi Connect Failed Retrying\n");
            vTaskDelay(2000); // wait 2 seconds and try again;
        }

    } while (result != CY_RSLT_SUCCESS);
}
</pre>
<div>
<h3>8. Update main.c</h3>
</div>
<p>In main.c you need to include the cloud task</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">#include "cloud_task.h"</pre>
<p>Then start the cloud task.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">xTaskCreate(cloud_task,    "Cloud"     ,configMINIMAL_STACK_SIZE*8  , NULL, 2, 0);  
</pre>
<div>
<h3>9. Test</h3>
<p>Program your project and make sure that it connects, and the CapSense and joystick still work.</p>
<p><a href="https://iotexpert.com/ew21-lesson-3-wifi/screen-shot-2021-02-23-at-9-23-40-am/" rel="attachment wp-att-10897"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.23.40-AM-1024x267.png" alt="" width="1024" height="267" class="alignnone size-large wp-image-10897" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.23.40-AM-1024x267.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.23.40-AM-300x78.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.23.40-AM-768x200.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.23.40-AM-1536x401.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.23.40-AM-600x156.png 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-9.23.40-AM.png 1710w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Resources for Project</h1>
<p>You can find this projects in your project creator dialog by filtering for &#8220;IoT Expert Embedded&#8221;.  This is lesson3</p>
<p><a href="https://iotexpert.com/ew21-lesson-1-freertos-capsense/screen-shot-2021-02-22-at-4-33-41-pm/" rel="attachment wp-att-10818"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.33.41-PM-1024x583.png" alt="" width="1024" height="583" class="alignnone size-large wp-image-10818" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.33.41-PM-1024x583.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.33.41-PM-300x171.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.33.41-PM-768x437.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.33.41-PM-1536x874.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.33.41-PM-2048x1165.png 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.33.41-PM-600x341.png 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>You can also clone this project at git@github.com:iotexpert/ew21-lesson3.git or https://github.com/iotexpert/ew21-lesson3</p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/ew21-lesson-3-wifi/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>EW21: Lesson 4: MQTT</title>
		<link>https://iotexpert.com/ew21-lesson-4-mqtt/</link>
					<comments>https://iotexpert.com/ew21-lesson-4-mqtt/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Wed, 24 Feb 2021 15:23:52 +0000</pubDate>
				<category><![CDATA[Embedded World 2021]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=10783</guid>

					<description><![CDATA[Summary In lesson 4 we will finish the cloud task by adding a connection to the MQTT broker.  Then I will make a very minor update to the CapSense and Joystick tasks to send their data to the Cloud.  At the end of this lesson you will have the Cloud truly colored green.  Here is [&#8230;]]]></description>
										<content:encoded><![CDATA[<div>
<p><span><h1>Embedded World 2021 - Infineon ModusToolbox PSoC 6 Drone </h1>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >#</th>
<th >Description</th>
</tr>
</thead>
<tbody>
<tr><td >0</td>
<td ><a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/" target="_blank" rel="noopener">Introduction &amp; Resources</a></td>
</tr>

<tr><td >1</td>
<td ><a href="https://iotexpert.com/ew21-lesson-1-freertos-capsense/" target="_blank" rel="noopener">FreeRTOS &amp; CapSense</a></td>
</tr>

<tr><td >2</td>
<td ><a href="https://iotexpert.com/ew21-lesson-2-joystick/" target="_blank" rel="noopener">3-D Magnetic Sensing XENSIV Joystick</a></td>
</tr>

<tr><td >3</td>
<td ><a href="https://iotexpert.com/ew21-lesson-3-wifi/" target="_blank" rel="noopener">WiFi</a></td>
</tr>

<tr><td >4</td>
<td ><a href="https://iotexpert.com/ew21-lesson-4-mqtt/" target="_blank" rel="noopener">MQTT</a></td>
</tr>

<tr><td >5</td>
<td ><a href="https://iotexpert.com/ew21-lesson-5-low-power/" target="_blank" rel="noopener">Low Power</a></td>
</tr>

<tr><td >6</td>
<td ><a href="https://iotexpert.com/ew21-lesson-6-motor-control/" target="_blank" rel="noopener">BLDC Motor Control</a></td>
</tr>

<tr><td >7</td>
<td ><a href="https://iotexpert.com/ew21-lesson-7-ws2812-led-strip/" target="_blank" rel="noopener">WS2812 Strip LEDs</a></td>
</tr>
</tbody></table></div></p>
<p>&nbsp;</p></span></p>
<h1>Summary</h1>
<p>In lesson 4 we will finish the cloud task by adding a connection to the MQTT broker.  Then I will make a very minor update to the CapSense and Joystick tasks to send their data to the Cloud.  At the end of this lesson you will have the Cloud truly colored green.  Here is the architecture:</p>
<p><a href="https://iotexpert.com/ew21-lesson-4-mqtt/l4-arch/" rel="attachment wp-att-10981"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/l4-arch-1024x433.png" alt="" width="1024" height="433" class="alignnone size-large wp-image-10981" srcset="https://iotexpert.com/wp-content/uploads/2021/02/l4-arch-1024x433.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/l4-arch-300x127.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/l4-arch-768x324.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/l4-arch-1536x649.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/l4-arch-600x253.png 600w, https://iotexpert.com/wp-content/uploads/2021/02/l4-arch.png 1631w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Learning Objectives</h1>
<ol>
<li>MQTT</li>
<li>AnyCloud use of AWS libraries</li>
</ol>
<h1>Procedure</h1>
<ol>
<li>Create a new project by copying lesson 3</li>
<li>Add the MQTT Library</li>
<li>Copy the core MQTT configuration</li>
<li>Update the Makefile</li>
<li>Update the cloud_task.h</li>
<li>Update the cloud_task.c</li>
<li>Update joystick_task.c</li>
<li>Update capsense_task.c</li>
<li>Test (using an MQTT Client)</li>
<li>Test (using our C++/Qt GUI)</li>
</ol>
<h3>1. Create a new project by copying lesson 3</h3>
<p>Start the new project creator.  Pick the CY8CPROTO-062-4343W and press next.</p>
<p><a href="https://iotexpert.com/ew21-lesson-4-mqtt/screen-shot-2021-02-23-at-10-07-52-am/" rel="attachment wp-att-10904"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.07.52-AM-1024x966.png" alt="" width="1024" height="966" class="alignnone size-large wp-image-10904" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.07.52-AM-1024x966.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.07.52-AM-300x283.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.07.52-AM-768x724.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.07.52-AM-600x566.png 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.07.52-AM.png 1194w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Click on the import button</p>
<p><a href="https://iotexpert.com/ew21-lesson-4-mqtt/screen-shot-2021-02-23-at-10-08-06-am/" rel="attachment wp-att-10905"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.08.06-AM-1024x225.png" alt="" width="1024" height="225" class="alignnone size-large wp-image-10905" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.08.06-AM-1024x225.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.08.06-AM-300x66.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.08.06-AM-768x169.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.08.06-AM-600x132.png 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.08.06-AM.png 1200w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>And select project three to start from.</p>
<p><a href="https://iotexpert.com/ew21-lesson-4-mqtt/screen-shot-2021-02-23-at-10-08-21-am/" rel="attachment wp-att-10906"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.08.21-AM-1024x700.png" alt="" width="1024" height="700" class="alignnone size-large wp-image-10906" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.08.21-AM-1024x700.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.08.21-AM-300x205.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.08.21-AM-768x525.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.08.21-AM-600x410.png 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.08.21-AM.png 1320w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Give it a sensible name</p>
<p><a href="https://iotexpert.com/ew21-lesson-4-mqtt/screen-shot-2021-02-23-at-10-08-38-am/" rel="attachment wp-att-10907"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.08.38-AM-1024x707.jpg" alt="" width="1024" height="707" class="alignnone size-large wp-image-10907" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.08.38-AM-1024x707.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.08.38-AM-300x207.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.08.38-AM-768x530.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.08.38-AM-1536x1060.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.08.38-AM-2048x1413.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.08.38-AM-600x414.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h3>2. Add the MQTT Library</h3>
<p>Start the library browser and pick out the MQTT library.  Notice that it brings in a bunch of other libraries including the AWS libraries.</p>
<p><a href="https://iotexpert.com/ew21-lesson-4-mqtt/screen-shot-2021-02-23-at-10-11-17-am/" rel="attachment wp-att-10908"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.11.17-AM-1024x795.jpg" alt="" width="1024" height="795" class="alignnone size-large wp-image-10908" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.11.17-AM-1024x795.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.11.17-AM-300x233.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.11.17-AM-768x596.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.11.17-AM-1536x1192.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.11.17-AM-2048x1589.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.11.17-AM-600x466.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h3>3. Copy the core MQTT configuration</h3>
</div>
<p>When you look at the README for the MQTT it tells you to copy the file core_mqtt_config.h into your project.  Do so.</p>
<p><a href="https://iotexpert.com/ew21-lesson-4-mqtt/screen-shot-2021-02-23-at-10-29-54-am/" rel="attachment wp-att-10910"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.29.54-AM-1024x991.jpg" alt="" width="1024" height="991" class="alignnone size-large wp-image-10910" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.29.54-AM-1024x991.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.29.54-AM-300x290.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.29.54-AM-768x743.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.29.54-AM-1536x1486.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.29.54-AM-2048x1981.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.29.54-AM-600x580.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<div>
<h3>4. Update the Makefile</h3>
</div>
<p>For this to work you need to make two changes to your Makefile.  First enable the secure sockets.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">COMPONENTS= FREERTOS LWIP MBEDTLS SECURE_SOCKETS</pre>
<p>Then ignore a few files from the AWS library.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">CY_IGNORE+=$(SEARCH_aws-iot-device-sdk-embedded-C)/libraries/standard/coreHTTP
CY_IGNORE+=libs/aws-iot-device-sdk-embedded-C/libraries/standard/coreHTTP
</pre>
<h3>5. Update the cloud_task.h</h3>
<div>
<p>In order for other tasks to send a message I will create a function where they can send a &#8220;speed&#8221; also known as a percent 0-100.  This function will be called from both the CapSense task as well as the JoyStick task.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">void cloud_sendMotorSpeed(int speed);
</pre>
<h3>6. Update the cloud_task.c</h3>
</div>
<p>In the previous lesson we created the cloud task which connects to the WiFI network.  In this lesson we add MQTT.  Start by adding the includes for the MQTT and the RTOS queue.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#include "cy_mqtt_api.h"
#include "queue.h"</pre>
<p>Rather than have magic numbers (or values) hidden in my code I provide #defines for:</p>
<ol>
<li>The MQTT broker</li>
<li>My Client ID</li>
<li>The Topic to broadcast to</li>
<li>The JSON key for the motor speed</li>
</ol>
<p>For other tasks to talk to this task they will push a value of the speed into a queue.  So I need to define that queue.  I will also use a static local variable to hold the handle of the MQTT connection.</p>
<p>I then define functions to</p>
<ol>
<li>Connect to MQTT</li>
<li>Start MQTT</li>
<li>Publish to MQTT</li>
</ol>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#define CLOUD_MQTT_BROKER        "mqtt.eclipseprojects.io"


#define CLOUD_MQTT_CLIENT_PREFIX "remote"
#define CLOUD_MQTT_TOPIC         "motor_speed"

#define MOTOR_KEY                "motor"

static QueueHandle_t motor_value_q;
static cy_mqtt_t mqtthandle;

static void cloud_connectWifi();
static void cloud_startMQTT();
static void cloud_mqtt_event_cb( cy_mqtt_t mqtt_handle, cy_mqtt_event_t event, void *user_data);

static void cloud_publishMessage(char *topic,char *message);</pre>
<p>The updates to the cloud task are:</p>
<ol>
<li>Start WiFi</li>
<li>Start MQTT</li>
<li>Start the queue</li>
<li>In the main loop, wait for a message, then publish it.</li>
</ol>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">void cloud_task(void* param)
{
    (void)param;

    cloud_connectWifi();
    cloud_startMQTT();

    motor_value_q = xQueueCreate(1,sizeof(uint32_t));

    for(;;)
    {
        int motorSpeed;
        char message[32];

    	xQueueReceive(motor_value_q, &amp;motorSpeed, portMAX_DELAY);
        snprintf(message, sizeof(message)-1, "{\"%s\":%d}",MOTOR_KEY,motorSpeed);
        cloud_publishMessage(CLOUD_MQTT_TOPIC,message);
    }
}
</pre>
<p>This function is used in other tasks to send the motor speed into the queue.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">void cloud_sendMotorSpeed(int speed)
{
    if(motor_value_q)
        xQueueOverwrite(motor_value_q,&amp;speed);
}
</pre>
<p>To start MQTT you need to</p>
<ol>
<li>Define the MQTT broker structure</li>
<li>Create the MQTT system</li>
<li>Define your connection information</li>
<li>Create a random clientID (so there are no duplicated clients on the MQTT broker)</li>
<li>Make the connection</li>
</ol>
<pre class="EnlighterJSRAW" data-enlighter-language="c">static void cloud_startMQTT()
{
    static cy_mqtt_connect_info_t    	connect_info;
    static cy_mqtt_broker_info_t     	broker_info;
    static uint8_t buffer[1024];

    cy_rslt_t result;

    result = cy_mqtt_init();
    broker_info.hostname = CLOUD_MQTT_BROKER;
    broker_info.hostname_len = strlen(broker_info.hostname);
    broker_info.port = 1883;

    result = cy_mqtt_create( buffer, sizeof(buffer),
                              NULL, &amp;broker_info,
                              cloud_mqtt_event_cb, NULL,
                              &amp;mqtthandle );

    CY_ASSERT(result == CY_RSLT_SUCCESS);

    static char clientId[32];
    srand(xTaskGetTickCount());
    snprintf(clientId,sizeof(clientId),"%s%6d",CLOUD_MQTT_CLIENT_PREFIX,rand());
    memset( &amp;connect_info, 0, sizeof( cy_mqtt_connect_info_t ) );
    connect_info.client_id      = clientId;
    connect_info.client_id_len  = strlen(connect_info.client_id);
    connect_info.keep_alive_sec = 60;
    connect_info.will_info      = 0;
    connect_info.clean_session = true;


    result = cy_mqtt_connect( mqtthandle, &amp;connect_info );
    CY_ASSERT(result == CY_RSLT_SUCCESS);
    printf("MQTT Connect Success to %s Client=%s\n",CLOUD_MQTT_BROKER,clientId);

}</pre>
<p>You need an MQTT callback.  This is unused in this lesson but we will modify it for the drone.  Just copy it into your project</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">static void cloud_mqtt_event_cb( cy_mqtt_t mqtt_handle, cy_mqtt_event_t event, void *user_data )
{
    cy_mqtt_publish_info_t *received_msg;
    printf( "\nMQTT App callback with handle : %p \n", mqtt_handle );
    (void)user_data;
    switch( event.type )
    {
        case CY_MQTT_EVENT_TYPE_DISCONNECT :
            if( event.data.reason == CY_MQTT_DISCONN_TYPE_BROKER_DOWN )
            {
                printf( "\nCY_MQTT_DISCONN_TYPE_BROKER_DOWN .....\n" );
            }
            else
            {
                printf( "\nCY_MQTT_DISCONN_REASON_NETWORK_DISCONNECTION .....\n" );
            }
            break;
        case CY_MQTT_EVENT_TYPE_PUBLISH_RECEIVE :
            received_msg = &amp;(event.data.pub_msg.received_message);
            printf( "Incoming Publish Topic Name: %.*s\n", received_msg-&gt;topic_len, received_msg-&gt;topic );
            printf( "Incoming Publish message Packet Id is %u.\n", event.data.pub_msg.packet_id );
            printf( "Incoming Publish Message : %.*s.\n\n", ( int )received_msg-&gt;payload_len, ( const char * )received_msg-&gt;payload );
            break;
        default :
            printf( "\nUNKNOWN EVENT .....\n" );
            break;
    }
}</pre>
<p>To publish a message you</p>
<ol>
<li>Create the message</li>
<li>Send the publish</li>
</ol>
<pre class="EnlighterJSRAW" data-enlighter-language="c">static void cloud_publishMessage(char *topic,char *message)
{
    cy_mqtt_publish_info_t  pub_msg;
        
    pub_msg.qos = CY_MQTT_QOS0;
    pub_msg.topic = topic;
    pub_msg.topic_len = strlen(pub_msg.topic);
    pub_msg.payload = message;
    pub_msg.payload_len = strlen(message);
    
    cy_mqtt_publish( mqtthandle, &amp;pub_msg );
    printf("Published to Topic=%s Message=%s\n",topic,message);
    
}
</pre>
<div>
<h3>7. Update joystick_task.c</h3>
</div>
<p>We want the joystick task to be able to send joystick positions.  Include the cloud_task.h so that it gets access to the function to send messages.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">#include "cloud_task.h"</pre>
<p>Update the joystick function to call the send message function.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">/* Only update/print new value if it has changed by more than the hysteresis value */
if((joystick_curr.x &gt; (joystick_prev.x + JOYSTICK_HYSTERESIS)) || (joystick_curr.x &lt; (joystick_prev.x - JOYSTICK_HYSTERESIS)))
{
    printf("Joystick Position: %d\n", joystick_curr.x);
    cloud_sendMotorSpeed(joystick_curr.x); 

}</pre>
<div>
<h3>8. Update capsense_task.c</h3>
</div>
<p>We want the CapSense task to be able to send CapSense positions.  Include the cloud_task.h so that it gets access to the function to send messages.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">#include "cloud_task.h"</pre>
<p>Update the button code to send either 0 or 75 (0=STOP!!!#*##&amp;&amp;#) (75=take off)</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">if((0u != button0_status) &amp;&amp; (0u == button0_status_prev))
{
    printf("Button 0 pressed\n");
    cloud_sendMotorSpeed(0); // Stop the Motor
}

if((0u != button1_status) &amp;&amp; (0u == button1_status_prev))
{
    printf("Button 1 pressed\n");
    cloud_sendMotorSpeed(75); // Set the motor to 75%
}</pre>
<p>The slider just sends the current position.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">if((0u != slider_touched) &amp;&amp; (slider_pos_prev != slider_pos ))
{
    printf("Slider position %d\n",slider_pos);
    cloud_sendMotorSpeed(slider_pos);
}</pre>
<h3>9. Test (using an MQTT Client)</h3>
<p>You can download/install MQTTBox from <a href="http://workswithweb.com/mqttbox.html" target="_blank" rel="noopener">here</a>  This is a Mac/Linux/Windows MQTT client.  This will enable you to attach to the MQTT broker and then subscribe to the motor speed topic.</p>
<p><a href="https://iotexpert.com/ew21-lesson-4-mqtt/screen-shot-2021-02-23-at-10-53-16-am/" rel="attachment wp-att-10916"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.53.16-AM-1024x673.jpg" alt="" width="1024" height="673" class="alignnone size-large wp-image-10916" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.53.16-AM-1024x673.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.53.16-AM-300x197.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.53.16-AM-768x504.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.53.16-AM-1536x1009.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.53.16-AM-2048x1345.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.53.16-AM-600x394.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Setup the configuration for the MQTT broker by pressing the gear button</p>
<p><a href="https://iotexpert.com/ew21-lesson-4-mqtt/screen-shot-2021-02-23-at-10-53-02-am/" rel="attachment wp-att-10915"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.53.02-AM-1024x485.png" alt="" width="1024" height="485" class="alignnone size-large wp-image-10915" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.53.02-AM-1024x485.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.53.02-AM-300x142.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.53.02-AM-768x364.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.53.02-AM-1536x728.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.53.02-AM-2048x971.png 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.53.02-AM-600x284.png 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Then program your remote control and send some joystick and CapSense values.</p>
<p><a href="https://iotexpert.com/ew21-lesson-4-mqtt/screen-shot-2021-02-23-at-10-52-48-am/" rel="attachment wp-att-10914"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.52.48-AM-1024x564.jpg" alt="" width="1024" height="564" class="alignnone size-large wp-image-10914" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.52.48-AM-1024x564.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.52.48-AM-300x165.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.52.48-AM-768x423.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.52.48-AM-1536x847.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.52.48-AM-600x331.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.52.48-AM.jpg 1836w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>And you will see them coming out on the MQTTBox client</p>
<p><a href="https://iotexpert.com/ew21-lesson-4-mqtt/screen-shot-2021-02-23-at-10-52-39-am/" rel="attachment wp-att-10913"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.52.39-AM-1024x769.jpg" alt="" width="1024" height="769" class="alignnone size-large wp-image-10913" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.52.39-AM-1024x769.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.52.39-AM-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.52.39-AM-768x577.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.52.39-AM-1536x1154.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.52.39-AM-600x451.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-10.52.39-AM.jpg 1922w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h3>10. Test (using our C++/Qt GUI)</h3>
<p>My friend Butch created a C++/Qt GUI to &#8220;simulate&#8221; the drone.  You can find it in the &#8220;simulator&#8221; directory of project 4.  Here is what it looks like.  You will need to put in</p>
<ol>
<li>Which broker you are using</li>
<li>The name of your Topic</li>
</ol>
<p><a href="https://iotexpert.com/ew21-lesson-4-mqtt/screen-shot-2021-02-23-at-11-13-18-am/" rel="attachment wp-att-10919"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-11.13.18-AM-813x1024.png" alt="" width="813" height="1024" class="alignnone size-large wp-image-10919" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-11.13.18-AM-813x1024.png 813w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-11.13.18-AM-238x300.png 238w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-11.13.18-AM-768x968.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-11.13.18-AM-600x756.png 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-11.13.18-AM.png 838w" sizes="auto, (max-width: 813px) 100vw, 813px" /></a></p>
<div>
<h1>Resources for Project</h1>
<p>You can find this completed project in your project creator dialog by filtering for &#8220;IoT Expert Embedded&#8221;.  This is lesson 4</p>
<p><a href="https://iotexpert.com/ew21-lesson-1-freertos-capsense/screen-shot-2021-02-22-at-4-33-54-pm/" rel="attachment wp-att-10817"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.33.54-PM-1024x581.png" alt="" width="1024" height="581" class="alignnone size-large wp-image-10817" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.33.54-PM-1024x581.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.33.54-PM-300x170.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.33.54-PM-768x436.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.33.54-PM-1536x872.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.33.54-PM-2048x1162.png 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.33.54-PM-600x341.png 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>You can also clone this project at git@github.com:iotexpert/ew21-lesson4.git or https://github.com/iotexpert/ew21-lesson4</p>
</div>
<div>
<p>Here is the final cloud_task.c</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#include &lt;stdio.h&gt;

#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"

#include "cy_wcm.h"
#include "cy_mqtt_api.h"

#include "cloud_task.h"


#define CLOUD_WIFI_AP        "ew2021"
#define CLOUD_WIFI_PW        "ew2021ap"
#define CLOUD_WIFI_SECURITY  CY_WCM_SECURITY_WPA2_AES_PSK
#define CLOUD_WIFI_BAND      CY_WCM_WIFI_BAND_ANY

#define CLOUD_MQTT_BROKER        "mqtt.eclipseprojects.io"


#define CLOUD_MQTT_CLIENT_PREFIX "remote"
#define CLOUD_MQTT_TOPIC         "motor_speed"

#define MOTOR_KEY                "motor"

static QueueHandle_t motor_value_q;
static cy_mqtt_t mqtthandle;

static void cloud_connectWifi();
static void cloud_startMQTT();
static void cloud_mqtt_event_cb( cy_mqtt_t mqtt_handle, cy_mqtt_event_t event, void *user_data);

static void cloud_publishMessage(char *topic,char *message);

void cloud_task(void* param)
{
    (void)param;

    cloud_connectWifi();
    cloud_startMQTT();

    motor_value_q = xQueueCreate(1,sizeof(uint32_t));

    for(;;)
    {
        int motorSpeed;
        char message[32];

    	xQueueReceive(motor_value_q, &amp;motorSpeed, portMAX_DELAY);
        snprintf(message, sizeof(message)-1, "{\"%s\":%d}",MOTOR_KEY,motorSpeed);
        cloud_publishMessage(CLOUD_MQTT_TOPIC,message);
    }
}

void cloud_sendMotorSpeed(int speed)
{
    if(motor_value_q)
        xQueueSend(motor_value_q,&amp;speed,0);
}

static void cloud_connectWifi()
{
    cy_rslt_t result;

    cy_wcm_connect_params_t connect_param = {
        .ap_credentials.SSID = CLOUD_WIFI_AP,
        .ap_credentials.password = CLOUD_WIFI_PW,
        .ap_credentials.security = CLOUD_WIFI_SECURITY,
    	.static_ip_settings = 0,
        .BSSID = {0},
        .band = CLOUD_WIFI_BAND,
    };
    cy_wcm_config_t config = {.interface = CY_WCM_INTERFACE_TYPE_STA}; // We are a station (not a Access Point)

    cy_wcm_init(&amp;config); // Initialize the connection manager

    printf("\nWi-Fi Connection Manager initialized.\n");

    do
    {
        cy_wcm_ip_address_t ip_address;

        printf("Connecting to Wi-Fi AP '%s'\n", connect_param.ap_credentials.SSID);
        result = cy_wcm_connect_ap(&amp;connect_param, &amp;ip_address);

        if (result == CY_RSLT_SUCCESS)
        {
            printf("Successfully connected to Wi-Fi network '%s'.\n",
                    connect_param.ap_credentials.SSID);

            // Print IP Address
            if (ip_address.version == CY_WCM_IP_VER_V4)
            {
                printf("IPv4 Address Assigned: %d.%d.%d.%d\n", (uint8_t)ip_address.ip.v4,
                        (uint8_t)(ip_address.ip.v4 &gt;&gt; 8), (uint8_t)(ip_address.ip.v4 &gt;&gt; 16),
                        (uint8_t)(ip_address.ip.v4 &gt;&gt; 24));
            }
            else if (ip_address.version == CY_WCM_IP_VER_V6)
            {
                printf("IPv6 Address Assigned: %0X:%0X:%0X:%0X\n", (unsigned int)ip_address.ip.v6[0],
                        (unsigned int)ip_address.ip.v6[1], (unsigned int)ip_address.ip.v6[2],
                        (unsigned int)ip_address.ip.v6[3]);
            }
            break; /* Exit the for loop once the connection has been made */
        }
        else
        {
            printf("WiFi Connect Failed Retrying\n");
            vTaskDelay(2000); // wait 2 seconds and try again;
        }

    } while (result != CY_RSLT_SUCCESS);

}

static void cloud_startMQTT()
{
    static cy_mqtt_connect_info_t    	connect_info;
    static cy_mqtt_broker_info_t     	broker_info;
    static uint8_t buffer[1024];

    cy_rslt_t result;

    result = cy_mqtt_init();
    broker_info.hostname = CLOUD_MQTT_BROKER;
    broker_info.hostname_len = strlen(broker_info.hostname);
    broker_info.port = 1883;

    result = cy_mqtt_create( buffer, sizeof(buffer),
                              NULL, &amp;broker_info,
                              cloud_mqtt_event_cb, NULL,
                              &amp;mqtthandle );

    CY_ASSERT(result == CY_RSLT_SUCCESS);

    static char clientId[32];
    srand(xTaskGetTickCount());
    snprintf(clientId,sizeof(clientId),"%s%6d",CLOUD_MQTT_CLIENT_PREFIX,rand());
    memset( &amp;connect_info, 0, sizeof( cy_mqtt_connect_info_t ) );
    connect_info.client_id      = clientId;
    connect_info.client_id_len  = strlen(connect_info.client_id);
    connect_info.keep_alive_sec = 60;
    connect_info.will_info      = 0;
    connect_info.clean_session = true;


    result = cy_mqtt_connect( mqtthandle, &amp;connect_info );
    CY_ASSERT(result == CY_RSLT_SUCCESS);
    printf("MQTT Connect Success to %s Client=%s\n",CLOUD_MQTT_BROKER,clientId);

}

static void cloud_mqtt_event_cb( cy_mqtt_t mqtt_handle, cy_mqtt_event_t event, void *user_data )
{
    cy_mqtt_publish_info_t *received_msg;
    printf( "\nMQTT App callback with handle : %p \n", mqtt_handle );
    (void)user_data;
    switch( event.type )
    {
        case CY_MQTT_EVENT_TYPE_DISCONNECT :
            if( event.data.reason == CY_MQTT_DISCONN_TYPE_BROKER_DOWN )
            {
                printf( "\nCY_MQTT_DISCONN_TYPE_BROKER_DOWN .....\n" );
            }
            else
            {
                printf( "\nCY_MQTT_DISCONN_REASON_NETWORK_DISCONNECTION .....\n" );
            }
            break;
        case CY_MQTT_EVENT_TYPE_PUBLISH_RECEIVE :
            received_msg = &amp;(event.data.pub_msg.received_message);
            printf( "Incoming Publish Topic Name: %.*s\n", received_msg-&gt;topic_len, received_msg-&gt;topic );
            printf( "Incoming Publish message Packet Id is %u.\n", event.data.pub_msg.packet_id );
            printf( "Incoming Publish Message : %.*s.\n\n", ( int )received_msg-&gt;payload_len, ( const char * )received_msg-&gt;payload );
            break;
        default :
            printf( "\nUNKNOWN EVENT .....\n" );
            break;
    }
}

static void cloud_publishMessage(char *topic,char *message)
{
    cy_mqtt_publish_info_t  pub_msg;
        
    pub_msg.qos = CY_MQTT_QOS0;
    pub_msg.topic = topic;
    pub_msg.topic_len = strlen(pub_msg.topic);
    pub_msg.payload = message;
    pub_msg.payload_len = strlen(message);
    
    cy_mqtt_publish( mqtthandle, &amp;pub_msg );
    printf("Published to Topic=%s Message=%s\n",topic,message);
    
}
</pre>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/ew21-lesson-4-mqtt/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>EW21: Lesson 5: Low Power</title>
		<link>https://iotexpert.com/ew21-lesson-5-low-power/</link>
					<comments>https://iotexpert.com/ew21-lesson-5-low-power/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Wed, 24 Feb 2021 15:23:04 +0000</pubDate>
				<category><![CDATA[Embedded World 2021]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=10784</guid>

					<description><![CDATA[Summary The FreeRTOS template we started with already enables low power mode transitions such as Sleep and Deep Sleep. In lesson 5 we will update our remote control project to have even lower power as remote controls are almost always driven by batteries.  We will do this by using lower power regulators, slowing down clocks, [&#8230;]]]></description>
										<content:encoded><![CDATA[<div>
<p><span><h1>Embedded World 2021 - Infineon ModusToolbox PSoC 6 Drone </h1>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >#</th>
<th >Description</th>
</tr>
</thead>
<tbody>
<tr><td >0</td>
<td ><a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/" target="_blank" rel="noopener">Introduction &amp; Resources</a></td>
</tr>

<tr><td >1</td>
<td ><a href="https://iotexpert.com/ew21-lesson-1-freertos-capsense/" target="_blank" rel="noopener">FreeRTOS &amp; CapSense</a></td>
</tr>

<tr><td >2</td>
<td ><a href="https://iotexpert.com/ew21-lesson-2-joystick/" target="_blank" rel="noopener">3-D Magnetic Sensing XENSIV Joystick</a></td>
</tr>

<tr><td >3</td>
<td ><a href="https://iotexpert.com/ew21-lesson-3-wifi/" target="_blank" rel="noopener">WiFi</a></td>
</tr>

<tr><td >4</td>
<td ><a href="https://iotexpert.com/ew21-lesson-4-mqtt/" target="_blank" rel="noopener">MQTT</a></td>
</tr>

<tr><td >5</td>
<td ><a href="https://iotexpert.com/ew21-lesson-5-low-power/" target="_blank" rel="noopener">Low Power</a></td>
</tr>

<tr><td >6</td>
<td ><a href="https://iotexpert.com/ew21-lesson-6-motor-control/" target="_blank" rel="noopener">BLDC Motor Control</a></td>
</tr>

<tr><td >7</td>
<td ><a href="https://iotexpert.com/ew21-lesson-7-ws2812-led-strip/" target="_blank" rel="noopener">WS2812 Strip LEDs</a></td>
</tr>
</tbody></table></div></p>
<p>&nbsp;</p></span></p>
<h1>Summary</h1>
<p>The FreeRTOS template we started with already enables low power mode transitions such as Sleep and Deep Sleep. In lesson 5 we will update our remote control project to have even lower power as remote controls are almost always driven by batteries.  We will do this by using lower power regulators, slowing down clocks, and by offloading some functionality to the WiFi chip. This will be the final lesson on the remote control.  Here is the architecture:</p>
<p><a href="https://iotexpert.com/ew21-lesson-5-low-power/l5-arch/" rel="attachment wp-att-10983"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/l5-arch-1024x433.png" alt="" width="1024" height="433" class="alignnone size-large wp-image-10983" srcset="https://iotexpert.com/wp-content/uploads/2021/02/l5-arch-1024x433.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/l5-arch-300x127.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/l5-arch-768x324.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/l5-arch-1536x649.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/l5-arch-600x253.png 600w, https://iotexpert.com/wp-content/uploads/2021/02/l5-arch.png 1631w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Learning Objectives</h1>
<p>This lesson will show you two important features of Modus Toolbox.</p>
<ol>
<li>How to reduce system power using the Low Power Assistant</li>
<li>How to create a custom board support package</li>
</ol>
<h1>Procedure</h1>
<ol>
<li>Create your project</li>
<li>Create a custom Board Support Package</li>
<li>Modify the Makefile to use the new BSP</li>
<li>Add the Low Power Assistant to the project</li>
<li>Use the Configurator to setup Low Power</li>
<li>Examine FreeRTOSConfig.h</li>
<li>Test the project</li>
</ol>
<h3>1. Create the project</h3>
<p>Start the project creator and make a copy of your 4th project.</p>
<p><a href="https://iotexpert.com/ew21-lesson-5-low-power/screen-shot-2021-02-23-at-5-27-11-pm/" rel="attachment wp-att-10987"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-5.27.11-PM-1024x708.jpg" alt="" width="1024" height="708" class="alignnone size-large wp-image-10987" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-5.27.11-PM-1024x708.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-5.27.11-PM-300x207.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-5.27.11-PM-768x531.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-5.27.11-PM-1536x1062.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-5.27.11-PM-2048x1416.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-5.27.11-PM-600x415.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Call it Lesson_5</p>
<p><a href="https://iotexpert.com/ew21-lesson-5-low-power/screen-shot-2021-02-23-at-5-27-51-pm/" rel="attachment wp-att-10988"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-5.27.51-PM-1024x717.jpg" alt="" width="1024" height="717" class="alignnone size-large wp-image-10988" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-5.27.51-PM-1024x717.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-5.27.51-PM-300x210.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-5.27.51-PM-768x538.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-5.27.51-PM-1536x1076.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-5.27.51-PM-2048x1435.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-5.27.51-PM-600x420.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h3>2. Override the BSP Configuration</h3>
<p>Make a directory called &#8220;COMPONENT_CUSTOM_DESIGN_MODUS&#8221; to contain the configuration files that will override the configuration from the BSP.  This will be brought into the project automatically by the build system.</p>
<p>Note: You can also create a complete custom BSP which allows changing things like linker scripts, startup code, etc. See the ModusToolbox User Guide for details on how to do that.</p>
<p><a href="https://iotexpert.com/ew21-lesson-5-low-power/screen-shot-2021-02-23-at-1-48-42-pm/" rel="attachment wp-att-10943"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.48.42-PM-1024x276.png" alt="" width="1024" height="276" class="alignnone size-large wp-image-10943" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.48.42-PM-1024x276.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.48.42-PM-300x81.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.48.42-PM-768x207.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.48.42-PM-600x161.png 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.48.42-PM.png 1152w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Make a directory called &#8220;TARGET_CY8CPROTO-062-4343W&#8221; in your project.  This directory will hold the custom BSP files.</p>
<p><a href="https://iotexpert.com/ew21-lesson-5-low-power/screen-shot-2021-02-23-at-1-49-09-pm/" rel="attachment wp-att-10944"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.49.09-PM-1024x258.png" alt="" width="1024" height="258" class="alignnone size-large wp-image-10944" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.49.09-PM-1024x258.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.49.09-PM-300x76.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.49.09-PM-768x194.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.49.09-PM-600x151.png 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.49.09-PM.png 1150w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Copy and paste the configuration files from the Modus Toolbox BSP directly into your project.</p>
<p><a href="https://iotexpert.com/ew21-lesson-5-low-power/screen-shot-2021-02-23-at-1-49-32-pm/" rel="attachment wp-att-10945"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.49.32-PM-988x1024.png" alt="" width="988" height="1024" class="alignnone size-large wp-image-10945" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.49.32-PM-988x1024.png 988w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.49.32-PM-289x300.png 289w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.49.32-PM-768x796.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.49.32-PM-600x622.png 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.49.32-PM.png 1140w" sizes="auto, (max-width: 988px) 100vw, 988px" /></a></p>
<p>Now your project should have these files:</p>
</div>
<p><a href="https://iotexpert.com/ew21-lesson-5-low-power/screen-shot-2021-02-24-at-8-33-25-am/" rel="attachment wp-att-11048"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-8.33.25-AM-1024x317.png" alt="" width="1024" height="317" class="alignnone size-large wp-image-11048" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-8.33.25-AM-1024x317.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-8.33.25-AM-300x93.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-8.33.25-AM-768x238.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-8.33.25-AM-600x186.png 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-24-at-8.33.25-AM.png 1136w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<div>
<h3>3. Modify the Makefile</h3>
</div>
<p>You need to</p>
<ol>
<li>Enable your new BSP</li>
<li>Disable the existing BSP</li>
</ol>
<p>Do this by adding to the COMPONENTS and DISABLE_COMPONENTS line in the Makefile</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">COMPONENTS= FREERTOS LWIP MBEDTLS SECURE_SOCKETS CUSTOM_DESIGN_MODUS WCM
DISABLE_COMPONENTS=BSP_DESIGN_MODUS</pre>
<div>
<h3>4. Add the Low Power Assistant to the project</h3>
<p>Start the Library Manager and add the LPA (Low Power Assistant) library to your project</p>
<p><a href="https://iotexpert.com/ew21-lesson-5-low-power/screen-shot-2021-02-23-at-1-12-02-pm/" rel="attachment wp-att-10939"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.12.02-PM-1024x795.jpg" alt="" width="1024" height="795" class="alignnone size-large wp-image-10939" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.12.02-PM-1024x795.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.12.02-PM-300x233.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.12.02-PM-768x596.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.12.02-PM-1536x1193.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.12.02-PM-2048x1590.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.12.02-PM-600x466.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h3>5. Use the configurator to Setup for Low Power</h3>
<p>Set the System Active Power Mode to ULP and enable the &#8220;Normal Current Buck&#8221;.</p>
<p>Notice that the System Idle Power Mode is already set to System Deep Sleep. This means that when the RTOS is not busy, it will attempt to enter Deep Sleep mode.</p>
<p><a href="https://iotexpert.com/ew21-lesson-5-low-power/screen-shot-2021-02-23-at-1-03-49-pm/" rel="attachment wp-att-10934"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.03.49-PM-1024x918.jpg" alt="" width="1024" height="918" class="alignnone size-large wp-image-10934" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.03.49-PM-1024x918.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.03.49-PM-300x269.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.03.49-PM-768x689.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.03.49-PM-1536x1378.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.03.49-PM-2048x1837.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.03.49-PM-600x538.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Turn down the FLL to 50 Mhz</p>
<p><a href="https://iotexpert.com/ew21-lesson-5-low-power/screen-shot-2021-02-23-at-1-05-04-pm/" rel="attachment wp-att-10935"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.05.04-PM-1024x918.jpg" alt="" width="1024" height="918" class="alignnone size-large wp-image-10935" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.05.04-PM-1024x918.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.05.04-PM-300x269.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.05.04-PM-768x689.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.05.04-PM-1536x1377.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.05.04-PM-2048x1836.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.05.04-PM-600x538.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Lower the frequency of the peripherals by cutting the divider in half.</p>
<p><a href="https://iotexpert.com/ew21-lesson-5-low-power/screen-shot-2021-02-23-at-1-05-16-pm/" rel="attachment wp-att-10936"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.05.16-PM-1024x465.jpg" alt="" width="1024" height="465" class="alignnone size-large wp-image-10936" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.05.16-PM-1024x465.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.05.16-PM-300x136.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.05.16-PM-768x348.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.05.16-PM-1536x697.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.05.16-PM-2048x929.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.05.16-PM-600x272.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>In order to save power the host can sleep and wait for WiFi packets.  The WiFi chip needs to be able to wakeup the host PSoC.  Enable P0[4] as the wakeup pin and turn on the interrupt.</p>
<p><a href="https://iotexpert.com/ew21-lesson-5-low-power/screen-shot-2021-02-23-at-1-09-32-pm/" rel="attachment wp-att-10937"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.09.32-PM-1024x906.png" alt="" width="1024" height="906" class="alignnone size-large wp-image-10937" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.09.32-PM-1024x906.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.09.32-PM-300x265.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.09.32-PM-768x679.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.09.32-PM-600x531.png 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.09.32-PM.png 1318w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>&nbsp;</p>
<p>Click on the CYW4343WKUGB tab.  Enable the host wakeup option.  Set the pin to P0[4].  Enable ARP off loads.  You can also look through the other low power offload filters.</p>
<p><a href="https://iotexpert.com/ew21-lesson-5-low-power/screen-shot-2021-02-23-at-1-46-37-pm/" rel="attachment wp-att-10941"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.46.37-PM-1024x480.jpg" alt="" width="1024" height="480" class="alignnone size-large wp-image-10941" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.46.37-PM-1024x480.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.46.37-PM-300x141.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.46.37-PM-768x360.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.46.37-PM-1536x720.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.46.37-PM-2048x960.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-1.46.37-PM-600x281.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h3>6. Examine FreeRTOSConfig.h</h3>
<p>Along with the System Idle Power Mode in the Configurator, this block of code tells FreeRTOS that when the system is idle that it should go to sleep.</p>
<p>The function vApplicationSleep is in the abstraction-rtos library and it allows the system to go to sleep and wake up cleanly in the context of FreeRTOS.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">#if CY_CFG_PWR_SYS_IDLE_MODE == CY_CFG_PWR_MODE_SLEEP || CY_CFG_PWR_SYS_IDLE_MODE == CY_CFG_PWR_MODE_DEEPSLEEP
extern void vApplicationSleep( uint32_t xExpectedIdleTime );
#define portSUPPRESS_TICKS_AND_SLEEP( xIdleTime ) vApplicationSleep( xIdleTime )
#define configUSE_TICKLESS_IDLE  2
#endif

#if CY_CFG_PWR_DEEPSLEEP_LATENCY&gt;0
#define configEXPECTED_IDLE_TIME_BEFORE_SLEEP CY_CFG_PWR_DEEPSLEEP_LATENCY
#endif
</pre>
<h3>7. Test</h3>
<p>Program and test to make sure that things still work.  If you have a DMM plug it in and find out how much power you saved.</p>
<p><a href="https://iotexpert.com/ew21-lesson-5-low-power/screen-shot-2021-02-23-at-2-11-04-pm/" rel="attachment wp-att-10947"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-2.11.04-PM-1024x552.jpg" alt="" width="1024" height="552" class="alignnone size-large wp-image-10947" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-2.11.04-PM-1024x552.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-2.11.04-PM-300x162.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-2.11.04-PM-768x414.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-2.11.04-PM-1536x828.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-2.11.04-PM-2048x1104.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-2.11.04-PM-600x324.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Resources for Project</h1>
<p>You can find the completed project in your project creator dialog by filtering for &#8220;IoT Expert Embedded&#8221;.  This is lesson5</p>
<p><a href="https://iotexpert.com/ew21-lesson-1-freertos-capsense/screen-shot-2021-02-22-at-4-34-13-pm/" rel="attachment wp-att-10816"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.34.13-PM-1024x586.png" alt="" width="1024" height="586" class="alignnone size-large wp-image-10816" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.34.13-PM-1024x586.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.34.13-PM-300x172.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.34.13-PM-768x439.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.34.13-PM-1536x879.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.34.13-PM-2048x1172.png 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.34.13-PM-600x343.png 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>You can also clone this project at git@github.com:iotexpert/ew21-lesson5.git or https://github.com/iotexpert/ew21-lesson5</p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/ew21-lesson-5-low-power/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>EW21: Lesson 6: Motor Control</title>
		<link>https://iotexpert.com/ew21-lesson-6-motor-control/</link>
					<comments>https://iotexpert.com/ew21-lesson-6-motor-control/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Wed, 24 Feb 2021 15:22:28 +0000</pubDate>
				<category><![CDATA[Embedded World 2021]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=10785</guid>

					<description><![CDATA[Summary In lesson 6 we will turn our attention to the drone. Everything on the drone side is almost exactly the same as remote control, so I will copy all of that code to start with then add the motor controller.  At the end of lesson one you will have the functioning drone controller.  Here [&#8230;]]]></description>
										<content:encoded><![CDATA[<div>
<p><span><h1>Embedded World 2021 - Infineon ModusToolbox PSoC 6 Drone </h1>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >#</th>
<th >Description</th>
</tr>
</thead>
<tbody>
<tr><td >0</td>
<td ><a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/" target="_blank" rel="noopener">Introduction &amp; Resources</a></td>
</tr>

<tr><td >1</td>
<td ><a href="https://iotexpert.com/ew21-lesson-1-freertos-capsense/" target="_blank" rel="noopener">FreeRTOS &amp; CapSense</a></td>
</tr>

<tr><td >2</td>
<td ><a href="https://iotexpert.com/ew21-lesson-2-joystick/" target="_blank" rel="noopener">3-D Magnetic Sensing XENSIV Joystick</a></td>
</tr>

<tr><td >3</td>
<td ><a href="https://iotexpert.com/ew21-lesson-3-wifi/" target="_blank" rel="noopener">WiFi</a></td>
</tr>

<tr><td >4</td>
<td ><a href="https://iotexpert.com/ew21-lesson-4-mqtt/" target="_blank" rel="noopener">MQTT</a></td>
</tr>

<tr><td >5</td>
<td ><a href="https://iotexpert.com/ew21-lesson-5-low-power/" target="_blank" rel="noopener">Low Power</a></td>
</tr>

<tr><td >6</td>
<td ><a href="https://iotexpert.com/ew21-lesson-6-motor-control/" target="_blank" rel="noopener">BLDC Motor Control</a></td>
</tr>

<tr><td >7</td>
<td ><a href="https://iotexpert.com/ew21-lesson-7-ws2812-led-strip/" target="_blank" rel="noopener">WS2812 Strip LEDs</a></td>
</tr>
</tbody></table></div></p>
<p>&nbsp;</p></span></p>
<h1>Summary</h1>
<p>In lesson 6 we will turn our attention to the drone. Everything on the drone side is almost exactly the same as remote control, so I will copy all of that code to start with then add the motor controller.  At the end of lesson one you will have the functioning drone controller.  Here is the architecture:</p>
<p><a href="https://iotexpert.com/ew21-lesson-6-motor-control/l6-arch/" rel="attachment wp-att-10985"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/l6-arch-1024x433.png" alt="" width="1024" height="433" class="alignnone size-large wp-image-10985" srcset="https://iotexpert.com/wp-content/uploads/2021/02/l6-arch-1024x433.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/l6-arch-300x127.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/l6-arch-768x324.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/l6-arch-1536x649.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/l6-arch-600x253.png 600w, https://iotexpert.com/wp-content/uploads/2021/02/l6-arch.png 1631w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Learning Objectives</h1>
<ol>
<li>Retargeting a project to a different board</li>
<li>Using the Infineon BLDC Motor Controller</li>
<li>Subscribing to a MQTT topic</li>
</ol>
<h1>Procedure</h1>
<ol>
<li>Make a new project</li>
<li>Rip out the joystick_task.c/h and fix main.c</li>
<li>Add the motor driver library</li>
<li>Create motor_task.h</li>
<li>Create motor_task.c</li>
<li>Update the CapSense task to submit to the motor_task</li>
<li>Fix the Cloud Task to perform MQTT subscribe instead of publish</li>
<li>Fix main.c to start the motor task</li>
<li>Test</li>
</ol>
<h3>1. Make a new project</h3>
<p>In order to control the BLDC motor I am going to a development kit that has Arduino headers, the CY8CKIT-062S2-43012.  Start your project from that BSP.</p>
<p><a href="https://iotexpert.com/ew21-lesson-6-motor-control/screen-shot-2021-02-23-at-3-07-24-pm/" rel="attachment wp-att-10951"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.07.24-PM-1024x708.jpg" alt="" width="1024" height="708" class="alignnone size-large wp-image-10951" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.07.24-PM-1024x708.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.07.24-PM-300x208.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.07.24-PM-768x531.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.07.24-PM-1536x1062.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.07.24-PM-2048x1417.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.07.24-PM-600x415.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Our project is basically the same as Lesson4, so import that as a template.</p>
<p><a href="https://iotexpert.com/ew21-lesson-6-motor-control/screen-shot-2021-02-23-at-3-07-37-pm/" rel="attachment wp-att-10952"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.07.37-PM-1024x583.png" alt="" width="1024" height="583" class="alignnone size-large wp-image-10952" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.07.37-PM-1024x583.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.07.37-PM-300x171.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.07.37-PM-768x437.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.07.37-PM-1536x875.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.07.37-PM-600x342.png 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.07.37-PM.png 1594w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Don&#8217;t sully your project&#8217;s name, pick something good.</p>
<p><a href="https://iotexpert.com/ew21-lesson-6-motor-control/screen-shot-2021-02-23-at-3-08-08-pm/" rel="attachment wp-att-10953"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.08.08-PM-1024x489.jpg" alt="" width="1024" height="489" class="alignnone size-large wp-image-10953" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.08.08-PM-1024x489.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.08.08-PM-300x143.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.08.08-PM-768x367.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.08.08-PM-1536x734.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.08.08-PM-2048x979.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.08.08-PM-600x287.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h3>2. Rip out the joystick_task</h3>
<p>This project will not have the joystick task.  Nuke it! Don&#8217;t forget to remove the task start from main.c</p>
<p><a href="https://iotexpert.com/ew21-lesson-6-motor-control/screen-shot-2021-02-23-at-3-09-27-pm/" rel="attachment wp-att-10954"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.09.27-PM-1024x578.png" alt="" width="1024" height="578" class="alignnone size-large wp-image-10954" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.09.27-PM-1024x578.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.09.27-PM-300x169.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.09.27-PM-768x434.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.09.27-PM-600x339.png 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.09.27-PM.png 1172w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h3>3. Add the Motor Driver Library and Remove the Magnetic Sensor</h3>
<p>For this project we will be talking to the TLE9879 BLDC motor shield.  I provide you a driver library for that.  And we won&#8217;t need the 3-D Magnetic sensing library any more.</p>
</div>
<p><a href="https://iotexpert.com/ew21-lesson-6-motor-control/screen-shot-2021-02-23-at-3-23-18-pm/" rel="attachment wp-att-10956"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.23.18-PM-1024x793.jpg" alt="" width="1024" height="793" class="alignnone size-large wp-image-10956" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.23.18-PM-1024x793.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.23.18-PM-300x232.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.23.18-PM-768x595.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.23.18-PM-1536x1190.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.23.18-PM-2048x1586.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.23.18-PM-600x465.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<div>
<h3>4. Create motor_task.h</h3>
</div>
<p>Create a motor_task.h  This will have the definition of the task, plus a function to set the motor speed by submitting to a queue.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#pragma once

void motor_task(void* param);

void motor_update(int speed);
</pre>
<div>
<h3>5. Create motor_task.c</h3>
</div>
<p>The motor task needs some include files.  This task will also use a queue to manage other tasks (cloud and CapSense) that will submitting data to change the speed of the motor.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#include "cybsp.h"
#include "cyhal.h"
#include "cycfg.h"
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;math.h&gt;

#include "motor_task.h"

#include "tle9879_system.h"

static QueueHandle_t motor_value_q;</pre>
<p>I will define a few constants that will help me map 0-100% into 0-5500 RPM (the max for this motor). The motor needs to run at a decent speed to start up properly so we will map 10% to 1000 RPM. Below 10%, the motor will be off.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">/*******************************************************************************
* Global constants
*******************************************************************************/
#define		RPM_CHANGE_INTERVAL		(100)
#define		RPM_CHANGE_RATE			(10)
#define		RPM_PERCENT_MIN			(10)

#define  	RPM_MAX 				5500.0
#define  	RPM_MIN 				1000.0
</pre>
<p>The task is pretty simple, but with one trick.  Apparently you ramp changes in motor speed, so I use a timeout in the message queue to give me a periodic change.  The task is</p>
<ol>
<li>Start the shield</li>
<li>Then wait for a new value in the queue (or the timeout)</li>
<li>If it is a new value then change the desired value</li>
<li>If the current value is not the same as the desired value then take a step towards the desired value</li>
</ol>
<pre class="EnlighterJSRAW" data-enlighter-language="c">void motor_task(void* param)
{
    (void)param;

    tle9879_sys_t tle9879_sys;

    uint8_t numberOfBoards = 1;
    BaseType_t rtos_api_result;

    motor_value_q = xQueueCreate(1,sizeof(int));

    /* Initialize and configure the motor driver */
    tle9879sys_init(&amp;tle9879_sys,
    					CYBSP_D11,
                        CYBSP_D12,
                        CYBSP_D13,
                        NULL,
                        CYBSP_D4,
                        CYBSP_D5,
                        CYBSP_D6,
                        CYBSP_D7,
                        &amp;numberOfBoards);
    if (tle9879_sys.board_count == 0)
    {
        printf("Motor board not detected. Exiting Motor task.\n");
        vTaskDelete(NULL);
    }

    tle9879sys_setMode(&amp;tle9879_sys, FOC, 1, false);
    
    bool motorState=false;
    int currentPercentage=0;
    int desiredPercentage=0;

    while(1)
    {
    	rtos_api_result = xQueueReceive(motor_value_q, &amp;desiredPercentage, RPM_CHANGE_INTERVAL);

       	/* Value has been received from the queue (i.e. not a timeout) */
        if(rtos_api_result == pdTRUE)
        {
            if(desiredPercentage &lt; RPM_PERCENT_MIN) /* Any value less than 10% will result in stopping the motor */
                desiredPercentage = 0;
        
            if(desiredPercentage&gt;100)
                desiredPercentage = 100;
        }

        if(currentPercentage != desiredPercentage)
        {
            if(abs(currentPercentage-desiredPercentage) &lt; RPM_CHANGE_RATE)
                currentPercentage = desiredPercentage;

            if (currentPercentage &lt; desiredPercentage)
                currentPercentage = currentPercentage + RPM_CHANGE_RATE;
            if (currentPercentage &gt; desiredPercentage)
                currentPercentage = currentPercentage - RPM_CHANGE_RATE;

            if(currentPercentage&gt;0 &amp;&amp; motorState==false)
            {
                tle9879sys_setMotorMode(&amp;tle9879_sys, START_MOTOR, 1);
                motorState = true;
            }
            if(currentPercentage == 0 &amp;&amp; motorState==true)
            {
                tle9879sys_setMotorMode(&amp;tle9879_sys, STOP_MOTOR, 1);
                motorState = false;
            }

            float motorSpeed = ((float)(currentPercentage-RPM_PERCENT_MIN))/(float)(100.0-RPM_PERCENT_MIN) * (RPM_MAX - RPM_MIN) + RPM_MIN;

            tle9879sys_setMotorSpeed(&amp;tle9879_sys, motorSpeed, 1);
            printf("Current %d%% Desired=%d%% Speed=%f\n",currentPercentage,desiredPercentage,motorSpeed);
        }
    }
}</pre>
<p>In order to simplify the CapSense and cloud tasks I provide a function to submit a new percent to the queue.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">void motor_update(int speed)
{
    if(motor_value_q)
        xQueueOverwrite(motor_value_q,&amp;speed);
}
</pre>
<div>
<h3>6. Update the CapSense task to submit to the motor_task</h3>
</div>
<p>Lets fix the CapSense task to submit to the motor queue.  First fix the include.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">#include "motor_task.h"</pre>
<p>Then update the buttons to use the submit function</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">if((0u != button0_status) &amp;&amp; (0u == button0_status_prev))
{
    printf("Button 0 pressed\n");
    motor_update(0); // Stop the Motor
}

if((0u != button1_status) &amp;&amp; (0u == button1_status_prev))
{
    printf("Button 1 pressed\n");
    motor_update(75); // Set the motor to 75%
}
</pre>
<p>Fix the slider to use the submit function as well.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">if((0u != slider_touched) &amp;&amp; (slider_pos_prev != slider_pos ))
{
    printf("Slider position %d\n",slider_pos);
    motor_update(slider_pos);
}
</pre>
<p>7. Fix the Cloud Task</p>
<p>Remember that we copied our cloud task from the remote control.  It publishes MQTT messages.  We need to fix the cloud task to subscribe instead of publish.   If you recall from Lesson 4 we submit the messages as JSON.  To decode the JSON I will use a JSON parser.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#include "cy_json_parser.h"</pre>
<p>The function prototypes are almost the same, except for a subscribe instead of publish, plus a JSON callback</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">static void cloud_connectWifi();
static void cloud_startMQTT();
static void cloud_subscribeMQTT();
static void cloud_mqtt_event_cb( cy_mqtt_t mqtt_handle, cy_mqtt_event_t event, void *user_data);
static cy_rslt_t json_cb(cy_JSON_object_t *json_object, void *arg);
</pre>
<p>The cloud task is much simpler this time.  connect, start, subscribe and then wait for some action.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">void cloud_task(void* param)
{
    (void)param;

    cloud_connectWifi();
    cloud_startMQTT();
    cloud_subscribeMQTT();

    for(;;)
    {
        vTaskSuspend(NULL);
    }
}</pre>
<p>To subscribe you just setup a subscribe info structure.  Then call the subscribe.  You also need to configure the JSON parser.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">static void cloud_subscribeMQTT()
{

    cy_rslt_t result;

    cy_mqtt_subscribe_info_t    sub_msg[1];

    /* Subscribe to motor speed MQTT messages */
    sub_msg[0].qos = 0;
    sub_msg[0].topic = CLOUD_MQTT_TOPIC;
    sub_msg[0].topic_len = strlen(sub_msg[0].topic);

    result = cy_mqtt_subscribe( mqtthandle, sub_msg, 1 );
    CY_ASSERT(result == CY_RSLT_SUCCESS);
    printf("Subscribe Success to Topic %s\n",CLOUD_MQTT_TOPIC);

    /* Register JSON callback function */
    cy_JSON_parser_register_callback(json_cb, NULL);

}
</pre>
<p>When you get a callback from the MQTT, you will look and see which topic.  If it matches the motor topic then call the JSON parser.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">static void cloud_mqtt_event_cb( cy_mqtt_t mqtt_handle, cy_mqtt_event_t event, void *user_data )
{
    cy_mqtt_publish_info_t *received_msg;
    printf( "\nMQTT App callback with handle : %p \n", mqtt_handle );
    (void)user_data;
    switch( event.type )
    {
        case CY_MQTT_EVENT_TYPE_DISCONNECT :
            if( event.data.reason == CY_MQTT_DISCONN_TYPE_BROKER_DOWN )
            {
                printf( "\nCY_MQTT_DISCONN_TYPE_BROKER_DOWN .....\n" );
            }
            else
            {
                printf( "\nCY_MQTT_DISCONN_REASON_NETWORK_DISCONNECTION .....\n" );
            }
            break;
        case CY_MQTT_EVENT_TYPE_PUBLISH_RECEIVE :
            received_msg = &amp;(event.data.pub_msg.received_message);
            printf( "Incoming Publish Topic Name: %.*s\n", received_msg-&gt;topic_len, received_msg-&gt;topic );
            printf( "Incoming Publish message Packet Id is %u.\n", event.data.pub_msg.packet_id );
            printf( "Incoming Publish Message : %.*s.\n\n", ( int )received_msg-&gt;payload_len, ( const char * )received_msg-&gt;payload );
            if(memcmp(received_msg-&gt;topic, CLOUD_MQTT_TOPIC, strlen(CLOUD_MQTT_TOPIC)) == 0) /* Topic matches the motor speed topic */
            {
                    cy_JSON_parser(received_msg-&gt;payload, received_msg-&gt;payload_len);
            }
            
            break;
        default :
            printf( "\nUNKNOWN EVENT .....\n" );
            break;
    }
}</pre>
<p>If the JSON parser matches, you call the motor_update function with the new requested speed.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">/* This is the callback from the cy_JSON_parser function. It is called whenever
 * the parser finds a JSON object. */
static cy_rslt_t json_cb(cy_JSON_object_t *json_object, void *arg)
{
    int motorSpeed;

    if(memcmp(json_object-&gt;object_string, MOTOR_KEY, json_object-&gt;object_string_length) == 0)
    {
        if(json_object-&gt;value_type == JSON_NUMBER_TYPE)
        {
            /* Add null termination to the value and then convert to a number */
            char resultString[json_object-&gt;value_length + 1];
            memcpy(resultString, json_object-&gt;value, json_object-&gt;value_length);
            resultString[json_object-&gt;value_length] = 0;
            motorSpeed = (uint8_t) atoi(resultString);
            printf("Received speed value from cloud: %d\n", motorSpeed);
            motor_update(motorSpeed);
        }
    }
    return CY_RSLT_SUCCESS;
}
</pre>
<div>
<h3>8. Fix main.c to start the motor task</h3>
</div>
<p>In main.c you need to &#8220;do the needful&#8221; starting with an include.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">#include "motor_task.h"</pre>
<p>Then starting the motor task.</p>
<div>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">xTaskCreate(motor_task,    "Motor"     ,configMINIMAL_STACK_SIZE*8  , NULL, 1, 0);
</pre>
<h3>9. Test</h3>
<p><a href="https://iotexpert.com/ew21-lesson-6-motor-control/screen-shot-2021-02-23-at-3-48-46-pm/" rel="attachment wp-att-10959"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.48.46-PM-1024x584.jpg" alt="" width="1024" height="584" class="alignnone size-large wp-image-10959" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.48.46-PM-1024x584.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.48.46-PM-300x171.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.48.46-PM-768x438.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.48.46-PM-1536x877.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.48.46-PM-600x342.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-3.48.46-PM.jpg 2022w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Resources for Project</h1>
<p>You can find the completed project in your project creator dialog by filtering for &#8220;IoT Expert Embedded&#8221;.  This is lesson6</p>
<p><a href="https://iotexpert.com/ew21-lesson-1-freertos-capsense/screen-shot-2021-02-22-at-4-34-40-pm/" rel="attachment wp-att-10815"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.34.40-PM-1024x581.png" alt="" width="1024" height="581" class="alignnone size-large wp-image-10815" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.34.40-PM-1024x581.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.34.40-PM-300x170.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.34.40-PM-768x436.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.34.40-PM-1536x872.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.34.40-PM-2048x1163.png 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-22-at-4.34.40-PM-600x341.png 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>You can also clone this project at git@github.com:iotexpert/ew21-lesson6.git or https://github.com/iotexpert/ew21-lesson6</p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/ew21-lesson-6-motor-control/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>EW21: Lesson 7: WS2812 LED Strip</title>
		<link>https://iotexpert.com/ew21-lesson-7-ws2812-led-strip/</link>
					<comments>https://iotexpert.com/ew21-lesson-7-ws2812-led-strip/#comments</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Wed, 24 Feb 2021 15:21:20 +0000</pubDate>
				<category><![CDATA[Embedded World 2021]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=10831</guid>

					<description><![CDATA[Summary In lesson 7 we will finish this Frankenstein drone setup by adding WS2812 Strip LEDs.  At the end of lesson one you will have the &#8220;WS2812 LED&#8221; block colored green.  Here is the architecture: Learning Objectives Have fun by adding another cool library &#8211; WS2812 Procedure Create a new project Add the IoT Expert [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><span><h1>Embedded World 2021 - Infineon ModusToolbox PSoC 6 Drone </h1>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >#</th>
<th >Description</th>
</tr>
</thead>
<tbody>
<tr><td >0</td>
<td ><a href="https://iotexpert.com/ew21-lesson-0-introduction-resources/" target="_blank" rel="noopener">Introduction &amp; Resources</a></td>
</tr>

<tr><td >1</td>
<td ><a href="https://iotexpert.com/ew21-lesson-1-freertos-capsense/" target="_blank" rel="noopener">FreeRTOS &amp; CapSense</a></td>
</tr>

<tr><td >2</td>
<td ><a href="https://iotexpert.com/ew21-lesson-2-joystick/" target="_blank" rel="noopener">3-D Magnetic Sensing XENSIV Joystick</a></td>
</tr>

<tr><td >3</td>
<td ><a href="https://iotexpert.com/ew21-lesson-3-wifi/" target="_blank" rel="noopener">WiFi</a></td>
</tr>

<tr><td >4</td>
<td ><a href="https://iotexpert.com/ew21-lesson-4-mqtt/" target="_blank" rel="noopener">MQTT</a></td>
</tr>

<tr><td >5</td>
<td ><a href="https://iotexpert.com/ew21-lesson-5-low-power/" target="_blank" rel="noopener">Low Power</a></td>
</tr>

<tr><td >6</td>
<td ><a href="https://iotexpert.com/ew21-lesson-6-motor-control/" target="_blank" rel="noopener">BLDC Motor Control</a></td>
</tr>

<tr><td >7</td>
<td ><a href="https://iotexpert.com/ew21-lesson-7-ws2812-led-strip/" target="_blank" rel="noopener">WS2812 Strip LEDs</a></td>
</tr>
</tbody></table></div></p>
<p>&nbsp;</p></span></p>
<h1>Summary</h1>
<p>In lesson 7 we will finish this Frankenstein drone setup by adding WS2812 Strip LEDs.  At the end of lesson one you will have the &#8220;WS2812 LED&#8221; block colored green.  Here is the architecture:</p>
<p><a href="https://iotexpert.com/ew21-lesson-7-ws2812-led-strip/l7-arch/" rel="attachment wp-att-11046"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/l7-arch-1024x433.png" alt="" width="1024" height="433" class="alignnone size-large wp-image-11046" srcset="https://iotexpert.com/wp-content/uploads/2021/02/l7-arch-1024x433.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/l7-arch-300x127.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/l7-arch-768x324.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/l7-arch-1536x649.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/l7-arch-600x253.png 600w, https://iotexpert.com/wp-content/uploads/2021/02/l7-arch.png 1631w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Learning Objectives</h1>
<ol>
<li>Have fun by adding another cool library &#8211; WS2812</li>
</ol>
<h1>Procedure</h1>
<ol>
<li>Create a new project</li>
<li>Add the IoT Expert WS2812 Library</li>
<li>Modify motor_task.c</li>
<li>Test</li>
</ol>
<h3>1. Create a new project</h3>
<p>Start from the CY8CKIT-062S2-43012</p>
<p><a href="https://iotexpert.com/ew21-lesson-7-ws2812-led-strip/screen-shot-2021-02-23-at-6-01-36-pm/" rel="attachment wp-att-10992"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.01.36-PM-1024x708.jpg" alt="" width="1024" height="708" class="alignnone size-large wp-image-10992" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.01.36-PM-1024x708.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.01.36-PM-300x207.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.01.36-PM-768x531.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.01.36-PM-1536x1062.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.01.36-PM-2048x1416.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.01.36-PM-600x415.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Give the project a sensible name.  In this case IoT_Expert_Embedded_World_2021_Lesson7</p>
<p><a href="https://iotexpert.com/ew21-lesson-7-ws2812-led-strip/screen-shot-2021-02-23-at-6-02-10-pm/" rel="attachment wp-att-10990"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.02.10-PM-1024x711.jpg" alt="" width="1024" height="711" class="alignnone size-large wp-image-10990" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.02.10-PM-1024x711.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.02.10-PM-300x208.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.02.10-PM-768x533.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.02.10-PM-1536x1066.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.02.10-PM-2048x1422.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.02.10-PM-600x417.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h3>2. Add the IoT Expert WS2812 Library</h3>
<p>You need to find the IoT Expert WS2812 library and include it into your project.</p>
<p><a href="https://iotexpert.com/ew21-lesson-7-ws2812-led-strip/screen-shot-2021-02-23-at-6-03-31-pm/" rel="attachment wp-att-10991"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.03.31-PM-937x1024.jpg" alt="" width="937" height="1024" class="alignnone size-large wp-image-10991" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.03.31-PM-937x1024.jpg 937w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.03.31-PM-275x300.jpg 275w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.03.31-PM-768x839.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.03.31-PM-600x656.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.03.31-PM.jpg 1142w" sizes="auto, (max-width: 937px) 100vw, 937px" /></a></p>
<h3>3. Modify motor_task.c</h3>
<p>Include the header file for the library.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#include "ws2812.h"</pre>
<p>The number of LEDs in our system</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#define		NUM_LEDS				(61)</pre>
<p>Define some colors to use and initialize the LED strip</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">/* LED color array - 7 different colors each with RGB values */
uint8_t ledColors[7][3] = {
        { 0,  0,  0},	// Off
        {20,  0, 30},	// Violet
        { 0,  0, 50},	// Blue
        { 0, 50,  0},	// Green
        {30, 20,  0},	// Yellow
        {42,  8,  0},	// Orange
        {50,  0,  0},	// Red
};

 uint8_t ledColorRow = 0;
 uint8_t ledColorRowPrev = 0;
/* Initialize LED strips */
ws2812_init(NUM_LEDS, P10_0, P10_1, P10_2);
</pre>
<p>A bit of code to send updates to the LED strip based on the status of the motor.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">/* Calculate LED color and update if it has changed */
            if(motorState == false)
            {
                /* Turn off LEDs */
                ws2812_setMultiRGB(0, NUM_LEDS-1, 0, 0, 0);
                ws2812_update();
                ledColorRowPrev = 0;
            }
            else
            {
                ledColorRow = 1 + (uint8_t)((( (uint16_t)motorSpeed - (uint16_t)RPM_MIN ) * 5) / ((uint16_t)RPM_MAX - (uint16_t)RPM_MIN)); /* Determine row to use */
                if(ledColorRowPrev != ledColorRow)
                {
                    ws2812_setMultiRGB(0, NUM_LEDS-1, ledColors[ledColorRow][0], ledColors[ledColorRow][1], ledColors[ledColorRow][2]);
                    ws2812_update();
                    ledColorRowPrev = ledColorRow;
                }
            }</pre>
<h3>4. Test</h3>
<p>Let it rip tater chip</p>
<p><a href="https://iotexpert.com/ew21-lesson-7-ws2812-led-strip/img_0492/" rel="attachment wp-att-10995"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0492-1024x674.jpg" alt="" width="1024" height="674" class="alignnone size-large wp-image-10995" srcset="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0492-1024x674.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0492-300x198.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0492-768x506.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0492-1536x1012.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0492-600x395.jpg 600w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0492.jpg 1998w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Here it is with the LED strips on&#8230;</p>
<p><a href="https://iotexpert.com/ew21-lesson-7-ws2812-led-strip/img_0491/" rel="attachment wp-att-10994"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0491-1024x947.jpg" alt="" width="1024" height="947" class="alignnone size-large wp-image-10994" srcset="https://iotexpert.com/wp-content/uploads/2021/02/IMG_0491-1024x947.jpg 1024w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0491-300x277.jpg 300w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0491-768x710.jpg 768w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0491-1536x1420.jpg 1536w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0491-2048x1894.jpg 2048w, https://iotexpert.com/wp-content/uploads/2021/02/IMG_0491-600x555.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Resources for Project</h1>
<p>You can find the completed project in your project creator dialog by filtering for &#8220;IoT Expert Embedded&#8221;.  This is lesson 7</p>
<p><a href="https://iotexpert.com/ew21-lesson-7-ws2812-led-strip/screen-shot-2021-02-23-at-6-23-45-pm/" rel="attachment wp-att-10996"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.23.45-PM-1024x491.png" alt="" width="1024" height="491" class="alignnone size-large wp-image-10996" srcset="https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.23.45-PM-1024x491.png 1024w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.23.45-PM-300x144.png 300w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.23.45-PM-768x369.png 768w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.23.45-PM-1536x737.png 1536w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.23.45-PM-2048x983.png 2048w, https://iotexpert.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-23-at-6.23.45-PM-600x288.png 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>You can also clone this project at git@github.com:iotexpert/ew21-lesson2.git or https://github.com/iotexpert/ew21-lesson2</p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/ew21-lesson-7-ws2812-led-strip/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Beer Smith Water Volume Calculator</title>
		<link>https://iotexpert.com/beer-smith-water-volume-calculator/</link>
					<comments>https://iotexpert.com/beer-smith-water-volume-calculator/#comments</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Sat, 19 Dec 2020 14:58:32 +0000</pubDate>
				<category><![CDATA[Beer]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=10529</guid>

					<description><![CDATA[Summary A discussion of the algorithms to calculate water volume in Beer Smith 3.0 including a spreadsheet showing the calculations.  What does this have to do with IoT?  Nothing. Story I am a new brewer. I started at the beginning of COVID in March 2020.  At this point I have only done 26 batches so [&#8230;]]]></description>
										<content:encoded><![CDATA[<h1>Summary</h1>
<p>A discussion of the algorithms to calculate water volume in Beer Smith 3.0 including a spreadsheet showing the calculations.  What does this have to do with IoT?  Nothing.</p>
<h1>Story</h1>
<p>I am a new brewer. I started at the beginning of COVID in March 2020.  At this point I have only done 26 batches so I am a long way from expert.  For sure there is no danger of BrewExpert.com from me any time soon.  But, I am also an engineer so I like to &#8220;know&#8221; (and if there are any IoT Expert people still reading, you will already know that)</p>
<p>I have been struggling to understand how much strike and sparge water to use during the making process. I own and use a <a href="https://shop.grainfather.com/grainfather-connect.html" target="_blank" rel="noopener noreferrer">Grainfather</a>, so I have been using their software, but honestly Im not a huge fan.  Nathan at <a href="https://www.brewerdude.com" target="_blank" rel="noopener noreferrer">BrewerDude</a>, my local home brew store, told me that using Beer Smith was the best way to improve my results.  And, as you know figuring things out is more than half the fun for me.  Game on.</p>
<p><a href="http://beersmith.com" target="_blank" rel="noopener noreferrer">Beer Smith 3.0</a> is a interesting piece of software written by Brad Smith that was made to design and help you implement beer recipes.  The software was clearly built with years of &#8220;experience&#8221; in making beer and is also clearly a reflection of his workflow.  The tool is seems to have a substantial amount of empirical knowledge built into the tool &#8211; Ohm&#8217;s laws for beer?</p>
<p>Now to the problem.  I started trying to reconcile the water volume information coming out of Beer Smith with what was coming out of the Grainfather software.  The numbers didn&#8217;t really add up and there were a bunch of things which I didn&#8217;t really know. Google here we come. Turns out there are a boatload hits that are some variant of &#8220;how do I match what the Grainfather and BeerSmith think for water volumes&#8221;.  I am sure that there is a beautiful document in the Beer Smith documentation library which I haven&#8217;t found which explains the answer to the question of how the water volumes are calculated in Beer Smith, but I couldn&#8217;t find it.</p>
<p>So I decided to reverse engineer the calculations, which I mostly have done (with a few issues).  They are all in a spreadsheet which you can download from the IoT Expert Github respository which you can find at <a href="https://github.com/iotexpert/Beer.git" target="_blank" rel="noopener noreferrer">https://github.com/iotexpert/Beer.git</a> That repository contains a spreadsheet called &#8220;beer-smith-water.xlsx&#8221; which has my version of the formulas which seem to match BeerSmith 3.1.08</p>
<p>I am quite sure that this water volume issue is obvious to everyone, except me.  But, as I said, I&#8217;m only 26 batches into this brewing adventure.  For the rest of this article I will focus only on the parameters that impact water volume in Beer Smith.</p>
<p>First I will walk through the screens that impact water then I will show the &#8220;Vols&#8221; tab and my spreadsheet which mimics the calculations.</p>
<h1>Getting Started</h1>
<p>I will use the recipe &#8220;<a href="https://www.brewerdude.com/abbey-of-the-blonds.html" target="_blank" rel="noopener noreferrer">Abbey of the Blonds</a>&#8221; from BrewerDude and my setup which is a Grainfather G30 and a Grainfather Conical Fermenter.  Here is a picture of the front cover of the book that came with the recipe.  Notice my handwritten notes that are the strike and sparge water&#8230; in both metric and imperial&#8230; and my note that the water values that I used to get a good result.</p>
<p><a href="https://iotexpert.com/beer-smith-water-volume-calculator/img_0355/" rel="attachment wp-att-10543"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2020/12/IMG_0355-709x1024.jpg" alt="" width="709" height="1024" class="alignnone size-large wp-image-10543" srcset="https://iotexpert.com/wp-content/uploads/2020/12/IMG_0355-709x1024.jpg 709w, https://iotexpert.com/wp-content/uploads/2020/12/IMG_0355-208x300.jpg 208w, https://iotexpert.com/wp-content/uploads/2020/12/IMG_0355-768x1110.jpg 768w, https://iotexpert.com/wp-content/uploads/2020/12/IMG_0355-1063x1536.jpg 1063w, https://iotexpert.com/wp-content/uploads/2020/12/IMG_0355-1417x2048.jpg 1417w, https://iotexpert.com/wp-content/uploads/2020/12/IMG_0355-600x867.jpg 600w, https://iotexpert.com/wp-content/uploads/2020/12/IMG_0355-scaled.jpg 1772w" sizes="auto, (max-width: 709px) 100vw, 709px" /></a></p>
<p>Before you can really look at the water volume numbers you need to do several things:</p>
<ol>
<li>Enter the recipe (which I copied from the nice document that came from BrewerDude along with the kit)</li>
<li>Add your equipment (in the picture you can see that I added Grainfather G30 110V ARH).  &#8220;ARH&#8221; are my initials and is my copy of the default configuration.</li>
<li>Add your mash profile (in the picture you can see that I picked Single Infusion Medium Body, Batch Sparge)</li>
<li>Set the boil time to 90 minutes (which over-rides the default of this equipment of 60 minutes)</li>
<li>Notice the Batch Size of 5.5 gallons (which was copied from the equipment profile)</li>
</ol>
<p>In the picture you can see that I changed the fields in the middle right to display the three water volume numbers that I am interested in, specifically:</p>
<ul>
<li>Tot Mash Water</li>
<li>Sparge Water</li>
<li>Total Volume</li>
</ul>
<p>I do not believe that BH Efficiency impacts the water volume calculations.</p>
<p><a href="https://iotexpert.com/beer-smith-water-volume-calculator/screen-shot-2020-12-18-at-1-43-54-pm/" rel="attachment wp-att-10532"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-1.43.54-PM-1024x721.jpg" alt="" width="1024" height="721" class="alignnone size-large wp-image-10532" srcset="https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-1.43.54-PM-1024x721.jpg 1024w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-1.43.54-PM-300x211.jpg 300w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-1.43.54-PM-768x541.jpg 768w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-1.43.54-PM-1536x1082.jpg 1536w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-1.43.54-PM-2048x1442.jpg 2048w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-1.43.54-PM-600x422.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Batch Size &amp; A GUI Comment</h1>
<p>The starting value for Batch Size is <span style="color: #ff0000;"><strong>copied</strong></span> from Equipment Setup configuration.  This number was intensely confusing to me for a good while until I got it sorted out that this is the total volume of cold wort going into the fermenter after the mash and boil.  One thing that you should watch for is that this value is linked onto multiple menus/screens and a change in one place will effectively change it multiple places.  When you change this value it appears to propagate throughout your recipe but it does not change the original source equipment profile.</p>
<h1>Equipment Setup</h1>
<p>As I stated above, when you create the recipe you effectively COPY the equipment profile into your recipe.  In other words the values in this tab become the default values for your recipe when you configure this equipment profile to be used for your recipe.</p>
<p>In the equipment profile the following values impact water:</p>
<ul>
<li>Batch Volume &#8211; How much wort you want to go into the fermenter</li>
<li>Fermenter Loss &#8211; Dead space at bottom of the fermenter i.e. below the line where you bottle from</li>
<li>Mash Tun Volume &#8211; Used as a check to make sure you don&#8217;t overflow during the mash.  This doesn&#8217;t change the calculations, just a warning.</li>
<li><del>Mash Tun Weight</del> &#8211; No impact on water? (pretty sure)</li>
<li><del>Mash Tun Specific Heat</del> &#8211; No impact on water? (pretty sure)</li>
<li>Boil Time &#8211; The default length of time to boil.  This is copied into your reciepe.  This parameter is used in the boil off calculation</li>
<li>Boil Off &#8211; The input variable to the total boil off calculation</li>
<li>Use boil as an hourly rate (if you click this boil off will vary with the boil time)</li>
<li>Total Boil Off: Calculated boil off = Batch Size * boil time / 60 * Boil Off</li>
<li>Recoverable Mash Deadspace &#8211; volume of water below the false bottom which WILL be part of the final wort</li>
<li>Mash Deadspace Losses &#8211; the volume of water below the false bottom which willl be LOST and not part of the final wort</li>
<li>Top Up Water for Kettle: How much water you add pre-boil</li>
<li>Post Boil Vol: This is a calculated estimate based on the input parameters (more details later)</li>
<li>Cooling Shrinkage: how much volume you loose as the wort cools</li>
<li>Loss to Trub and Chiller &#8211; what it says</li>
<li>Top Up Water &#8211; How much water you add into the fermenter</li>
</ul>
<p>You will find that most of these values are copied onto the &#8220;Vols&#8221; screen later on.</p>
<p><a href="https://iotexpert.com/beer-smith-water-volume-calculator/screen-shot-2020-12-18-at-1-57-25-pm/" rel="attachment wp-att-10533"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-1.57.25-PM-1024x900.jpg" alt="" width="1024" height="900" class="alignnone size-large wp-image-10533" srcset="https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-1.57.25-PM-1024x900.jpg 1024w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-1.57.25-PM-300x264.jpg 300w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-1.57.25-PM-768x675.jpg 768w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-1.57.25-PM-1536x1350.jpg 1536w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-1.57.25-PM-600x528.jpg 600w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-1.57.25-PM.jpg 1838w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Mash Profile</h1>
<p>When you choose the mash profile it is the major input to the strike water calculations.</p>
<p>On the Mash screen the parameters:</p>
<ol>
<li>Grain Weight Basis &#8211; used for the calculation of strike water (derived from your inputs on the recipe)</li>
<li>Mash In &#8211; will take you to the next screen where the strike water is calculated</li>
</ol>
<p>I was lost trying to figure out where the strike water came from for quite a while until I realized that you could change the values on the &#8220;Mash In&#8221; step screen.  To do this click on it and press &#8220;Edit Step&#8221; (where the water volume action happens).  Really what is happening here is that you can create multiple steps in your mash process.  Each step can/will impact the water used by that step.  When you configure your reciepe to use a mash profile, you are essentially copying those steps into your recipe and they drive the values for strike water in your recipe.</p>
<p>As I work to write this article I notice for the first time &#8220;Batch Sparge using batches that fill 90%&#8221; but I have no idea what that impacts.</p>
<p><a href="https://iotexpert.com/beer-smith-water-volume-calculator/screen-shot-2020-12-18-at-2-00-44-pm/" rel="attachment wp-att-10535"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-2.00.44-PM-803x1024.png" alt="" width="803" height="1024" class="alignnone size-large wp-image-10535" srcset="https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-2.00.44-PM-803x1024.png 803w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-2.00.44-PM-235x300.png 235w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-2.00.44-PM-768x980.png 768w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-2.00.44-PM-600x766.png 600w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-2.00.44-PM.png 1196w" sizes="auto, (max-width: 803px) 100vw, 803px" /></a></p>
<p>The Mash Step screen calculates the mash water for this step.  The key metric is the Water/Grain Ratio which is used to calculate the &#8220;Water to add&#8221;.  Where did the 1.250 qt/lb come from?  I suspect that this is empirical.  Notice that the water to add does NOT include the Mash Tun Deadspace Addition.  This number was copied from the Equipment profile (which recall was 0.92 gallon = 3.68qt).  Im sure that there was a good reason to add a place to enter this value here, but damn if I can figure it out.  I&#8217;m also sure there was some good reason to change units, but Im also not sure why, but probably convenience.</p>
<p><a href="https://iotexpert.com/beer-smith-water-volume-calculator/screen-shot-2020-12-18-at-2-45-13-pm/" rel="attachment wp-att-10537"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-2.45.13-PM-1024x648.png" alt="" width="1024" height="648" class="alignnone size-large wp-image-10537" srcset="https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-2.45.13-PM-1024x648.png 1024w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-2.45.13-PM-300x190.png 300w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-2.45.13-PM-768x486.png 768w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-2.45.13-PM-600x379.png 600w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-2.45.13-PM.png 1072w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>The Advanced Options</h1>
<p>The advanced options screen (which can be accessed from the preferences button) has two numbers which are relevant to the water calculations</p>
<ol>
<li>Grain Absorption (how much water is absorbed by the grain) = 0.96 Fluid Oz per Oz of Grain</li>
<li>Grain Volume (how much physical space is taken by the wet grain) = 0.6520 l/kg</li>
</ol>
<p>Im quite sure that both of these numbers were arrived at empirically.  These numbers are used in the upcoming &#8220;Vols&#8221; calculations.</p>
<p><a href="https://iotexpert.com/beer-smith-water-volume-calculator/screen-shot-2020-12-18-at-5-20-10-pm/" rel="attachment wp-att-10541"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-5.20.10-PM-1024x787.jpg" alt="" width="1024" height="787" class="alignnone size-large wp-image-10541" srcset="https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-5.20.10-PM-1024x787.jpg 1024w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-5.20.10-PM-300x231.jpg 300w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-5.20.10-PM-768x590.jpg 768w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-5.20.10-PM-1536x1181.jpg 1536w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-5.20.10-PM-600x461.jpg 600w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-18-at-5.20.10-PM.jpg 1642w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>The &#8220;Vols&#8221; Tab</h1>
<p>This tab is where the action happens.  You can see and edit most of what you might want from a water volume point of view.  This screen is broken up into four sections which I will walk through one by one.</p>
<ol>
<li>Water Needed</li>
<li>Mash</li>
<li>Boil and Fermentation</li>
<li>Fermentation/Bottling</li>
</ol>
<p><a href="https://iotexpert.com/beer-smith-water-volume-calculator/screen-shot-2020-12-19-at-7-39-45-am/" rel="attachment wp-att-10546"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.39.45-AM-1024x672.jpg" alt="" width="1024" height="672" class="alignnone size-large wp-image-10546" srcset="https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.39.45-AM-1024x672.jpg 1024w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.39.45-AM-300x197.jpg 300w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.39.45-AM-768x504.jpg 768w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.39.45-AM-1536x1009.jpg 1536w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.39.45-AM-2048x1345.jpg 2048w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.39.45-AM-600x394.jpg 600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>The first thing you should know on the &#8220;Vols&#8221; tab is that the Total Volume = Tot Mash Water + Sparge Vol and is calculated for you.</p>
<p><a href="https://iotexpert.com/beer-smith-water-volume-calculator/screen-shot-2020-12-19-at-7-42-52-am/" rel="attachment wp-att-10547"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.42.52-AM-1024x94.png" alt="" width="1024" height="94" class="alignnone size-large wp-image-10547" srcset="https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.42.52-AM-1024x94.png 1024w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.42.52-AM-300x28.png 300w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.42.52-AM-768x71.png 768w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.42.52-AM-600x55.png 600w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.42.52-AM.png 1326w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>The next section is<strong> Mash</strong></p>
<p>The Mash Grain Wt (weight) comes from your recipe.</p>
<p>Grain Absorption = Mash Grain Wt * Grain Absorption (from the advanced options)</p>
<p>The Tot Mash Water comes from the Mash Profile which you set earlier plus the Mash Tun Addition.  In this specific case it was calculated with</p>
<ul>
<li>10.88 pounds * 1.25 qts/pound * 1 gallon/4 quarts = 3.4 Gallons + 0.92 Gallons = 4.32 Gallons</li>
</ul>
<p>The Tun Deadspace is a parameter for you to enter and is the unrecoverable amount of fluid in the mash tun (things below the pickup in the bottom of the Grainfather)</p>
<p>The Mash Volume Needed = Total Mash Water + Volume of the Wet Grain (which isn&#8217;t shown on this screen but is on my spreadsheet)</p>
<p>The Volume of the Wet Grain = Grain weight * gallons/pound  Remember from the advanced tab which had Grain Volume in litres/pound.  This is how much space is taken up inside of your mash tun for wet grain.</p>
<p>Water Available from the Mash = Total Mash Waster &#8211; Grain Absorption (this is how much wort can move to the next step)</p>
<p>The Sparge Vol comes from a long chain of calculations on the next sections&#8230;</p>
<p><a href="https://iotexpert.com/beer-smith-water-volume-calculator/screen-shot-2020-12-19-at-7-44-09-am/" rel="attachment wp-att-10549"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.44.09-AM-1024x345.png" alt="" width="1024" height="345" class="alignnone size-large wp-image-10549" srcset="https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.44.09-AM-1024x345.png 1024w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.44.09-AM-300x101.png 300w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.44.09-AM-768x259.png 768w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.44.09-AM-600x202.png 600w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.44.09-AM.png 1406w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Here is the section of my spreadsheet which represents these calculations.</p>
<p><a href="https://iotexpert.com/beer-smith-water-volume-calculator/screen-shot-2020-12-19-at-7-50-06-am/" rel="attachment wp-att-10550"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.50.06-AM-1024x281.png" alt="" width="1024" height="281" class="alignnone size-large wp-image-10550" srcset="https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.50.06-AM-1024x281.png 1024w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.50.06-AM-300x82.png 300w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.50.06-AM-768x211.png 768w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.50.06-AM-1536x421.png 1536w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.50.06-AM-600x164.png 600w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.50.06-AM.png 1656w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Now I am going to skip the Boil and Fermentation section and come back because the Fermentation/Bottling section uses data from the this section as an Input.</p>
<p>Top Up Water is how much water you add to the boiled wort as you add it into the Fermenter.  I am not sure why you would do this, perhaps to lower the gravity?</p>
<p>The Batch Size is a parameter that came from the recipe page and is all over this software.  This value is how much wort you are going to put into the fermenter.</p>
<p>The bottling/fermentation loss is how much you loose at the bottom of your fermenter and by taking samples or draining crap during the fermentation process.</p>
<p>I don&#8217;t know what &#8220;Starter Size Used&#8221; is, but I believe that it was put there for a Yeast starter (I have been using Propper Starter).  This would add 32 Ozs (aren&#8217;t the units fun here) or 0.94 of a liter.  On a semi-related note I wonder why they addition of Wort doesn&#8217;t change the gravity enough to add into their calculations &#8230; I suppose adding 16oz at 1.040 isn&#8217;t material.  (late edit: I did the math and adding 16oz of 1.040 to a 5.5 gallon batch of 1.060 lower the gravity by 0.04%)</p>
<p><a href="https://iotexpert.com/beer-smith-water-volume-calculator/screen-shot-2020-12-19-at-7-51-09-am/" rel="attachment wp-att-10552"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.51.09-AM-1024x266.png" alt="" width="1024" height="266" class="alignnone size-large wp-image-10552" srcset="https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.51.09-AM-1024x266.png 1024w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.51.09-AM-300x78.png 300w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.51.09-AM-768x200.png 768w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.51.09-AM-600x156.png 600w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.51.09-AM.png 1532w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Here is the <strong>Fermentation</strong> section from my spreadsheet.  Notice that in the picture there are two yellow fields for you to override the calculations from that step.</p>
<p><a href="https://iotexpert.com/beer-smith-water-volume-calculator/screen-shot-2020-12-19-at-8-00-43-am/" rel="attachment wp-att-10554"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-8.00.43-AM-1024x141.png" alt="" width="1024" height="141" class="alignnone size-large wp-image-10554" srcset="https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-8.00.43-AM-1024x141.png 1024w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-8.00.43-AM-300x41.png 300w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-8.00.43-AM-768x106.png 768w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-8.00.43-AM-1536x212.png 1536w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-8.00.43-AM-600x83.png 600w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-8.00.43-AM.png 1682w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Back to the  &#8220;<strong>Boil and Fermentation</strong>&#8221; section.</p>
<p>Kettle Top Up is how much water you add before you boil after the mash (I have no idea why you would do this)</p>
<p>The best way to think about the rest of this is to</p>
<ol>
<li>Remember that we are trying to back calculate Sparge Water</li>
<li>Start from the bottom and work back to the top</li>
</ol>
<p>Trub loss is what it say it is.  With this you can now calculate a value which isn&#8217;t shown on this screen.  I call that value &#8220;Post Cool Volume&#8221;</p>
<p>Post Cool Volume = Batch Size + Trub Loss &#8211; Kettle Top Up</p>
<p>In order to achieve the &#8220;Post Cool Volume&#8221; you need to increase the work volume by the amount of Cooling Shrinkage.</p>
<p>Pre Cool Volume = Post Boil Volume / (1-Pct Cool Loss)</p>
<p>Cooling Shrinkage = Pre Cool Vol &#8211; Post Cool Volume</p>
<p>I suppose that I was surprised that the number was anything other than 0 as I thought that liquids dont change their volume very much.  Shows what an electrical engineer knows eh.</p>
<p>Est Pre-Boil Vol = Pre Cool Volume / ( 1 &#8211; (Evaporation Rate * Boil Time / 60 Minutes))</p>
<p>With that you can now calculate Boil Off = Pre  boil &#8211; Post Boil</p>
<p>Finally Sparge Volume = Est Pre Boil &#8211; Kettle Top Up + Grain Absorption + Tun Deadspace &#8211; Tot Mash Water</p>
<p><a href="https://iotexpert.com/beer-smith-water-volume-calculator/screen-shot-2020-12-19-at-7-51-03-am/" rel="attachment wp-att-10551"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.51.03-AM-1024x297.png" alt="" width="1024" height="297" class="alignnone size-large wp-image-10551" srcset="https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.51.03-AM-1024x297.png 1024w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.51.03-AM-300x87.png 300w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.51.03-AM-768x223.png 768w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.51.03-AM-600x174.png 600w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-7.51.03-AM.png 1378w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Here is my spreadsheet:</p>
<p><a href="https://iotexpert.com/beer-smith-water-volume-calculator/screen-shot-2020-12-19-at-7-51-09-am/" rel="attachment wp-att-10552"></a><a href="https://iotexpert.com/?attachment_id=10555" rel="attachment wp-att-10555"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-9.06.05-AM-1024x203.png" alt="" width="1024" height="203" class="alignnone size-large wp-image-10555" srcset="https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-9.06.05-AM-1024x203.png 1024w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-9.06.05-AM-300x59.png 300w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-9.06.05-AM-768x152.png 768w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-9.06.05-AM-1536x305.png 1536w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-9.06.05-AM-600x119.png 600w, https://iotexpert.com/wp-content/uploads/2020/12/Screen-Shot-2020-12-19-at-9.06.05-AM.png 1674w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Final Thoughts</h1>
<p>I have not answered (at least) the following questions</p>
<ol>
<li>Where did the Grainfather numbers come from?</li>
<li>Given (1) why is there a difference between Beer Smith and Grainfather</li>
<li>What other calculators are out there?</li>
<li>What is &#8220;Batch Sparge Using Batches that fill %&#8221; used for?</li>
</ol>
<p>I am pretty sure that the right thing for me to do next is to design a set of experiments that will arrive at the configuration parameters that best match my setup.  I think that it would be useful to describe this procedure.</p>
<p>There may very well be an error in here.  In fact I would say with certainty that I made some error.  If you have made it this far and you spotted the error I would very much like to know what it is so that I can fix it.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/beer-smith-water-volume-calculator/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Kentucky Inspired Me &#8230; Thanks Erich</title>
		<link>https://iotexpert.com/kentucky-inspired-me-thanks-erich/</link>
					<comments>https://iotexpert.com/kentucky-inspired-me-thanks-erich/#comments</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Wed, 07 Oct 2020 12:00:48 +0000</pubDate>
				<category><![CDATA[Misc]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=9899</guid>

					<description><![CDATA[I follow Erich&#8217;s blog.  In the last few years he has been posting pictures taken near his home in Switzerland.  Remarkable. In the last few days Kentucky has inspired to take some fall pictures.  I will not pretend they are great works of photography.  But I think that they are pretty. How are they IoT?  They [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>I follow Erich&#8217;s <a href="https://mcuoneclipse.com/2020/08/08/arnisee-and-sunniggrat/" target="_blank" rel="noopener noreferrer">blog</a>.  In the last few years he has been posting pictures taken near his home in Switzerland.  Remarkable.</p>
<p>In the last few days Kentucky has inspired to take some fall pictures.  I will not pretend they are great works of photography.  But I think that they are pretty.</p>
<p>How are they IoT?  They aren&#8217;t.</p>
<p><a href="https://iotexpert.com/kentucky-inspired-me-thanks-erich/img_0146/"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2020/10/IMG_0146-1024x768.jpeg" alt="" class="alignnone wp-image-10709 size-large" width="1024" height="768" srcset="https://iotexpert.com/wp-content/uploads/2020/10/IMG_0146-1024x768.jpeg 1024w, https://iotexpert.com/wp-content/uploads/2020/10/IMG_0146-300x225.jpeg 300w, https://iotexpert.com/wp-content/uploads/2020/10/IMG_0146-768x576.jpeg 768w, https://iotexpert.com/wp-content/uploads/2020/10/IMG_0146-1536x1152.jpeg 1536w, https://iotexpert.com/wp-content/uploads/2020/10/IMG_0146-2048x1536.jpeg 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a><br />
<a href="https://iotexpert.com/kentucky-inspired-me-thanks-erich/img_0161/"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2020/10/IMG_0161-1024x768.jpeg" alt="" class="alignnone wp-image-10710 size-large" width="1024" height="768" srcset="https://iotexpert.com/wp-content/uploads/2020/10/IMG_0161-1024x768.jpeg 1024w, https://iotexpert.com/wp-content/uploads/2020/10/IMG_0161-300x225.jpeg 300w, https://iotexpert.com/wp-content/uploads/2020/10/IMG_0161-768x576.jpeg 768w, https://iotexpert.com/wp-content/uploads/2020/10/IMG_0161-1536x1152.jpeg 1536w, https://iotexpert.com/wp-content/uploads/2020/10/IMG_0161-2048x1536.jpeg 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/kentucky-inspired-me-thanks-erich/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>The Wires Are Out Of Control</title>
		<link>https://iotexpert.com/the-wires-are-out-of-control/</link>
					<comments>https://iotexpert.com/the-wires-are-out-of-control/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Mon, 28 Sep 2020 16:19:08 +0000</pubDate>
				<category><![CDATA[Misc]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=9847</guid>

					<description><![CDATA[You have to start by admitting you have a problem OK, it looks like I&#8217;m on the right track. But, that made things worse in other ways. Really? Let&#8217;s make some progress on the power. Having a lab assistant is awesome Finally&#8230; You can see: My new work Windows laptop My personal Mac A 4K [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>You have to start by admitting you have a problem</p>
<p><a href="https://iotexpert.com/2020/09/28/the-wires-are-out-of-control/tempimage0edtbs/" rel="attachment wp-att-9856"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2020/09/tempImage0edtBs-1024x768.jpg" alt="" width="1024" height="768" class="alignnone size-large wp-image-9856" /></a></p>
<p>OK, it looks like I&#8217;m on the right track.</p>
<p><a href="https://iotexpert.com/2020/09/28/the-wires-are-out-of-control/img_0112/" rel="attachment wp-att-9848"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2020/09/IMG_0112-scaled-e1600692542165-1024x839.jpg" alt="" width="1024" height="839" class="alignnone wp-image-9848 size-large" /></a></p>
<p>But, that made things worse in other ways.</p>
<p><a href="https://iotexpert.com/2020/09/28/the-wires-are-out-of-control/img_0107/" rel="attachment wp-att-9849"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2020/09/IMG_0107-scaled-e1600692478769-701x1024.jpg" alt="" width="701" height="1024" class="alignnone wp-image-9849 size-large" /></a></p>
<p>Really?</p>
<p><a href="https://iotexpert.com/2020/09/28/the-wires-are-out-of-control/img_0104/" rel="attachment wp-att-9850"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2020/09/IMG_0104-768x1024.jpg" alt="" width="768" height="1024" class="alignnone size-large wp-image-9850" /></a></p>
<p>Let&#8217;s make some progress on the power.</p>
<p><a href="https://iotexpert.com/2020/09/28/the-wires-are-out-of-control/img_0114-2/" rel="attachment wp-att-9851"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2020/09/IMG_0114-768x1024.jpg" alt="" width="768" height="1024" class="alignnone size-large wp-image-9851" /></a></p>
<p>Having a lab assistant is awesome</p>
<p><a href="https://iotexpert.com/2020/09/28/the-wires-are-out-of-control/img_0116/" rel="attachment wp-att-9852"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2020/09/IMG_0116-1024x768.jpg" alt="" width="1024" height="768" class="alignnone size-large wp-image-9852" /></a></p>
<p>Finally&#8230;</p>
<p><a href="https://iotexpert.com/2020/09/28/the-wires-are-out-of-control/img_0157/" rel="attachment wp-att-9865"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2020/09/IMG_0157-1024x636.jpg" alt="" width="1024" height="636" class="alignnone size-large wp-image-9865" /></a></p>
<p>You can see:</p>
<ol>
<li>My new work Windows laptop</li>
<li>My personal Mac</li>
<li>A 4K display that is switched with a KVM under the desk</li>
<li>The Jetson Nano that I am currently working on</li>
<li>The Thunderbolt hub connected to my Mac</li>
<li>A beautiful antique magnifying glass</li>
<li>A Weller soldering iron</li>
<li>An amazing Leica microscope</li>
<li>My Linux box (under the desk).  It is attached via display port to the monitor &#8211; but it is mostly logged into via the network</li>
<li>A paper protractor that my daughter made when she was little</li>
<li>A paper Go Dad flag made by my daughter when she was little</li>
<li>UK (BSEE) &amp; Georgia Tech (MSEE) Diplomas</li>
<li>Part of my photojournalism portfolio</li>
<li> My new work phone on the wireless charger</li>
<li>A pack of post-it-notes</li>
<li>A paper tracing of my Katana done with the NBTHK Hozon</li>
</ol>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/the-wires-are-out-of-control/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Mouser PSoC 6 WiFi/BT MBED: L1 Developer Resources</title>
		<link>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l1-developer-resources/</link>
					<comments>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l1-developer-resources/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Mon, 09 Dec 2019 17:05:36 +0000</pubDate>
				<category><![CDATA[Mouser PSoC 6 WiFi/BT MBED]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=7994</guid>

					<description><![CDATA[Summary This is an index of links to all of the PSoC 6 MCU, CYW4343W &#38; Mbed OS learning resources.  You can click the links to go the website or see screen captures of the resources. Mbed OS Overview (screen capture only) Mbed OS Landing Page Mbed Studio CY8CPROTO-062-4343W ModusToolbox Software Environment PSoC 6 Product [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><span><h1>IoT Design with Cypress PSoC® 6 MCUs and Wi-Fi/Bluetooth using Arm® Mbed<img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" /></h1>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >#</th>
<th >Lesson</th>
<th >GitHub Project</th>
</tr>
</thead>
<tbody>
<tr><td >0</td>
<td ><a href="https://iotexpert.com/2019/12/08/mouser-psoc-6-wifi-bt-mbed-l0-introduction/" target="_blank" rel="noopener">Introduction</a></td>
<td ></td>
</tr>

<tr><td >1</td>
<td ><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l1-developer-resources/" target="_blank" rel="noopener">Developer Resources</a></td>
<td ></td>
</tr>

<tr><td >2</td>
<td ><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l2-the-blinking-thread/" target="_blank" rel="noopener">Your First Project &amp; The Blinking Thread</a></td>
<td >https://github.com/iotexpert/mouser-mbed-02.git</td>
</tr>

<tr><td >3</td>
<td ><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l3-display-thread/" target="_blank" rel="noopener">Display Thread</a></td>
<td >https://github.com/iotexpert/mouser-mbed-03.git</td>
</tr>

<tr><td >4</td>
<td ><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l4-temperature-thread/" target="_blank" rel="noopener">Temperature Thread</a></td>
<td >https://github.com/iotexpert/mouser-mbed-04.git</td>
</tr>

<tr><td >5</td>
<td ><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l5-capsense-thread/" target="_blank" rel="noopener">CapSense Thread</a></td>
<td >https://github.com/iotexpert/mouser-mbed-05.git</td>
</tr>

<tr><td >6</td>
<td ><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l6-wifi-ntp-thread/" target="_blank" rel="noopener">WiFi &amp; NTP Thread</a></td>
<td >https://github.com/iotexpert/mouser-mbed-06.git</td>
</tr>

<tr><td >7</td>
<td ><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l7-the-cy8ckit-062-wifi-bt/" target="_blank" rel="noopener">The CY8CKIT-062-WiFi-BT</a></td>
<td >https://github.com/iotexpert/mouser-mbed-07.git </td>
</tr>

<tr><td >8</td>
<td ><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l8-amazon-aws-mqtt-thread-part1/" target="_blank" rel="noopener">Amazon AWS MQTT Thread - Part1</a></td>
<td >https://github.com/iotexpert/mouser-mbed-08.git</td>
</tr>

<tr><td >9</td>
<td ><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l9-amazon-aws-mqtt-thread-part2/" target="_blank" rel="noopener">Amazon AWS MQTT Thread - Part2</a></td>
<td >https://github.com/iotexpert/mouser-mbed-09.git</td>
</tr>
</tbody></table></div></p>
<p>You can “mbed import https://github.com/iotexpert/mouser-mbed-09.git“ to make a copy of the project in your workspace.</p>
<p>The final architecture of the thermostat looks like this.</p>
<p><a href="https://iotexpert.com/?attachment_id=8027" rel="attachment wp-att-8027"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/overallarch-1024x651.png" alt="" width="1024" height="651" class="alignnone size-large wp-image-8027" srcset="https://iotexpert.com/wp-content/uploads/2019/12/overallarch-1024x651.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/overallarch-600x381.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/overallarch-300x191.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/overallarch-768x488.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/overallarch.png 1662w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>&nbsp;</p></span></p>
<h1>Summary</h1>
<p>This is an index of links to all of the PSoC 6 MCU, CYW4343W &amp; Mbed OS learning resources.  You can click the links to go the website or see screen captures of the resources.</p>
<ol>
<li>Mbed OS Overview (screen capture only)</li>
<li><a href="https://www.mbed.com/en/" target="_blank" rel="noopener noreferrer">Mbed OS Landing Page</a></li>
<li><a href="https://os.mbed.com/studio/?_ga=2.72442579.1703669375.1575719308-1336169840.1494694869" target="_blank" rel="noopener noreferrer">Mbed Studio</a></li>
<li><a href="https://www.cypress.com/documentation/development-kitsboards/psoc-6-wi-fi-bt-prototyping-kit-cy8cproto-062-4343w" target="_blank" rel="noopener noreferrer">CY8CPROTO-062-4343W</a></li>
<li><a href="https://www.cypress.com/products/modustoolbox-software-environment" target="_blank" rel="noopener noreferrer">ModusToolbox Software Environment</a></li>
<li><a href="http://www.cypress.com/products/32-bit-arm-cortex-m4-psoc-6" target="_blank" rel="noopener noreferrer">PSoC 6 Product Page</a></li>
<li><a href="http://www.cypress.com/products/wi-fi-bluetooth-combos" target="_blank" rel="noopener noreferrer">WiFi + Bluetooth Combo Product Page</a></li>
<li><a href="http://www.cypress.com/products/32-bit-arm-cortex-m4-psoc-6#tabs-0-bottom_side-5" target="_blank" rel="noopener noreferrer">PSoC 6 Documentation</a></li>
<li><a href="https://community.cypress.com/community/psoc-6" target="_blank" rel="noopener noreferrer">PSoC 6 Community</a></li>
<li><a href="https://community.cypress.com/community/wiced-wifi" target="_blank" rel="noopener noreferrer">Wireless Combo Community</a></li>
<li><a href="http://www.cypress.com/documentation/development-kitsboards/psoc-6-wifi-bt-pioneer-kit" target="_blank" rel="noopener noreferrer">CY8CKIT-062-BT-WiFi Development Kit Product Page</a></li>
<li><a href="http://www.cypress.com/file/407731/download" target="_blank" rel="noopener noreferrer">CY8CKIT-062-BT-WiFi Development Kit Guide</a></li>
<li><a href="http://www.cypress.com/file/385916/download" target="_blank" rel="noopener noreferrer">PSoC 6 Datasheet</a></li>
<li><a href="http://www.cypress.com/file/298081/download" target="_blank" rel="noopener noreferrer">CYW4343W Datasheet</a></li>
<li><a href="http://www.cypress.com/file/385621/download" target="_blank" rel="noopener noreferrer">PSoC 6 Technical Reference Manuals</a></li>
<li><a href="http://www.cypress.com/search/all?f[0]=meta_type%3Atechnical_documents&amp;f[1]=resource_meta_type%3A574&amp;f[2]=field_related_products%3A114026" target="_blank" rel="noopener noreferrer">PSoC 6 Application Notes</a></li>
<li><a href="http://www.cypress.com/search/all?sort_by=changed&amp;f%5B0%5D=meta_type%3Atechnical_documents&amp;f%5B1%5D=field_related_products%3A121332&amp;f%5B2%5D=resource_meta_type%3A574" target="_blank" rel="noopener noreferrer">WiFi + Bluetooth Combo Application Notes</a></li>
<li><a href="http://www.cypress.com/documentation/code-examples/psoc-6-mcu-code-examples" target="_blank" rel="noopener noreferrer">PSoC 6 Code Examples</a></li>
<li><a href="http://www.cypress.com/training/free-online-video-training-and-tutorials-cypress" target="_blank" rel="noopener noreferrer">Video Tutorials</a></li>
<li><a href="https://community.cypress.com/community/knowledge-base-articles/content?filterID=contentstatus%5Bpublished%5D~category%5Bpsoc-6%5D" target="_blank" rel="noopener noreferrer">PSoC 6 Knowledge Base</a></li>
<li>Peripheral Driver Library Documentation (Doxygen &#8211; screen capture only)</li>
<li><a href="https://iotexpert.com">IoT Expert Website</a></li>
</ol>
<h1>Mbed OS Overview</h1>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l1-developer-resources/mbedos/" rel="attachment wp-att-8252"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/mbedos.png" alt="" width="974" height="460" class="alignnone size-full wp-image-8252" srcset="https://iotexpert.com/wp-content/uploads/2019/12/mbedos.png 974w, https://iotexpert.com/wp-content/uploads/2019/12/mbedos-600x283.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/mbedos-300x142.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/mbedos-768x363.png 768w" sizes="auto, (max-width: 974px) 100vw, 974px" /></a></p>
<h1>Mbed OS Landing Page</h1>
<p>The link to the Arm Mbed landing page can be found <a href="https://www.mbed.com/en/">here</a>.</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l1-developer-resources/mbed-web/" rel="attachment wp-att-8254"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/mbed-web.png" alt="" width="974" height="452" class="alignnone size-large wp-image-8254" srcset="https://iotexpert.com/wp-content/uploads/2019/12/mbed-web.png 974w, https://iotexpert.com/wp-content/uploads/2019/12/mbed-web-600x278.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/mbed-web-300x139.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/mbed-web-768x356.png 768w" sizes="auto, (max-width: 974px) 100vw, 974px" /></a></p>
<h1>Mbed Studio</h1>
<p>The link to Mbed Studio can be found <a href="https://os.mbed.com/studio/?_ga=2.154651256.1340306692.1575848117-1016667877.1568852374">here</a>.</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l1-developer-resources/mbed-studio/" rel="attachment wp-att-8253"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/mbed-studio.png" alt="" width="974" height="712" class="alignnone size-large wp-image-8253" srcset="https://iotexpert.com/wp-content/uploads/2019/12/mbed-studio.png 974w, https://iotexpert.com/wp-content/uploads/2019/12/mbed-studio-600x439.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/mbed-studio-300x219.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/mbed-studio-768x561.png 768w" sizes="auto, (max-width: 974px) 100vw, 974px" /></a></p>
<h1>CY8CPROTO-062-4343W Landing Page</h1>
<p>The link to the PSoC 6 WiFi-BT Prototyping Kit (CY8CPROTO-062-4343W) can be found <a href="https://www.cypress.com/documentation/development-kitsboards/psoc-6-wi-fi-bt-prototyping-kit-cy8cproto-062-4343w">here</a>.</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l1-developer-resources/screen-shot-2019-12-08-at-7-19-02-pm/" rel="attachment wp-att-8259"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.19.02-PM-1024x1004.png" alt="" width="1024" height="1004" class="alignnone size-large wp-image-8259" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.19.02-PM-1024x1004.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.19.02-PM-600x588.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.19.02-PM-300x294.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.19.02-PM-768x753.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.19.02-PM.png 1918w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>ModusToolbox Software Environment</h1>
<p>The link to the ModusToolbox Software Environment landing page can be found <a href="https://www.cypress.com/products/modustoolbox-software-environment">here</a>.</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l1-developer-resources/screen-shot-2019-12-08-at-7-20-02-pm/" rel="attachment wp-att-8261"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.20.02-PM-1024x884.png" alt="" width="1024" height="884" class="alignnone size-large wp-image-8261" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.20.02-PM-1024x884.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.20.02-PM-600x518.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.20.02-PM-300x259.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.20.02-PM-768x663.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.20.02-PM.png 1900w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>PSoC 6 Product Page</h1>
<p>You can find the PSoC 6 Product landing page for PSoC 6 <a href="http://www.cypress.com/products/32-bit-arm-cortex-m4-psoc-6" target="_blank" rel="noopener noreferrer">here</a></p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-2.57.54-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-2.57.54-PM-1024x870.png" alt="" width="1024" height="870" class="alignnone size-large wp-image-4499" srcset="https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-2.57.54-PM-1024x870.png 1024w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-2.57.54-PM-600x510.png 600w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-2.57.54-PM-300x255.png 300w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-2.57.54-PM-768x652.png 768w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-2.57.54-PM.png 1280w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>WiFi + Bluetooth Combo Page</h1>
<p>You can find the landing page for all Cypress WiFi + Bluetooth combo radios <a href="https://www.cypress.com/products/wi-fi-bluetooth-combos" target="_blank" rel="noopener noreferrer">here</a>.</p>
<p><a href="https://iotexpert.com/2018/10/24/mouser-psoc6-wifi-bt-l1-developers-resources/screen-shot-2018-10-22-at-5-51-59-am/" rel="attachment wp-att-6037"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-5.51.59-AM-1024x783.png" alt="" width="1024" height="783" class="alignnone size-large wp-image-6037" srcset="https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-5.51.59-AM-1024x783.png 1024w, https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-5.51.59-AM-600x459.png 600w, https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-5.51.59-AM-300x229.png 300w, https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-5.51.59-AM-768x587.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>PSoC 6 Documentation</h1>
<p>On the PSoC 6 Product Landing page there is a documentation tab that has <a href="https://www.cypress.com/products/32-bit-arm-cortex-m4-psoc-6#tabs-0-bottom_side-5">links</a> to all of the current documentation.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-3.16.16-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-3.16.16-PM-806x1024.png" alt="" width="806" height="1024" class="alignnone size-large wp-image-4502" srcset="https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-3.16.16-PM-806x1024.png 806w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-3.16.16-PM-600x762.png 600w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-3.16.16-PM-236x300.png 236w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-3.16.16-PM-768x975.png 768w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-3.16.16-PM.png 834w" sizes="auto, (max-width: 806px) 100vw, 806px" /></a></p>
<h1>PSoC 6 Community</h1>
<p>Cypress has an active development community and forum.  It can be found <a href="https://community.cypress.com/community/psoc-6" target="_blank" rel="noopener noreferrer">here</a>.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-2.40.56-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-2.40.56-PM-1024x876.png" alt="" width="1024" height="876" class="alignnone size-large wp-image-4495" srcset="https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-2.40.56-PM-1024x876.png 1024w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-2.40.56-PM-600x514.png 600w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-2.40.56-PM-300x257.png 300w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-2.40.56-PM-768x657.png 768w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-2.40.56-PM.png 1478w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Wireless WiFi + Bluetooth Combo Community</h1>
<p>The forum on the Cypress Developer Community for WiFi + Bluetooth combo radios can be found <a href="https://community.cypress.com/community/wiced-wifi">here</a>.</p>
<p><a href="https://iotexpert.com/2018/10/24/mouser-psoc6-wifi-bt-l1-developers-resources/screen-shot-2018-10-22-at-5-54-42-am/" rel="attachment wp-att-6038"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-5.54.42-AM-1024x585.png" alt="" width="1024" height="585" class="alignnone size-large wp-image-6038" srcset="https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-5.54.42-AM-1024x585.png 1024w, https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-5.54.42-AM-600x343.png 600w, https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-5.54.42-AM-300x171.png 300w, https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-5.54.42-AM-768x438.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>CY8CKIT-062-WiFi-BT Development Kit Web Page</h1>
<p>Every Cypress development kit has a web page that contains all of the information about it, including links to the documentation and store.  The CY8CKIT-062-WiFi-BT kit page is <a href="http://www.cypress.com/documentation/development-kitsboards/psoc-6-wifi-bt-pioneer-kit" target="_blank" rel="noopener noreferrer">here</a>.</p>
<p><a href="https://iotexpert.com/2018/10/24/mouser-psoc6-wifi-bt-l1-developers-resources/screen-shot-2018-10-22-at-5-56-36-am/" rel="attachment wp-att-6039"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-5.56.36-AM-1024x694.png" alt="" width="1024" height="694" class="alignnone size-large wp-image-6039" srcset="https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-5.56.36-AM-1024x694.png 1024w, https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-5.56.36-AM-600x407.png 600w, https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-5.56.36-AM-300x203.png 300w, https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-5.56.36-AM-768x520.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>CY8CKIT-062-WiFi-BT Development Kit Guide</h1>
<p>You can find the development kit guide <a href="http://www.cypress.com/documentation/development-kitsboards/psoc-6-wifi-bt-pioneer-kit" target="_blank" rel="noopener noreferrer">here</a>.</p>
<p><a href="https://iotexpert.com/2018/10/24/mouser-psoc6-wifi-bt-l1-developers-resources/screen-shot-2018-10-22-at-5-58-01-am/" rel="attachment wp-att-6040"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-5.58.01-AM-1024x440.png" alt="" width="1024" height="440" class="alignnone size-large wp-image-6040" srcset="https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-5.58.01-AM-1024x440.png 1024w, https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-5.58.01-AM-600x258.png 600w, https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-5.58.01-AM-300x129.png 300w, https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-5.58.01-AM-768x330.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>PSoC 6 Datasheet</h1>
<p>The PSoC 6 Datasheet is available on Cypress.com <a href="http://www.cypress.com/file/385916/download" target="_blank" rel="noopener noreferrer">here</a>.</p>
<p><a href="https://iotexpert.com/2018/10/24/mouser-psoc6-wifi-bt-l1-developers-resources/screen-shot-2018-10-22-at-6-00-20-am/" rel="attachment wp-att-6041"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-6.00.20-AM-1024x749.png" alt="" width="1024" height="749" class="alignnone size-large wp-image-6041" srcset="https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-6.00.20-AM-1024x749.png 1024w, https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-6.00.20-AM-600x439.png 600w, https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-6.00.20-AM-300x219.png 300w, https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-6.00.20-AM-768x562.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>CYW4343W Datasheet</h1>
<p>The CYW4343W datasheet can be found <a href="http://www.cypress.com/file/298081/download" target="_blank" rel="noopener noreferrer">here</a>.</p>
<p><a href="https://iotexpert.com/2018/10/24/mouser-psoc6-wifi-bt-l1-developers-resources/screen-shot-2018-10-22-at-6-02-12-am/" rel="attachment wp-att-6042"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-6.02.12-AM-1024x662.png" alt="" width="1024" height="662" class="alignnone size-large wp-image-6042" srcset="https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-6.02.12-AM-1024x662.png 1024w, https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-6.02.12-AM-600x388.png 600w, https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-6.02.12-AM-300x194.png 300w, https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-6.02.12-AM-768x497.png 768w, https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-6.02.12-AM.png 1994w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>PSoC 6 Technical Reference Manual</h1>
<p>Each of the PSoC 6 devices has a lengthy discussion of the Technical Resources.  These documents can be found <a href="http://www.cypress.com/file/385621/download" target="_blank" rel="noopener noreferrer">here</a></p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-3.12.57-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-3.12.57-PM-1024x997.png" alt="" width="1024" height="997" class="alignnone size-large wp-image-4501" srcset="https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-3.12.57-PM-1024x997.png 1024w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-3.12.57-PM-600x584.png 600w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-3.12.57-PM-300x292.png 300w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-3.12.57-PM-768x748.png 768w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-3.12.57-PM.png 1105w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>PSoC 6 Application Notes</h1>
<p>You can get them all on our website. Here is a link to the filtered list of <a href="http://www.cypress.com/search/all?f[0]=meta_type%3Atechnical_documents&amp;f[1]=resource_meta_type%3A574&amp;f[2]=field_related_products%3A114026" target="_blank" rel="noopener noreferrer">PSoC 6 Application Notes</a>.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-12.06.05-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-12.06.05-PM-1024x917.png" alt="" width="1024" height="917" class="alignnone size-large wp-image-4459" srcset="https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-12.06.05-PM-1024x917.png 1024w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-12.06.05-PM-600x537.png 600w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-12.06.05-PM-300x269.png 300w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-12.06.05-PM-768x687.png 768w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-12.06.05-PM.png 1363w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>The best application note is always the &#8220;Getting Started&#8221;.  In this case it is <a href="http://www.cypress.com/documentation/application-notes/an210781-getting-started-psoc-6-mcu-bluetooth-low-energy-ble?source=search&amp;cat=technical_documents" target="_blank" rel="noopener noreferrer">AN210781 &#8220;Getting Started with PSoC 6 MCU with Bluetooth Low Energy (BLE) Connectivity&#8221;</a></p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-12.08.11-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-12.08.11-PM-1024x940.png" alt="" width="1024" height="940" class="alignnone size-large wp-image-4460" srcset="https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-12.08.11-PM-1024x940.png 1024w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-12.08.11-PM-600x551.png 600w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-12.08.11-PM-300x276.png 300w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-12.08.11-PM-768x705.png 768w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-12.08.11-PM.png 1421w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>WiFi + Bluetooth Combo Application Notes</h1>
<p>Here is a link to all of the <a href="http://www.cypress.com/search/all?sort_by=changed&amp;f%5B0%5D=meta_type%3Atechnical_documents&amp;f%5B1%5D=field_related_products%3A121332&amp;f%5B2%5D=resource_meta_type%3A574" target="_blank" rel="noopener noreferrer">WiFI Bluetooth Combo Application</a> Notes.</p>
<p><a href="https://iotexpert.com/2018/10/24/mouser-psoc6-wifi-bt-l1-developers-resources/screen-shot-2018-10-22-at-9-20-58-am/" rel="attachment wp-att-6045"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-9.20.58-AM-1024x784.png" alt="" width="1024" height="784" class="alignnone size-large wp-image-6045" srcset="https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-9.20.58-AM-1024x784.png 1024w, https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-9.20.58-AM-600x460.png 600w, https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-9.20.58-AM-300x230.png 300w, https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-9.20.58-AM-768x588.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Video Tutorials</h1>
<p>Cypress has made a bunch of videos that take you step by step through an introduction to PSoC 6.  You can find them on the Cypress <a href="https://www.cypress.com/training/psoc-101-video-tutorial-series-how-use-arm-cortex-m4-based-psoc-6">training website</a>.</p>
<p><a href="https://iotexpert.com/2018/10/24/mouser-psoc6-wifi-bt-l1-developers-resources/screen-shot-2018-10-22-at-9-24-27-am/" rel="attachment wp-att-6046"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-9.24.27-AM-1024x735.png" alt="" width="1024" height="735" class="alignnone size-large wp-image-6046" srcset="https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-9.24.27-AM-1024x735.png 1024w, https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-9.24.27-AM-600x431.png 600w, https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-9.24.27-AM-300x215.png 300w, https://iotexpert.com/wp-content/uploads/2018/10/Screen-Shot-2018-10-22-at-9.24.27-AM-768x551.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>PSoC 6 Knowledge Base</h1>
<p>The Cypress technical support team writes &#8220;Knowledge Base&#8221; articles when there are repeated issues reported by customers.  You can find them <a href="https://community.cypress.com/community/knowledge-base-articles/content?filterID=contentstatus%5Bpublished%5D~category%5Bpsoc-6%5D" target="_blank" rel="noopener noreferrer">here</a>.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-3.50.02-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-3.50.02-PM-1024x819.png" alt="" width="1024" height="819" class="alignnone size-large wp-image-4505" srcset="https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-3.50.02-PM-1024x819.png 1024w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-3.50.02-PM-600x480.png 600w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-3.50.02-PM-300x240.png 300w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-3.50.02-PM-768x614.png 768w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-03-at-3.50.02-PM.png 1252w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a><a href="https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-06-at-3.52.32-PM.png"></a></p>
<h1>Peripheral Driver Library Documentation (Doxygen)</h1>
<p>All of the APIs in the PDL are documented in a Doxygen generated HTML document.  You can get there from</p>
<ul>
<li>Help -&gt; Peripheral Driver Library (this link is live only when you have a PSoC 6 project open)</li>
<li>Right click on a component -&gt; Open PDL Documentation</li>
</ul>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-06-at-4.01.06-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-06-at-4.01.06-PM-1024x580.png" alt="" width="1024" height="580" class="alignnone size-large wp-image-4619" srcset="https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-06-at-4.01.06-PM-1024x580.png 1024w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-06-at-4.01.06-PM-600x340.png 600w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-06-at-4.01.06-PM-300x170.png 300w, https://iotexpert.com/wp-content/uploads/2017/11/Screen-Shot-2017-11-06-at-4.01.06-PM-768x435.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l1-developer-resources/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Mouser PSoC 6 WiFi/BT MBED: L2 The Blinking Thread</title>
		<link>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l2-the-blinking-thread/</link>
					<comments>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l2-the-blinking-thread/#comments</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Mon, 09 Dec 2019 17:05:15 +0000</pubDate>
				<category><![CDATA[Mouser PSoC 6 WiFi/BT MBED]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=7996</guid>

					<description><![CDATA[Summary Here we are again. The blinking LED.  I always start with a basic Blinking LED project just to make sure that everything is working.  What is everything?  The whole tool flow, from the editor, to the programmer, to the chip to the SDK.  The only thing that will be a little different than usual [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><span><h1>IoT Design with Cypress PSoC® 6 MCUs and Wi-Fi/Bluetooth using Arm® Mbed<img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" /></h1>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >#</th>
<th >Lesson</th>
<th >GitHub Project</th>
</tr>
</thead>
<tbody>
<tr><td >0</td>
<td ><a href="https://iotexpert.com/2019/12/08/mouser-psoc-6-wifi-bt-mbed-l0-introduction/" target="_blank" rel="noopener">Introduction</a></td>
<td ></td>
</tr>

<tr><td >1</td>
<td ><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l1-developer-resources/" target="_blank" rel="noopener">Developer Resources</a></td>
<td ></td>
</tr>

<tr><td >2</td>
<td ><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l2-the-blinking-thread/" target="_blank" rel="noopener">Your First Project &amp; The Blinking Thread</a></td>
<td >https://github.com/iotexpert/mouser-mbed-02.git</td>
</tr>

<tr><td >3</td>
<td ><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l3-display-thread/" target="_blank" rel="noopener">Display Thread</a></td>
<td >https://github.com/iotexpert/mouser-mbed-03.git</td>
</tr>

<tr><td >4</td>
<td ><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l4-temperature-thread/" target="_blank" rel="noopener">Temperature Thread</a></td>
<td >https://github.com/iotexpert/mouser-mbed-04.git</td>
</tr>

<tr><td >5</td>
<td ><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l5-capsense-thread/" target="_blank" rel="noopener">CapSense Thread</a></td>
<td >https://github.com/iotexpert/mouser-mbed-05.git</td>
</tr>

<tr><td >6</td>
<td ><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l6-wifi-ntp-thread/" target="_blank" rel="noopener">WiFi &amp; NTP Thread</a></td>
<td >https://github.com/iotexpert/mouser-mbed-06.git</td>
</tr>

<tr><td >7</td>
<td ><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l7-the-cy8ckit-062-wifi-bt/" target="_blank" rel="noopener">The CY8CKIT-062-WiFi-BT</a></td>
<td >https://github.com/iotexpert/mouser-mbed-07.git </td>
</tr>

<tr><td >8</td>
<td ><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l8-amazon-aws-mqtt-thread-part1/" target="_blank" rel="noopener">Amazon AWS MQTT Thread - Part1</a></td>
<td >https://github.com/iotexpert/mouser-mbed-08.git</td>
</tr>

<tr><td >9</td>
<td ><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l9-amazon-aws-mqtt-thread-part2/" target="_blank" rel="noopener">Amazon AWS MQTT Thread - Part2</a></td>
<td >https://github.com/iotexpert/mouser-mbed-09.git</td>
</tr>
</tbody></table></div></p>
<p>You can “mbed import https://github.com/iotexpert/mouser-mbed-09.git“ to make a copy of the project in your workspace.</p>
<p>The final architecture of the thermostat looks like this.</p>
<p><a href="https://iotexpert.com/?attachment_id=8027" rel="attachment wp-att-8027"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/overallarch-1024x651.png" alt="" width="1024" height="651" class="alignnone size-large wp-image-8027" srcset="https://iotexpert.com/wp-content/uploads/2019/12/overallarch-1024x651.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/overallarch-600x381.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/overallarch-300x191.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/overallarch-768x488.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/overallarch.png 1662w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>&nbsp;</p></span></p>
<h1>Summary</h1>
<p>Here we are again. The blinking LED.  I always start with a basic Blinking LED project just to make sure that everything is working.  What is everything?  The whole tool flow, from the editor, to the programmer, to the chip to the SDK.  The only thing that will be a little different than usual is that I will run the blinking LED in a thread by itself. This is useful for looking at the development kit and knowing that the RTOS is still running and the blinking LED thread is at least OK even if the rest of your program is trashed.</p>
<p>In each of the following lessons I will add on a new block (or two) into the architecture.  The blocks colored “green” will be the ones that are done in that lesson.  In future lessons the blocks that are blue will be from the previous lessons.</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l2-the-blinking-thread/lesson2-2/" rel="attachment wp-att-8036"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/lesson2-1-1024x651.png" alt="" width="1024" height="651" class="alignnone size-large wp-image-8036" srcset="https://iotexpert.com/wp-content/uploads/2019/12/lesson2-1-1024x651.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/lesson2-1-600x381.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/lesson2-1-300x191.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/lesson2-1-768x488.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/lesson2-1.png 1662w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>For all of these projects I will be using the Mbed Studio program to create, edit, build and program the development board.</p>
<p>To implement the blinking LED thread I will:</p>
<ol>
<li>Make a new Mbed OS Program from the blank template</li>
<li>Create &amp; code &#8220;blinkThread.h&#8221;</li>
<li>Create &amp; code &#8220;blinkThread.cpp&#8221;</li>
<li>Update main.cpp</li>
<li>Give a Tour of Targets</li>
<li>Compile and Program</li>
</ol>
<h1>Make a new Mbed OS Program from the blank template</h1>
<p>Start Mbed Studio.  Then run “File-&gt;New Program&#8230;”</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l2-the-blinking-thread/screen-shot-2019-12-07-at-4-03-36-pm/" rel="attachment wp-att-8047"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.03.36-PM.png" alt="" width="810" height="606" class="alignnone size-full wp-image-8047" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.03.36-PM.png 810w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.03.36-PM-600x449.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.03.36-PM-300x224.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.03.36-PM-768x575.png 768w" sizes="auto, (max-width: 810px) 100vw, 810px" /></a></p>
<p>Mbed Studio will then give you the ability to start with a template project.  To get started use “empty Mbed OS program”.  For each of the projects I will give it a name that corresponds to the lesson number, in this case “mouser-mbed-02”.  When you have all that selected click “Add Program”.</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l2-the-blinking-thread/screen-shot-2019-12-07-at-4-04-04-pm/" rel="attachment wp-att-8048"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.04.04-PM.png" alt="" width="896" height="584" class="alignnone size-large wp-image-8048" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.04.04-PM.png 896w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.04.04-PM-600x391.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.04.04-PM-300x196.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.04.04-PM-768x501.png 768w" sizes="auto, (max-width: 896px) 100vw, 896px" /></a></p>
<p>This will create a brand new project for you with Mbed OS setup and a blank main.cpp.</p>
<h1>Create &amp; code &#8220;blinkThread.h&#8221;</h1>
<p>In each of the following lessons I will be creating different threads to perform the different pieces of system functionality.  I will put each thread in a separate set of files with the name “functionThread.h” and “functionThread.cpp”.  As I am sure everyone knows, the “dot h” file is supposed to be the public interface to the “dot cpp” file.  In other words that file has all of the functions, objects and variables that other files are allowed to access.</p>
<p>To create a file you “right click” on the project and select “New File”</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l2-the-blinking-thread/screen-shot-2019-12-07-at-4-06-34-pm/" rel="attachment wp-att-8049"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.06.34-PM.png" alt="" width="682" height="262" class="alignnone size-full wp-image-8049" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.06.34-PM.png 682w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.06.34-PM-600x230.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.06.34-PM-300x115.png 300w" sizes="auto, (max-width: 682px) 100vw, 682px" /></a></p>
<p>And then give the file a name.  In this case it will be “blinkThread.h”.</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l2-the-blinking-thread/screen-shot-2019-12-07-at-4-06-47-pm/" rel="attachment wp-att-8050"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.06.47-PM.png" alt="" width="804" height="304" class="alignnone size-large wp-image-8050" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.06.47-PM.png 804w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.06.47-PM-600x227.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.06.47-PM-300x113.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.06.47-PM-768x290.png 768w" sizes="auto, (max-width: 804px) 100vw, 804px" /></a></p>
<p>This file will have the guards, to keep it from being included more than once, and just the function prototype for the thread.  In all of the coming lessons I will name the thread “functionThread”.  In this case the function is “blink” so the thread is called “blinkThread”</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c" ">#ifndef BLINK_THREAD_H
#define BLINK_THREAD_H

void blinkThread();

#endif
</pre>
<h1>Create &amp; code &#8220;blinkThread.cpp&#8221;</h1>
<p>Now I am ready to write the actual function which acts as the blinking LED thread.  Right click on the project and select “New File”</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l2-the-blinking-thread/screen-shot-2019-12-07-at-4-07-16-pm/" rel="attachment wp-att-8051"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.07.16-PM.png" alt="" width="686" height="174" class="alignnone size-large wp-image-8051" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.07.16-PM.png 686w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.07.16-PM-600x152.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.07.16-PM-300x76.png 300w" sizes="auto, (max-width: 686px) 100vw, 686px" /></a></p>
<p>Then give it the name “blinkThread.cpp”.  Just like the “dot h” files, the “dot cpp” files will be named “functionThread.cpp”.  In this case the function is blink so the file will be called “blinkThread.cpp”.</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l2-the-blinking-thread/screen-shot-2019-12-07-at-4-07-37-pm/" rel="attachment wp-att-8052"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.07.37-PM.png" alt="" width="800" height="302" class="alignnone size-large wp-image-8052" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.07.37-PM.png 800w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.07.37-PM-600x227.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.07.37-PM-300x113.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.07.37-PM-768x290.png 768w" sizes="auto, (max-width: 800px) 100vw, 800px" /></a></p>
<p>This is a really simple thread.  It wants to talk to the LED on the board.  All Mbed OS development boards are required to have at least one LED and that LED must be named “LED1”.  In reality the LED1 is just a map to the PSoC pin name of “P1_1” (this happens in the BSP/Target &#8211; more on this later).</p>
<p>By creating an object of type “DigitalOut” with an initializer argument of “LED1” I will have access to writing 1’s and 0’s to that pin.  Notice that I give the object definition the keyword “static” to limits its scope to this file.</p>
<p>The next thing that I need is the actual function which serves as the thread.  Notice that it is an infinite loop, which just does the following:</p>
<p>1. Inverts led1 by reading the pin, inverting it with the “!”, and then writing it back to the pin.</p>
<p>2. Doing a delay of 500 ms using the Mbed OS library function “sleep_for”.  For those of you who aren’t CPP people the “ThisThread::” just tells the compiler that the sleep_for function is in the namespace “ThisThread”.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#include "mbed.h"
#include "blinkThread.h"


static DigitalOut led1(LED1);

void blinkThread()
{
 
    while (true) 
    {
        led1 = !led1;
        ThisThread::sleep_for(500);
    }
}
</pre>
<h1>Update main.cpp</h1>
<p>In each of the following lessons, each time I create a new file, I will be making the same basic change to main.cpp.  Specifically I will startup the thread when the main function starts.  To do this:</p>
<ol>
<li>Include the new “functionThread.h” (in this case &#8220;blinkThread.h”).</li>
<li>Declare an object to hold the new thread (in this case &#8220;blinkThreadHandle&#8221;).</li>
<li>Start the thread by calling the start method with a function pointer to the actual thread function (in this case “blinkThread”).</li>
</ol>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#include "mbed.h"
#include "blinkThread.h"

Thread blinkThreadHandle;

int main()
{

    printf("Started System\n");

    blinkThreadHandle.start(blinkThread);
}
</pre>
<h1>Targets Tour</h1>
<p>Mbed OS abstracts all information about a development board into a set of files called the Target. These files reside in the mbed-os/targets directory.  This files are classically called the board support package (BSP).  This including information about which chip, startup code, libraries, and peripherals exist on the board.</p>
<p>In order to build a project you need to tell Mbed OS which target you are using.  This can be done in the Mbed CLI with  “mbed config target CY8CPROTO_062_4343W” or by selecting the correct target in the Mbed Studio IDE.</p>
<p>You should look in the following directories/files:</p>
<ol>
<li>mbed-os</li>
<li>targets directory</li>
<li>targets.json</li>
<li>TARGET_Cypress directory</li>
<li>One directory per Target</li>
</ol>
<h1>Compile and Program</h1>
<p>There are several things that you should notice on the panel to the left of your code.</p>
<ol>
<li>The active program (this is a drop down menu with each project in your workspace).</li>
<li>Which “target”.  When you plug in the development kit, Mbed Studio will recognize that you have attached a target that it recognizes.</li>
<li>The “hammer” button runs the Build process.</li>
<li>The “play” button runs a “Build” then programs the development kit.</li>
</ol>
<p>Press the “Play” button to Compile and Program.  And with any luck you should have a blinking LED.</p>
<p>Notice that it compiles a bunch of different files&#8230; actually all of the files in mbed-os.  This will take a while on a PC, but is much faster on a Mac or Linux.  This full compile step only needs to happen the first time for a project &#8211; each subsequent time will only compile your changes.</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l2-the-blinking-thread/screen-shot-2019-12-07-at-4-13-15-pm/" rel="attachment wp-att-8053"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.13.15-PM-1024x812.png" alt="" width="1024" height="812" class="alignnone size-large wp-image-8053" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.13.15-PM-1024x812.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.13.15-PM-600x476.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.13.15-PM-300x238.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.13.15-PM-768x609.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l2-the-blinking-thread/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Mouser PSoC 6 WiFi/BT MBED: L3 Display Thread</title>
		<link>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l3-display-thread/</link>
					<comments>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l3-display-thread/#comments</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Mon, 09 Dec 2019 17:04:56 +0000</pubDate>
				<category><![CDATA[Mouser PSoC 6 WiFi/BT MBED]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=8000</guid>

					<description><![CDATA[Summary In this lesson we will add an output capability to our project.  But what output device?  I am going old school with a serial terminal using VT100 graphics commands. Here is the update to the architecture.  Notice the new green boxes. A new thread (called Display Thread) The Serial terminal An RTC (the one [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><span><h1>IoT Design with Cypress PSoC® 6 MCUs and Wi-Fi/Bluetooth using Arm® Mbed<img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2122.png" alt="™" class="wp-smiley" style="height: 1em; max-height: 1em;" /></h1>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >#</th>
<th >Lesson</th>
<th >GitHub Project</th>
</tr>
</thead>
<tbody>
<tr><td >0</td>
<td ><a href="https://iotexpert.com/2019/12/08/mouser-psoc-6-wifi-bt-mbed-l0-introduction/" target="_blank" rel="noopener">Introduction</a></td>
<td ></td>
</tr>

<tr><td >1</td>
<td ><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l1-developer-resources/" target="_blank" rel="noopener">Developer Resources</a></td>
<td ></td>
</tr>

<tr><td >2</td>
<td ><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l2-the-blinking-thread/" target="_blank" rel="noopener">Your First Project &amp; The Blinking Thread</a></td>
<td >https://github.com/iotexpert/mouser-mbed-02.git</td>
</tr>

<tr><td >3</td>
<td ><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l3-display-thread/" target="_blank" rel="noopener">Display Thread</a></td>
<td >https://github.com/iotexpert/mouser-mbed-03.git</td>
</tr>

<tr><td >4</td>
<td ><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l4-temperature-thread/" target="_blank" rel="noopener">Temperature Thread</a></td>
<td >https://github.com/iotexpert/mouser-mbed-04.git</td>
</tr>

<tr><td >5</td>
<td ><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l5-capsense-thread/" target="_blank" rel="noopener">CapSense Thread</a></td>
<td >https://github.com/iotexpert/mouser-mbed-05.git</td>
</tr>

<tr><td >6</td>
<td ><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l6-wifi-ntp-thread/" target="_blank" rel="noopener">WiFi &amp; NTP Thread</a></td>
<td >https://github.com/iotexpert/mouser-mbed-06.git</td>
</tr>

<tr><td >7</td>
<td ><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l7-the-cy8ckit-062-wifi-bt/" target="_blank" rel="noopener">The CY8CKIT-062-WiFi-BT</a></td>
<td >https://github.com/iotexpert/mouser-mbed-07.git </td>
</tr>

<tr><td >8</td>
<td ><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l8-amazon-aws-mqtt-thread-part1/" target="_blank" rel="noopener">Amazon AWS MQTT Thread - Part1</a></td>
<td >https://github.com/iotexpert/mouser-mbed-08.git</td>
</tr>

<tr><td >9</td>
<td ><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l9-amazon-aws-mqtt-thread-part2/" target="_blank" rel="noopener">Amazon AWS MQTT Thread - Part2</a></td>
<td >https://github.com/iotexpert/mouser-mbed-09.git</td>
</tr>
</tbody></table></div></p>
<p>You can “mbed import https://github.com/iotexpert/mouser-mbed-09.git“ to make a copy of the project in your workspace.</p>
<p>The final architecture of the thermostat looks like this.</p>
<p><a href="https://iotexpert.com/?attachment_id=8027" rel="attachment wp-att-8027"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/overallarch-1024x651.png" alt="" width="1024" height="651" class="alignnone size-large wp-image-8027" srcset="https://iotexpert.com/wp-content/uploads/2019/12/overallarch-1024x651.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/overallarch-600x381.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/overallarch-300x191.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/overallarch-768x488.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/overallarch.png 1662w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>&nbsp;</p></span></p>
<h1>Summary</h1>
<p>In this lesson we will add an output capability to our project.  But what output device?  I am going old school with a serial terminal using VT100 graphics commands.</p>
<p>Here is the update to the architecture.  Notice the new green boxes.</p>
<ol>
<li>A new thread (called Display Thread)</li>
<li>The Serial terminal</li>
<li>An RTC (the one built into the PSoC 6)</li>
<li>An RTOS Queue called “Display Command Queue”</li>
<li>A function called displaySendUpdateTime (to tell the display to show the time)</li>
</ol>
<p><a href="https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l3-display-thread/lesson3/"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/lesson3-1024x651.png" alt="" class="alignnone wp-image-8034 size-large" width="1024" height="651" srcset="https://iotexpert.com/wp-content/uploads/2019/12/lesson3-1024x651.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/lesson3-600x381.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/lesson3-300x191.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/lesson3-768x488.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/lesson3.png 1662w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p><span>The way this will work is a new thread called “displayThread” will be created.  I will have an RTOS queue associated with it.  Tasks that want to display something will push a message into the queue.  The display thread will wait around until some other task pushes a message into the queue.  When another task pushes a message, the displayThread will process the message and “do the needful”.</span></p>
<p>To implement this I will:</p>
<ol>
<li>Import from GitHub lesson02</li>
<li>Discuss VT100 Commands</li>
<li>Create &amp; code displayThread.h</li>
<li>Create &amp; code displayThread.cpp</li>
<li>Create &amp; code mbed_app.json</li>
<li>Update blinkThread.cpp</li>
<li>Update main.cpp</li>
<li>Build, Program and Test</li>
</ol>
<h1>Import from GitHub Lesson 02</h1>
<p>Mbed Studio can start a new project by “importing” an old project and giving it a new name.  This is a super convenient way for me to build each project for this class on the base of the previous one.  To make this easier for you I save each of these lesson projects on GitHub so you can start from there.</p>
<p>In Mbed Studio use “File-&gt;Import Program&#8230;”</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l3-display-thread/screen-shot-2019-12-07-at-4-23-51-pm/" rel="attachment wp-att-8056"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.23.51-PM.png" alt="" class="alignnone size-full wp-image-8056" width="734" height="638" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.23.51-PM.png 734w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.23.51-PM-600x522.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.23.51-PM-300x261.png 300w" sizes="auto, (max-width: 734px) 100vw, 734px" /></a></p>
<p>Give it the path to my github site for the project you want to start from:</p>
<p>https://github.com/iotexpert/mouser-mbed-02.git</p>
<p>And then give it the new name you want for the new project &#8211; in this case mouser-mbed-03</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l3-display-thread/screen-shot-2019-12-07-at-4-24-08-pm/" rel="attachment wp-att-8057"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.24.08-PM.png" alt="" class="alignnone size-large wp-image-8057" width="888" height="600" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.24.08-PM.png 888w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.24.08-PM-600x405.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.24.08-PM-300x203.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.24.08-PM-768x519.png 768w" sizes="auto, (max-width: 888px) 100vw, 888px" /></a></p>
<p>After clicking “Add program” you should have a new program called “mouser-mbed-03” and it should be set as the active program.</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l3-display-thread/screen-shot-2019-12-07-at-4-26-57-pm/" rel="attachment wp-att-8058"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.26.57-PM.png" alt="" class="alignnone size-large wp-image-8058" width="782" height="990" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.26.57-PM.png 782w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.26.57-PM-600x760.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.26.57-PM-237x300.png 237w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.26.57-PM-768x972.png 768w" sizes="auto, (max-width: 782px) 100vw, 782px" /></a></p>
<p>At this point you could press the play button and get exactly the same behavior as the previous lesson 02.</p>
<h1>VT100 Commands</h1>
<p>Back in the dark ages when I started programming, most work was done on a “main frame” of some kind or the other.  The two that I used were the PDP-11 and the Prime.  To access these systems you typically used a “Dumb Terminal” attached to the mainframe via a long serial cable.  One of the most used terminals was the <a href="https://en.m.wikipedia.org/wiki/VT100" target="_blank" rel="noopener noreferrer">VT100</a> made by Digital Equipment Corporation (DEC).</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l3-display-thread/2ea7ca06-014c-4969-9e3e-a54e5000d369/" rel="attachment wp-att-8155"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/2EA7CA06-014C-4969-9E3E-A54E5000D369.jpeg" alt="" class="alignnone size-full wp-image-8155" width="300" height="266" /></a></p>
<p>These terminals could output a fixed width font in about 80 columns and 24 rows.  Basically, the mainframe sent ASCII characters and the terminal would display them.</p>
<p>An interesting feature that was put into these terminals was the ability to take commands and move the cursor around to screen, or clear it, or draw a line or &#8230;.</p>
<p>What does that have to do with today?  Simple, the VT100 command set is still used by almost all serial programs on your PC (Putty, etc).  And I am going to use these commands to create a graphical user interface for the thermostat that looks like this:</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l6-wifi-ntp-thread/screen-shot-2019-12-07-at-7-16-59-pm/" rel="attachment wp-att-8102"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.16.59-PM-1024x142.png" alt="" class="alignnone size-large wp-image-8102" width="1024" height="142" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.16.59-PM-1024x142.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.16.59-PM-600x83.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.16.59-PM-300x42.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.16.59-PM-768x106.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<ul>
<li>Line 1 will be the current temperature</li>
<li>Line 2 will be the setPoint of the thermostat</li>
<li>Line 3 will be the time</li>
<li>Line 4 will be the status of the system (Heat, Cool or Off)</li>
</ul>
<p>To use the VT100 commands you just use printf to send them to the serial terminal.  The commands I will use are:</p>
<div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >Command</th>
<th >ESC Sequence</th>
<th >printf</th>
</tr>
</thead>
<tbody>
<tr><td >Home</td>
<td >ESC [ H </td>
<td >printf("\033[H");</td>
</tr>

<tr><td >Clear Screen</td>
<td >ESC [ J</td>
<td >printf("\033[2J");</td>
</tr>

<tr><td >Turn Cursor Off</td>
<td >ESC [ ? 25l</td>
<td >printf("\033[?25l");</td>
</tr>

<tr><td >Goto column &amp; row</td>
<td >ESC [ column ; row H</td>
<td >printf("\033[%d;%dH%s",y,x,buffer);</td>
</tr>
</tbody></table></div>
<h1>Add displayThread.h</h1>
<p>As in lesson 02 I will create a new thread.  This time the header file will be called “displayThread.h”  Right click and select “New File”</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l3-display-thread/screen-shot-2019-12-07-at-4-27-37-pm/" rel="attachment wp-att-8059"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.27.37-PM.png" alt="" class="alignnone size-full wp-image-8059" width="796" height="688" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.27.37-PM.png 796w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.27.37-PM-600x519.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.27.37-PM-300x259.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.27.37-PM-768x664.png 768w" sizes="auto, (max-width: 796px) 100vw, 796px" /></a></p>
<p>Give it the name “displayThread.h”</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l3-display-thread/screen-shot-2019-12-07-at-4-27-51-pm/" rel="attachment wp-att-8060"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.27.51-PM.png" alt="" class="alignnone size-large wp-image-8060" width="784" height="286" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.27.51-PM.png 784w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.27.51-PM-600x219.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.27.51-PM-300x109.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.27.51-PM-768x280.png 768w" sizes="auto, (max-width: 784px) 100vw, 784px" /></a></p>
<p>This file will:</p>
<ol>
<li>Guard against multiple include</li>
<li>Provide the function prototype of the thread</li>
<li>Provide four functions to tell the displayThread to write onto the four different lines of the GUI</li>
</ol>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#ifndef DISPLAY_THREAD_H
#define DISPLAY_THREAD_H

void displayThread();


void displaySendUpdateTemp(float temperature);
void displaySendUpdateTime();
void displaySendUpdateSetPoint(float setPoint);
void displaySendUpdateMode(float mode);

#endif</pre>
<h1>Add displayThread.cpp</h1>
<p>From now on I will just show the file creation.  In this case “displayThread.cpp”</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l3-display-thread/screen-shot-2019-12-07-at-4-28-11-pm/" rel="attachment wp-att-8061"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.28.11-PM.png" alt="" class="alignnone size-large wp-image-8061" width="790" height="286" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.28.11-PM.png 790w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.28.11-PM-600x217.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.28.11-PM-300x109.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.28.11-PM-768x278.png 768w" sizes="auto, (max-width: 790px) 100vw, 790px" /></a></p>
<p>The first part of the file is to specify the queue.  To do this I create a new type called msg_t which will be inserted into the queue (actually a pointer to the msg_t).  The message structure will have two members the “command_t” and a generic floating point variable called “value”.</p>
<p>The Queue and Memory pool will only be accessible inside of this file.  The queue will hold up to 16 “msg_t”.  The MemoryPool is just an easy  way to do memory allocation.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#include "mbed.h"
#include "displayThread.h"

typedef enum {
    CMD_temperature,
    CMD_setPoint,
    CMD_time,
    CMD_mode,
} command_t;


typedef struct {
    command_t cmd;
    float    value;
} msg_t;


static Queue&lt;msg_t, 16&gt; queue;
static MemoryPool&lt;msg_t, 16&gt; mpool;</pre>
<p>In order to insert msg_t into the queue I create one function per msg_t that:</p>
<ul>
<li>allocates a new message</li>
<li>sets the command</li>
<li>sets the value</li>
<li>puts the message in the queue</li>
</ul>
<p>Notice if something goes wrong, I just ignore the problem.  In a real system you would probably want to do something else.</p>
<p>These four functions will actually run inside of the thread that calls them, but they will insert messages into the queue that the displayThread is processing.  This queue mechanism is a safe way for processes to talk to each other.</p>
<pre class="start-line:21 EnlighterJSRAW" data-enlighter-language="c">// Function called by other threads to queue a temperature change onto the display
void displaySendUpdateTemp(float temperature)
{
    msg_t *message = mpool.alloc();
    if(message)
    {
        message-&gt;cmd = CMD_temperature;
        message-&gt;value = temperature;
        queue.put(message);
    }
}

// Function called by other threads to queue display to update time
void displaySendUpdateTime()
{
    msg_t *message = mpool.alloc();
    if(message)
    {
        message-&gt;cmd = CMD_time;
        message-&gt;value = 0;
        queue.put(message);
    }
}

// Function called by other threads to queue a setPoint change onto the display
void displaySendUpdateSetPoint(float setPoint)
{
    msg_t *message = mpool.alloc();
    if(message)
    {
        message-&gt;cmd = CMD_setPoint;
        message-&gt;value = setPoint;
        queue.put(message);
    }
}

// Function called by other threads to queue a setPoint change onto the display
void displaySendUpdateMode(float mode)
{
    msg_t *message = mpool.alloc();
    if(message)
    {
        message-&gt;cmd = CMD_mode;
        message-&gt;value = mode;
        queue.put(message);
    }
}</pre>
<p>The function displayAtXY creates a string with the VT100 Goto command plus the string that was send.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">static void displayAtXY(int x, int y,char *buffer)
{
    // row column
    printf("\033[%d;%dH%s",y,x,buffer);
    fflush(stdout);
}
</pre>
<p>The actual display thread:</p>
<ul>
<li>Clears the screen and turns the cursor off</li>
<li>Goes into an infinite loop waiting for messages to be put into the queue</li>
<li>When a new message comes in, look at the command</li>
<li>sprintf to create the display message</li>
<li>print it using the displayAtXY function</li>
</ul>
<pre class="start-line:79 EnlighterJSRAW" data-enlighter-language="c">void displayThread()
{
    char buffer[128];

    printf("\033[2J\033[H"); // Clear Screen and go Home
    printf("\033[?25l"); // Turn the cursor off
    fflush(stdout);

    while(1)
    {
        osEvent evt = queue.get();
        if (evt.status == osEventMessage) {
            msg_t *message = (msg_t*)evt.value.p;
            switch(message-&gt;cmd)
            {
                case CMD_temperature:
                    sprintf(buffer,"Temperature = %2.1fF",message-&gt;value);
                    displayAtXY(1, 1, buffer);
                break;
                case CMD_setPoint:
                    sprintf(buffer,"Set Point = %2.1fF",message-&gt;value);
                    displayAtXY(1, 2, buffer);
                break;
                case CMD_time:
                    time_t rawtime;
                    struct tm * timeinfo;
                    time (&amp;rawtime);
                    rawtime = rawtime - (5*60*60); // UTC - 4hours ... serious hack which only works in winter
                    timeinfo = localtime (&amp;rawtime);
                    strftime (buffer,sizeof(buffer),"%r",timeinfo);
                    displayAtXY(1,3, buffer);
                break;
                case CMD_mode:
                    if(message-&gt;value == 0.0)
                        sprintf(buffer,"Mode = Off ");
                    else if (message-&gt;value &lt; 0.0)
                        sprintf(buffer,"Mode = Heat");
                    else
                        sprintf(buffer,"Mode = Cool");
                    displayAtXY(1, 4, buffer);
                break;

            }
            mpool.free(message);

        }
    }
}
</pre>
<p>Here is the whole file displayThread.cpp (to make a copy/paste easier):</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#include "mbed.h"
#include "displayThread.h"

typedef enum {
    CMD_temperature,
    CMD_setPoint,
    CMD_time,
    CMD_mode,
} command_t;


typedef struct {
    command_t cmd;
    float    value;
} msg_t;


static Queue&lt;msg_t, 32&gt; queue;
static MemoryPool&lt;msg_t, 16&gt; mpool;

// Function called by other threads to queue a temperature change onto the display
void displaySendUpdateTemp(float temperature)
{
    msg_t *message = mpool.alloc();
    if(message)
    {
        message-&gt;cmd = CMD_temperature;
        message-&gt;value = temperature;
        queue.put(message);
    }
}

// Function called by other threads to queue display to update time
void displaySendUpdateTime()
{
    msg_t *message = mpool.alloc();
    if(message)
    {
        message-&gt;cmd = CMD_time;
        message-&gt;value = 0;
        queue.put(message);
    }
}

// Function called by other threads to queue a setPoint change onto the display
void displaySendUpdateSetPoint(float setPoint)
{
    msg_t *message = mpool.alloc();
    if(message)
    {
        message-&gt;cmd = CMD_setPoint;
        message-&gt;value = setPoint;
        queue.put(message);
    }
}

// Function called by other threads to queue a setPoint change onto the display
void displaySendUpdateMode(float mode)
{
    msg_t *message = mpool.alloc();
    if(message)
    {
        message-&gt;cmd = CMD_mode;
        message-&gt;value = mode;
        queue.put(message);
    }
}

static void displayAtXY(int x, int y,char *buffer)
{
    // row column
    printf("\033[%d;%dH%s",y,x,buffer);
    fflush(stdout);
}


///////////////////////////////////////////////////////////////////////////////////////////////////////////

void displayThread()
{
    char buffer[128];

    printf("\033[2J\033[H"); // Clear Screen and go Home
    printf("\033[?25l"); // Turn the cursor off
    fflush(stdout);

    while(1)
    {
        osEvent evt = queue.get();
        if (evt.status == osEventMessage) {
            msg_t *message = (msg_t*)evt.value.p;
            switch(message-&gt;cmd)
            {
                case CMD_temperature:
                    sprintf(buffer,"Temperature = %2.1fF",message-&gt;value);
                    displayAtXY(1, 1, buffer);
                break;
                case CMD_setPoint:
                    sprintf(buffer,"Set Point = %2.1fF",message-&gt;value);
                    displayAtXY(1, 2, buffer);
                break;
                case CMD_time:
                    time_t rawtime;
                    struct tm * timeinfo;
                    time (&amp;rawtime);
                    rawtime = rawtime - (5*60*60); // UTC - 4hours ... serious hack which only works in winter
                    timeinfo = localtime (&amp;rawtime);
                    strftime (buffer,sizeof(buffer),"%r",timeinfo);
                    displayAtXY(1,3, buffer);
                break;
                case CMD_mode:
                    if(message-&gt;value == 0.0)
                        sprintf(buffer,"Mode = Off ");
                    else if (message-&gt;value &lt; 0.0)
                        sprintf(buffer,"Mode = Heat");
                    else
                        sprintf(buffer,"Mode = Cool");
                    displayAtXY(1, 4, buffer);
                break;

            }
            mpool.free(message);

        }
    }
}
</pre>
<h1>Create mbed_app.json</h1>
<p>By default the serial terminal on Mbed OS is 9600 baud or approximately the same speed as back in VT100 days.  Fortunately you can change that by setting up a global configuration.  To do this you need to create a file called “mbed_app.json”.</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l3-display-thread/screen-shot-2019-12-07-at-4-33-13-pm/" rel="attachment wp-att-8062"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.33.13-PM.png" alt="" class="alignnone size-full wp-image-8062" width="802" height="296" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.33.13-PM.png 802w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.33.13-PM-600x221.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.33.13-PM-300x111.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.33.13-PM-768x283.png 768w" sizes="auto, (max-width: 802px) 100vw, 802px" /></a></p>
<p>In that file, I tell the system that I want 115200 baud for all targets.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">{
    "target_overrides": {
        "*": {
            "platform.stdio-baud-rate": 115200
        }
    }
}
</pre>
<h1>Update blinkThread.cpp</h1>
<p>In order to test the new displayThread, I will fix up the blinkThread to temporarily send the four messages.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#include "mbed.h"
#include "blinkThread.h"
#include "displayThread.h"

static DigitalOut led1(LED1);

void blinkThread()
{
 
    while (true) 
    {
        led1 = !led1;
        displaySendUpdateTime();
        displaySendUpdateTemp(69.2);
        displaySendUpdateSetPoint(23.5);
        displaySendUpdateMode(-1.0);
        ThisThread::sleep_for(500);
    }
}</pre>
<h1>Update main.cpp</h1>
<p>The last step is to update main to start the new displayThread.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#include "mbed.h"
#include "blinkThread.h"
#include "displayThread.h"

Thread blinkThreadHandle;
Thread displayThreadHandle;

int main()
{

    printf("Started System\n");

    blinkThreadHandle.start(blinkThread);
    displayThreadHandle.start(displayThread);

}
</pre>
<h1>Build, Program and Test</h1>
<p>Now press the play button.</p>
<p>One nice thing in Mbed Studio is a built-in serial port viewer.  You can use it by clicking “View -&gt; Serial Monitor”</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l3-display-thread/screen-shot-2019-12-07-at-4-36-38-pm/" rel="attachment wp-att-8064"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.36.38-PM.png" alt="" class="alignnone size-full wp-image-8064" width="538" height="808" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.36.38-PM.png 538w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.36.38-PM-200x300.png 200w" sizes="auto, (max-width: 538px) 100vw, 538px" /></a></p>
<p>Change the baud rate to 115200 and you should see something like this:</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l3-display-thread/screen-shot-2019-12-07-at-4-48-26-pm/" rel="attachment wp-att-8066"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.48.26-PM-1024x124.png" alt="" class="alignnone size-large wp-image-8066" width="1024" height="124" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.48.26-PM-1024x124.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.48.26-PM-600x73.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.48.26-PM-300x36.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.48.26-PM-768x93.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l3-display-thread/feed/</wfw:commentRss>
			<slash:comments>8</slash:comments>
		
		
			</item>
	</channel>
</rss>
