<?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>Mouser PSoC 6 WiFi/BT MBED &#8211; IoT Expert</title>
	<atom:link href="https://iotexpert.com/category/misc/mouser-psoc-6-wifi-bt-mbed/feed/" rel="self" type="application/rss+xml" />
	<link>https://iotexpert.com</link>
	<description>Engineering for the Internet of Things</description>
	<lastBuildDate>Tue, 19 Jan 2021 17:23:12 +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>Mouser PSoC 6 WiFi/BT MBED &#8211; IoT Expert</title>
	<link>https://iotexpert.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<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 fetchpriority="high" 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="(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 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="(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 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="(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>
		<item>
		<title>Mouser PSoC 6 WiFi/BT MBED: L4 Temperature Thread</title>
		<link>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l4-temperature-thread/</link>
					<comments>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l4-temperature-thread/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Mon, 09 Dec 2019 17:04:44 +0000</pubDate>
				<category><![CDATA[Mouser PSoC 6 WiFi/BT MBED]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=7999</guid>

					<description><![CDATA[Summary In Lesson 04 I will add temperature sensing to the system. The new thread called “temperatureThread” acts as the actual guts of the thermostat.  It reads the temperature sensor, keeps track of the setPoint of the system and turns on and off Heat and Cooling.  Notice that it doesn&#8217;t know anything about displaying information, [&#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 Lesson 04 I will add temperature sensing to the system.</p>
<p><a href="https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l4-temperature-thread/lesson4/"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/lesson4-1024x651.png" alt="" class="alignnone wp-image-8033 size-large" width="1024" height="651" srcset="https://iotexpert.com/wp-content/uploads/2019/12/lesson4-1024x651.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/lesson4-600x381.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/lesson4-300x191.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/lesson4-768x488.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/lesson4.png 1662w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>The new thread called “temperatureThread” acts as the actual guts of the thermostat.  It reads the temperature sensor, keeps track of the setPoint of the system and turns on and off Heat and Cooling.  Notice that it doesn&#8217;t know anything about displaying information,  it just uses the functions calls we created for the displayThread.</p>
<p>To implement this I will:</p>
<ol>
<li>Explain Thermistors</li>
<li>Import lesson03</li>
<li>Create and code temperatureThread.h</li>
<li>Create and code temperatureThread.cpp</li>
<li>Fix blinkThread.cpp</li>
<li>Update main.cpp</li>
<li>Build, Program and Test</li>
</ol>
<h1>Thermistor</h1>
<p>On the wing of the CY8CPROTO-062-4343W there is a thermistor that you can use to measure temperature.   What is a thermistor?  It is simply a resistor that changes resistance in a known way based on temperature.</p>
<p>If you know the resistance you can calculate the temperature using the Steinhart-Hart equation.  Here is the <a href="https://en.m.wikipedia.org/wiki/Thermistor" target="_blank" rel="noopener noreferrer">Thermistor</a> Wikipedia article.</p>
<p>When you look at the <a href="https://www.cypress.com/file/457811/download" target="_blank" rel="noopener noreferrer">schematic</a> for the development kit you can see how the circuit is attached to the PSoC.</p>
<p>Basically, a known 10K resistor in series with the thermistor with a measurement point between them.  To calculate the resistance of the thermistor you use Ohms low, V=IR.  Or even better R=V/I.</p>
<p><span>To use this circuit you need to assign a voltage to the THERM_VDD, use a DigialOut to drive 3.3v to that signal and a DigialOut to drive ground to the THERM_GND.</span></p>
<p>Then use the ADC to find the voltage for THERM_OUT</p>
<p>To do the calculation, first the Thermistor voltage is THERM_VDD-THERM_OUT.</p>
<p>Then you need to get the current.  To do this you calculate the current through the reference resistor I=V/R or I=(THERM_OUT/10K).  This will be the same current as the Thermistor.</p>
<p>Now you can calculate the thermistor resistance.</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l4-temperature-thread/screen-shot-2019-12-07-at-5-13-51-pm/" rel="attachment wp-att-8077"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.13.51-PM-788x1024.png" alt="" class="alignnone size-large wp-image-8077" width="788" height="1024" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.13.51-PM-788x1024.png 788w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.13.51-PM-600x780.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.13.51-PM-231x300.png 231w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.13.51-PM-768x998.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.13.51-PM.png 934w" sizes="auto, (max-width: 788px) 100vw, 788px" /></a></p>
<p>Here is a picture of the thermistor on the board.</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l4-temperature-thread/img_1162/" rel="attachment wp-att-8209"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/IMG_1162-1024x848.jpg" alt="" class="alignnone size-large wp-image-8209" width="1024" height="848" srcset="https://iotexpert.com/wp-content/uploads/2019/12/IMG_1162-1024x848.jpg 1024w, https://iotexpert.com/wp-content/uploads/2019/12/IMG_1162-600x497.jpg 600w, https://iotexpert.com/wp-content/uploads/2019/12/IMG_1162-300x248.jpg 300w, https://iotexpert.com/wp-content/uploads/2019/12/IMG_1162-768x636.jpg 768w, https://iotexpert.com/wp-content/uploads/2019/12/IMG_1162.jpg 1454w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Here is the code that implements the thermistor measurement.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">static DigitalOut thermVDD(P10_3,1);
static DigitalOut thermGND(P10_0,0);
static AnalogIn thermOut(P10_1);

static void readTemp()
{
    float refVoltage = thermOut.read() * 2.4; // Range of ADC 0-&gt;2*Vref
    float refCurrent = refVoltage  / 10000.0; // 10k Reference Resistor
    float thermVoltage = 3.3 - refVoltage;    // Assume supply voltage is 3.3v
    float thermResistance = thermVoltage / refCurrent; 
    float logrT = (float32_t)log((float64_t)thermResistance);

    /* Calculate temperature from the resistance of thermistor using Steinhart-Hart Equation */
    float stEqn = (float32_t)((0.0009032679) + ((0.000248772) * logrT) + 
                             ((2.041094E-07) * pow((float64)logrT, (float32)3)));

    float temperatureC = (float32_t)(((1.0 / stEqn) - 273.15)  + 0.5);
    temperatureF = (temperatureC * 9.0/5.0) + 32;
}
</pre>
<h1>Import Lesson 03</h1>
<p>To build the project, start by importing Lesson 03:</p>
<p>https://github.com/iotexpert/mouser-mbed-03.git</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l4-temperature-thread/screen-shot-2019-12-07-at-4-56-09-pm/" rel="attachment wp-att-8069"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.56.09-PM.png" alt="" class="alignnone size-full wp-image-8069" width="806" height="602" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.56.09-PM.png 806w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.56.09-PM-600x448.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.56.09-PM-300x224.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.56.09-PM-768x574.png 768w" sizes="auto, (max-width: 806px) 100vw, 806px" /></a></p>
<p>Give it a new name of &#8220;mouser-mbed-04&#8221;:</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l4-temperature-thread/screen-shot-2019-12-07-at-4-57-28-pm/" rel="attachment wp-att-8071"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.57.28-PM.png" alt="" class="alignnone size-large wp-image-8071" width="892" height="608" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.57.28-PM.png 892w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.57.28-PM-600x409.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.57.28-PM-300x204.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.57.28-PM-768x523.png 768w" sizes="auto, (max-width: 892px) 100vw, 892px" /></a></p>
<h1>Create and code temperatureThread.h</h1>
<p>As before we want a thread for the temperature system called “temperatureThread.h”.  Create the “dot h”:</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l4-temperature-thread/screen-shot-2019-12-07-at-4-58-48-pm/" rel="attachment wp-att-8072"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.58.48-PM.png" alt="" class="alignnone size-full wp-image-8072" width="800" height="310" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.58.48-PM.png 800w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.58.48-PM-600x233.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.58.48-PM-300x116.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.58.48-PM-768x298.png 768w" sizes="auto, (max-width: 800px) 100vw, 800px" /></a></p>
<p>This file will just declare the thread and interface functions.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#ifndef TEMPERATURE_H
#define TEMPERATURE_H

void temperatureThread();

void tempSendUpdateSetpointF(float setPoint);
void tempSendDeltaSetpointF(float delta);


#endif
</pre>
<h1>Create and code temperatureThread.cpp</h1>
<p>Now we need the actual thread.  Make the new file “temperatureThread.cpp”</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l4-temperature-thread/screen-shot-2019-12-07-at-4-59-30-pm/" rel="attachment wp-att-8073"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.59.30-PM.png" alt="" class="alignnone size-large wp-image-8073" width="798" height="296" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.59.30-PM.png 798w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.59.30-PM-600x223.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.59.30-PM-300x111.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-4.59.30-PM-768x285.png 768w" sizes="auto, (max-width: 798px) 100vw, 798px" /></a></p>
<p>This thread will have two state variables.  One for temperatureF and one for the setPoint of the thermostat.</p>
<p>This thread will also have a queue just like the displayThread.  This queue will be used to let other parts of the system change the setPoint. One command to make a “delta” change  e.g. “go up 1 degree” and one command to make an absolute change e.g “set to 78 degrees”</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#include "mbed.h"
#include "temperatureThread.h"
#include "displayThread.h"

static float temperatureF;
static float setPoint = 75.0;

static void readTemp();

typedef enum {
    CMD_setPointDelta,
    CMD_setPoint,

} command_t;


typedef struct {
    command_t cmd;
    float    value;   /* AD result of measured voltage */
} msg_t;
</pre>
<p>As before to make things easier for the other parts of the system to send messages to the queue, I create functions to send the two commands.</p>
<pre class="start-line:26 EnlighterJSRAW" data-enlighter-language="c">void tempSendDeltaSetpointF(float delta)
{
    msg_t *message = mpool.alloc();
    if(message)
    {
        message-&gt;cmd = CMD_setPointDelta;
        message-&gt;value = delta;
        queue.put(message);
    }
}

void tempSendUpdateSetpointF(float setPoint)
{
    msg_t *message = mpool.alloc();
    if(message)
    {
        message-&gt;cmd = CMD_setPoint;
        message-&gt;value = setPoint;
        queue.put(message);
    }
}</pre>
<p>Now you need the function to read the temperature and update the state variable temperatureF</p>
<pre class="start-line:94 EnlighterJSRAW" data-enlighter-language="c">static DigitalOut thermVDD(P10_3,1);
static DigitalOut thermGND(P10_0,0);
static AnalogIn thermOut(P10_1);

static void readTemp()
{
    float refVoltage = thermOut.read() * 2.4; // Range of ADC 0-&gt;2*Vref
    float refCurrent = refVoltage  / 10000.0; // 10k Reference Resistor
    float thermVoltage = 3.3 - refVoltage;    // Assume supply voltage is 3.3v
    float thermResistance = thermVoltage / refCurrent; 
    float logrT = (float32_t)log((float64_t)thermResistance);

    /* Calculate temperature from the resistance of thermistor using Steinhart-Hart Equation */
    float stEqn = (float32_t)((0.0009032679) + ((0.000248772) * logrT) + 
                             ((2.041094E-07) * pow((float64)logrT, (float32)3)));

    float temperatureC = (float32_t)(((1.0 / stEqn) - 273.15)  + 0.5);
    temperatureF = (temperatureC * 9.0/5.0) + 32;
}
</pre>
<p>The temperatureThread listens for messages to be put into the queue.  It then processes them by either increment/decrement of the setPoint or by setting an absolute setPoint.</p>
<p>Also, the queue wait will timeout every 200ms and when that happens it will read the temperature and update the display.</p>
<p>It will also send the cool, heat or off based on a +- 0.5 degree difference from the setPoint.  In other words:</p>
<ul>
<li>temperatureF &gt; setPoint + 0.5 = cool</li>
<li>temperatureF &lt; setPoint -0.5 = heat</li>
<li>Otherwise OFF</li>
</ul>
<pre class="start-line:48 EnlighterJSRAW" data-enlighter-language="c">void temperatureThread()
{

    char buffer[128];
    displaySendUpdateTemp(temperatureF);
    displaySendUpdateSetPoint(setPoint);
    
    while(1)
    {
        osEvent evt = queue.get(200);
        if (evt.status == osEventMessage) {
            msg_t *message = (msg_t*)evt.value.p;
            switch(message-&gt;cmd)
            {
                case CMD_setPointDelta:
                    setPoint += message-&gt;value;
                    displaySendSetPoint(setPoint);
                break;
                case CMD_setPoint:
                    setPoint = message-&gt;value;
                    displaySendUpdateSetPoint(setPoint);
                break;

            }
            mpool.free(message);

        }
        else
        {
            readTemp();

            // Control the HVAC system with +- 0.5 degree of Hystersis
            if(temperatureF &lt; setPoint - 0.5)
                displaySendUpdateMode(-1.0);
            else if (temperatureF &gt; setPoint + 0.5)
                displaySendUpdateMode(1.0);
            else
                displaySendUpdateMode(0.0);

            displaySendUpdateTemp(temperatureF); 
        }
    }

}</pre>
<p>The whole file (to make the copy/paste easier):</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#include "mbed.h"
#include "temperatureThread.h"
#include "displayThread.h"

static float temperatureF;
static float setPoint = 75.0;

static void readTemp();

typedef enum {
    CMD_setPointDelta,
    CMD_setPoint,

} command_t;


typedef struct {
    command_t cmd;
    float    value;   /* AD result of measured voltage */
} msg_t;


static Queue&lt;msg_t, 32&gt; queue;
static MemoryPool&lt;msg_t, 16&gt; mpool;

void tempSendDeltaSetpointF(float delta)
{
    msg_t *message = mpool.alloc();
    if(message)
    {
        message-&gt;cmd = CMD_setPointDelta;
        message-&gt;value = delta;
        queue.put(message);
    }
}

void tempSendUpdateSetpointF(float setPoint)
{
    msg_t *message = mpool.alloc();
    if(message)
    {
        message-&gt;cmd = CMD_setPoint;
        message-&gt;value = setPoint;
        queue.put(message);
    }
}

void temperatureThread()
{

    char buffer[128];
    displaySendUpdateTemp(temperatureF);
    displaySendUpdateSetPoint(setPoint);
    
    while(1)
    {
        osEvent evt = queue.get(200);
        if (evt.status == osEventMessage) {
            msg_t *message = (msg_t*)evt.value.p;
            switch(message-&gt;cmd)
            {
                case CMD_setPointDelta:
                    setPoint += message-&gt;value;
                    displaySendUpdateSetPoint(setPoint);
                break;
                case CMD_setPoint:
                    setPoint = message-&gt;value;
                    displaySendUpdateSetPoint(setPoint);
                break;

            }
            mpool.free(message);

        }
        else
        {
            readTemp();

            // Control the HVAC system with +- 0.5 degree of Hystersis
            if(temperatureF &lt; setPoint - 0.5)
                displaySendUpdateMode(-1.0);
            else if (temperatureF &gt; setPoint + 0.5)
                displaySendUpdateMode(1.0);
            else
                displaySendUpdateMode(0.0);

            displaySendUpdateTemp(temperatureF); 
        }
    }

}


static DigitalOut thermVDD(P10_3,1);
static DigitalOut thermGND(P10_0,0);
static AnalogIn thermOut(P10_1);

static void readTemp()
{
    float refVoltage = thermOut.read() * 2.4; // Range of ADC 0-&gt;2*Vref
    float refCurrent = refVoltage  / 10000.0; // 10k Reference Resistor
    float thermVoltage = 3.3 - refVoltage;    // Assume supply voltage is 3.3v
    float thermResistance = thermVoltage / refCurrent; 
    float logrT = (float32_t)log((float64_t)thermResistance);

    /* Calculate temperature from the resistance of thermistor using Steinhart-Hart Equation */
    float stEqn = (float32_t)((0.0009032679) + ((0.000248772) * logrT) + 
                             ((2.041094E-07) * pow((float64)logrT, (float32)3)));

    float temperatureC = (float32_t)(((1.0 / stEqn) - 273.15)  + 0.5);
    temperatureF = (temperatureC * 9.0/5.0) + 32;
}
</pre>
<h1>Fix blinkThread.cpp</h1>
<p>Now edit the blinkThread.cpp to remove the test code from Lesson 03:</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();
        ThisThread::sleep_for(500);

    }
}
</pre>
<h1>Update main.cpp</h1>
<p>Then update main.cpp to start the new temperatureThread:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#include "mbed.h"
#include "blinkThread.h"
#include "displayThread.h"
#include "temperatureThread.h"

Thread blinkThreadHandle;
Thread displayThreadHandle;
Thread temperatureThreadHandle;

int main()
{

    printf("Started System\n");

    blinkThreadHandle.start(blinkThread);
    displayThreadHandle.start(displayThread);
    temperatureThreadHandle.start(temperatureThread);

}
</pre>
<h1>Build, Program and Test</h1>
<p>When you program the development kit you should be able to change the temperature by putting your finger on the thermistor:</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l4-temperature-thread/img_1163/" rel="attachment wp-att-8210"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/IMG_1163-768x1024.jpg" alt="" class="alignnone size-large wp-image-8210" width="768" height="1024" srcset="https://iotexpert.com/wp-content/uploads/2019/12/IMG_1163-768x1024.jpg 768w, https://iotexpert.com/wp-content/uploads/2019/12/IMG_1163-600x800.jpg 600w, https://iotexpert.com/wp-content/uploads/2019/12/IMG_1163-225x300.jpg 225w, https://iotexpert.com/wp-content/uploads/2019/12/IMG_1163-scaled.jpg 1920w" sizes="auto, (max-width: 768px) 100vw, 768px" /></a></p>
<p>And your terminal should look something like this:</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l4-temperature-thread/screen-shot-2019-12-07-at-5-11-25-pm/" rel="attachment wp-att-8075"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.11.25-PM-1024x298.png" alt="" class="alignnone size-large wp-image-8075" width="1024" height="298" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.11.25-PM-1024x298.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.11.25-PM-600x174.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.11.25-PM-300x87.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.11.25-PM-768x223.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.11.25-PM.png 1362w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l4-temperature-thread/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Mouser PSoC 6 WiFi/BT MBED: L6 WiFi &#038; NTP Thread</title>
		<link>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l6-wifi-ntp-thread/</link>
					<comments>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l6-wifi-ntp-thread/#comments</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Mon, 09 Dec 2019 17:04:20 +0000</pubDate>
				<category><![CDATA[Mouser PSoC 6 WiFi/BT MBED]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=8002</guid>

					<description><![CDATA[Summary I don’t know about you guys, but it annoys me every time I see that the clock isn’t set.  In this lesson we will start the IoT-ifying of this system by attaching it to WiFi and getting the network time. Inside of the PSoC is a RealTime clock that is driven by the crystal [&#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>I don’t know about you guys, but it annoys me every time I see that the clock isn’t set.  In this lesson we will start the IoT-ifying of this system by attaching it to WiFi and getting the network time.</p>
<p><a href="https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l6-wifi-ntp-thread/lesson6/"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/lesson6-1024x651.png" alt="" class="alignnone wp-image-8031 size-large" width="1024" height="651" srcset="https://iotexpert.com/wp-content/uploads/2019/12/lesson6-1024x651.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/lesson6-600x381.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/lesson6-300x191.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/lesson6-768x488.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/lesson6.png 1662w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Inside of the PSoC is a RealTime clock that is driven by the crystal oscillator on the board.  However, &#8220;What time is it?&#8221;  turns out to be a pretty simple question to answer if you are attached to the network.  You find out using an NTP server.  This lesson will attach to WiFi, and then every 5 minutes go get the UTC time from an NTP server.</p>
<p>To implement this I will</p>
<ol>
<li>Import lesson05</li>
<li>Add the NTP Server Library</li>
<li>Create &amp; Code ntpThread.h</li>
<li>Create &amp; Code ntpThread.cpp</li>
<li>Update main.cpp</li>
<li>Build, Program and Test</li>
</ol>
<h1>Import lesson05</h1>
<p>First import the Lesson 05 to create a new project.</p>
<p>https://github.com/iotexpert/mouser-mbed-05.git</p>
<h1><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l6-wifi-ntp-thread/screen-shot-2019-12-07-at-6-56-29-pm/" rel="attachment wp-att-8095"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.56.29-PM.png" alt="" class="alignnone size-full wp-image-8095" width="898" height="612" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.56.29-PM.png 898w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.56.29-PM-600x409.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.56.29-PM-300x204.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.56.29-PM-768x523.png 768w" sizes="auto, (max-width: 898px) 100vw, 898px" /></a></h1>
<h1>Add the NTP Server Library</h1>
<p>For this lesson I will use a library that knows how to talk to an NTP server using a TCP socket.  To get this library click on the libraries tab and press &#8220;+&#8221;</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-6-58-23-pm/" rel="attachment wp-att-8096"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.58.23-PM-1024x191.png" alt="" class="alignnone size-large wp-image-8096" width="1024" height="191" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.58.23-PM-1024x191.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.58.23-PM-600x112.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.58.23-PM-300x56.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.58.23-PM-768x143.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Now provide the path to the library.</p>
<p>https://github.com/ARMmbed/ntp-client</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-6-58-32-pm/" rel="attachment wp-att-8097"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.58.32-PM.png" alt="" class="alignnone size-large wp-image-8097" width="808" height="558" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.58.32-PM.png 808w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.58.32-PM-600x414.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.58.32-PM-300x207.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.58.32-PM-768x530.png 768w" sizes="auto, (max-width: 808px) 100vw, 808px" /></a></p>
<p>Use the master branch:</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-6-58-42-pm/" rel="attachment wp-att-8098"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.58.42-PM.png" alt="" class="alignnone size-large wp-image-8098" width="796" height="390" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.58.42-PM.png 796w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.58.42-PM-600x294.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.58.42-PM-300x147.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.58.42-PM-768x376.png 768w" sizes="auto, (max-width: 796px) 100vw, 796px" /></a></p>
<h1>Create &amp; Code ntpThread.h</h1>
<p>As always I am going to run the NTP Client in a thread.  This thread will be called “ntpThread”:</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-6-59-15-pm/" rel="attachment wp-att-8099"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.59.15-PM.png" alt="" class="alignnone size-large wp-image-8099" width="806" height="312" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.59.15-PM.png 806w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.59.15-PM-600x232.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.59.15-PM-300x116.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.59.15-PM-768x297.png 768w" sizes="auto, (max-width: 806px) 100vw, 806px" /></a></p>
<p>There is nothing to this but the function definition:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#ifndef NTP_THREAD_H
#define NTP_THREAD_H
void ntpThread();

#endif
</pre>
<h1>Create &amp; Code ntpThread.cpp</h1>
<p>Next create the actual thread code:</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-6-59-35-pm/" rel="attachment wp-att-8100"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.59.35-PM.png" alt="" class="alignnone size-large wp-image-8100" width="802" height="304" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.59.35-PM.png 802w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.59.35-PM-600x227.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.59.35-PM-300x114.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-6.59.35-PM-768x291.png 768w" sizes="auto, (max-width: 802px) 100vw, 802px" /></a></p>
<p>This code will need to include the ntp-client library.  Then I do something semi-evil by making an external reference to the WiFiInterface which will be declared in main.cpp.</p>
<p>Finally I will poll the NTP server every 5 minutes.  Notice that if the thing fails it tries again in 10 seconds.  When I get the time I write it into the RTC using the standard-C set_time function.  This function was connected by Cypress to the RTC hardware in the PSoC 6.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#include "mbed.h"
#include "ntp-client/NTPClient.h"

extern WiFiInterface *wifi;


void ntpThread()
{
    NTPClient ntpclient(wifi);
 
    uint32_t sleepTime = 1000 * 60 * 5 ; // 5 minutes
    while(1)
    {

        if(wifi-&gt;get_connection_status() == NSAPI_STATUS_GLOBAL_UP)
        {
            time_t timestamp = ntpclient.get_timestamp();
            if (timestamp &lt; 0) {
                sleepTime = 1000 * 10 ; // 10 seconds
            } 
            else 
            {
                set_time(timestamp);
                sleepTime = 1000 * 60 * 5 ; // 5 minutes

            }
        }
        ThisThread::sleep_for(sleepTime); // Goto the NTP server every 5 minutes
    }
}</pre>
<h1>Update main.cpp</h1>
<p>Now I need to update main.cpp.  This time is a little bit different since I need to setup a connection to the WiFi network.  I start by getting a pointer to the WiFi in the system and then connecting before I start all of the threads.</p>
<p>Notice that I hard-coded the SSID and Password.  I also try again until I have a WiFi connection.</p>
<p>The rest of main.cpp is normal.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#include "mbed.h"
#include "blinkThread.h"
#include "displayThread.h"
#include "temperatureThread.h"
#include "capsenseThread.h"
#include "ntpThread.h"

Thread blinkThreadHandle;
Thread displayThreadHandle;
Thread temperatureThreadHandle;
Thread capsenseThreadHandle;
Thread ntpThreadHandle;

WiFiInterface *wifi;

int main()
{

    printf("Started System\n");

    int ret;
    wifi = WiFiInterface::get_default_instance();

    do {
            ret = wifi-&gt;connect("CYFI_IOT_EXT", "cypresswicedwifi101", NSAPI_SECURITY_WPA_WPA2);
            if (ret != 0) {
            ThisThread::sleep_for(2000); // If for some reason it doesnt work wait 2s and try again
            }
    } while(ret !=0);


    ntpThreadHandle.start(ntpThread);
    blinkThreadHandle.start(blinkThread);
    displayThreadHandle.start(displayThread);
    temperatureThreadHandle.start(temperatureThread);
    capsenseThreadHandle.start(capsenseThread);
    
}</pre>
<h1>Build, Program and Test</h1>
<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>
<p>Now when I program this version, after 10 seconds or so, my time is updated&#8230; how cool is that?</p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l6-wifi-ntp-thread/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Mouser PSoC 6 WiFi/BT MBED: L5 CapSense Thread</title>
		<link>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l5-capsense-thread/</link>
					<comments>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l5-capsense-thread/#comments</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Mon, 09 Dec 2019 17:03:47 +0000</pubDate>
				<category><![CDATA[Mouser PSoC 6 WiFi/BT MBED]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=8001</guid>

					<description><![CDATA[Summary In Lesson 05 we will add a CapSense GUI to enable the user to change the setPoint of the thermostat. Specifically I will create a new Thread called “CapSense Thread” which will read the state of the CapSense Buttons and send messages to the temperatureThread. To implement this I will: Import Lesson 04 Add [&#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 Lesson 05 we will add a CapSense GUI to enable the user to change the setPoint of the thermostat.</p>
<p><a href="https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l5-capsense-thread/lesson5/"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/lesson5-1024x651.png" alt="" class="alignnone wp-image-8032 size-large" width="1024" height="651" srcset="https://iotexpert.com/wp-content/uploads/2019/12/lesson5-1024x651.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/lesson5-600x381.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/lesson5-300x191.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/lesson5-768x488.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/lesson5.png 1662w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Specifically I will create a new Thread called “CapSense Thread” which will read the state of the CapSense Buttons and send messages to the temperatureThread.</p>
<p>To implement this I will:</p>
<ol>
<li>Import Lesson 04</li>
<li>Add the Cypress CapSense library</li>
<li>Run the CapsSense configurator</li>
<li>Create and code capsenseThread.h</li>
<li>Create and code capsenseThread.cpp</li>
<li>Update main.cpp</li>
<li>Build, Program and Test</li>
</ol>
<h1>Import Lesson 04</h1>
<p>First import Lesson 04 and call your new project “mouser-mbed-05”</p>
<p>https://github.com/iotexpert/mouser-mbed-04.git</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l5-capsense-thread/screen-shot-2019-12-07-at-5-27-02-pm/" rel="attachment wp-att-8082"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.27.02-PM.png" alt="" class="alignnone size-full wp-image-8082" width="898" height="610" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.27.02-PM.png 898w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.27.02-PM-600x408.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.27.02-PM-300x204.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.27.02-PM-768x522.png 768w" sizes="auto, (max-width: 898px) 100vw, 898px" /></a></p>
<h1>Add the Cypress CapSense library</h1>
<p>In order to use the CapSense library you will need to import it from the Cypress GitHub site.  To do this we will use the Mbed Studio Library manager.  Click on the “Libraries” tab. Then press the “+” button to add a new library.</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l5-capsense-thread/screen-shot-2019-12-07-at-5-28-41-pm/" rel="attachment wp-att-8085"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.28.41-PM-1024x202.png" alt="" class="alignnone size-large wp-image-8085" width="1024" height="202" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.28.41-PM-1024x202.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.28.41-PM-600x118.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.28.41-PM-300x59.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.28.41-PM-768x151.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.28.41-PM.png 1582w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Give the Library manager the URL to the Cypress CapSense library:</p>
<p>https://github.com/cypresssemiconductorco/capsense.git</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l5-capsense-thread/screen-shot-2019-12-07-at-5-29-26-pm/" rel="attachment wp-att-8086"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.29.26-PM.png" alt="" class="alignnone size-large wp-image-8086" width="806" height="564" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.29.26-PM.png 806w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.29.26-PM-600x420.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.29.26-PM-300x210.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.29.26-PM-768x537.png 768w" sizes="auto, (max-width: 806px) 100vw, 806px" /></a></p>
<p>Specify that you want your library to point to the master branch.</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l5-capsense-thread/screen-shot-2019-12-07-at-5-29-36-pm/" rel="attachment wp-att-8087"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.29.36-PM.png" alt="" class="alignnone size-large wp-image-8087" width="794" height="384" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.29.36-PM.png 794w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.29.36-PM-600x290.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.29.36-PM-300x145.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.29.36-PM-768x371.png 768w" sizes="auto, (max-width: 794px) 100vw, 794px" /></a></p>
<p>Once that is done your library screen should look something like this.  When I took this screen shot I noticed that I was on the old version of mbed-os so I pressed the update button.</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l5-capsense-thread/screen-shot-2019-12-07-at-5-29-52-pm/" rel="attachment wp-att-8088"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.29.52-PM-1024x286.png" alt="" class="alignnone size-large wp-image-8088" width="1024" height="286" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.29.52-PM-1024x286.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.29.52-PM-600x168.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.29.52-PM-300x84.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.29.52-PM-768x214.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.29.52-PM.png 1576w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Now both libraries are at the latest version.</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l5-capsense-thread/screen-shot-2019-12-07-at-5-38-05-pm/" rel="attachment wp-att-8092"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.38.05-PM-1024x295.png" alt="" class="alignnone size-large wp-image-8092" width="1024" height="295" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.38.05-PM-1024x295.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.38.05-PM-600x173.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.38.05-PM-300x86.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.38.05-PM-768x221.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.38.05-PM.png 1576w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Run the CapSense Configurator</h1>
<p>First, lets run the CapSense configurator to look at the CapSense configuration.  You can find it in ModusToolbox/tools_2.0/capsense_configurator. Then use file&gt;open to open the Target&#8217;s CapSense configuration file from targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8PROTO_062_4343w/COMPONENT_BSP_DESIGN_MODUS/design.cycapsense.</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l5-capsense-thread/screen-shot-2019-12-08-at-2-55-42-pm/" rel="attachment wp-att-8198"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.55.42-PM-1024x723.png" alt="" class="alignnone size-large wp-image-8198" width="1024" height="723" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.55.42-PM-1024x723.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.55.42-PM-600x424.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.55.42-PM-300x212.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.55.42-PM-768x542.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.55.42-PM.png 1946w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Here is the advanced tab:</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l5-capsense-thread/screen-shot-2019-12-08-at-2-56-09-pm/" rel="attachment wp-att-8199"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.56.09-PM-1024x722.png" alt="" class="alignnone size-large wp-image-8199" width="1024" height="722" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.56.09-PM-1024x722.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.56.09-PM-600x423.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.56.09-PM-300x211.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.56.09-PM-768x541.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.56.09-PM.png 1944w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>The BSP/Target as delivered inside of Mbed OS does not have the generated source code required to run CapSense.  I could press save in the CapSense configurator GUI, but this would modify my version of Mbed OS.  I would rather add these files to the make project.  In order to get this code into my project I run the CapSense Configurator from the command line and tell to save the files locally.</p>
<ul>
<li><span>/Applications/ModusToolbox/tools_2.0/capsense-configurator/capsense-configurator-cli -c mbed-os/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT/COMPONENT_BSP_DESIGN_MODUS/design.cycapsense -o `pwd` -g</span></li>
</ul>
<p>Here is what the output looks like:</p>
<h1><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l5-capsense-thread/screen-shot-2019-12-07-at-5-36-07-pm/" rel="attachment wp-att-8090"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.36.07-PM-1024x268.png" alt="" class="alignnone size-large wp-image-8090" width="1024" height="268" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.36.07-PM-1024x268.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.36.07-PM-600x157.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.36.07-PM-300x79.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.36.07-PM-768x201.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.36.07-PM.png 1610w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a>Create and Code capsenseThread.h</h1>
<p>As with all of the other lessons, I want a new thread called “capsenseThread”  Start by making the “dot h”</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l5-capsense-thread/screen-shot-2019-12-07-at-5-27-43-pm/" rel="attachment wp-att-8083"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.27.43-PM.png" alt="" class="alignnone size-large wp-image-8083" width="800" height="296" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.27.43-PM.png 800w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.27.43-PM-600x222.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.27.43-PM-300x111.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.27.43-PM-768x284.png 768w" sizes="auto, (max-width: 800px) 100vw, 800px" /></a></p>
<p>This will only have the capsenseThread function.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#ifndef CAPSENSE_THREAD_H
#define CAPSENSE_THREAD_H

void capsenseThread(void);

#endif
</pre>
<h1>Create and code capsenseThread.cpp</h1>
<p>Now make the cpp file.</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l5-capsense-thread/screen-shot-2019-12-07-at-5-28-02-pm/" rel="attachment wp-att-8084"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.28.02-PM.png" alt="" class="alignnone size-large wp-image-8084" width="792" height="304" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.28.02-PM.png 792w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.28.02-PM-600x230.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.28.02-PM-300x115.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-5.28.02-PM-768x295.png 768w" sizes="auto, (max-width: 792px) 100vw, 792px" /></a></p>
<p>The Cypress CapSense system is a combination of hardware and firmware.  It works by:</p>
<ol>
<li>Initializing the Hardware</li>
<li>Initializing the Interrupt</li>
<li>Initializing the callback</li>
<li>Starting a scan (run the hardware block)</li>
<li>Processing the raw data when the scan is done and send a message</li>
<li>Starting another Scan</li>
</ol>
<p>I got the basis for this code by using the CapSense example project that Cypress has posted on GitHub. You can find that code example at:</p>
<p><a href="http://github.com/cypresssemiconductorco/mtb-example-psoc6-capsense-buttons-slider" target="_blank" rel="noopener noreferrer">github.com/cypresssemiconductorco/mtb-example-psoc6-capsense-buttons-slider</a></p>
<h2>Initializing the Hardware</h2>
<pre class="start-line:42 EnlighterJSRAW" data-enlighter-language="c">    /* Configure AMUX bus for CapSense */
    init_cycfg_routing();
    /* Configure PERI clocks for CapSense */
    Cy_SysClk_PeriphAssignDivider(PCLK_CSD_CLOCK, CYBSP_CSD_CLK_DIV_HW, CYBSP_CSD_CLK_DIV_NUM);
    Cy_SysClk_PeriphDisableDivider(CYBSP_CSD_CLK_DIV_HW, CYBSP_CSD_CLK_DIV_NUM);
    Cy_SysClk_PeriphSetDivider(CYBSP_CSD_CLK_DIV_HW, CYBSP_CSD_CLK_DIV_NUM, 0u);
    Cy_SysClk_PeriphEnableDivider(CYBSP_CSD_CLK_DIV_HW, CYBSP_CSD_CLK_DIV_NUM);
    

    /* Initialize the CSD HW block to the default state. */
    Cy_CapSense_Init(&amp;cy_capsense_context);
</pre>
<h2>Initializing the Interrupt</h2>
<p>This sets up the CapSense interrupt to work with the hardware block</p>
<pre class="start-line:54 EnlighterJSRAW" data-enlighter-language="c">    const cy_stc_sysint_t CapSense_ISR_cfg =
    {
        .intrSrc = CYBSP_CSD_IRQ,
        .intrPriority = 4u
    };
    /* Initialize CapSense interrupt */
    Cy_SysInt_Init(&amp;CapSense_ISR_cfg, &amp;CapSense_InterruptHandler);
    NVIC_ClearPendingIRQ(CapSense_ISR_cfg.intrSrc);
    NVIC_EnableIRQ(CapSense_ISR_cfg.intrSrc);
</pre>
<h2>Initializing the callback</h2>
<p>The callback is used to set the semaphore when the scan is done.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">    /* Initialize the CapSense firmware modules. */
    Cy_CapSense_Enable(&amp;cy_capsense_context);
    Cy_CapSense_RegisterCallback(CY_CAPSENSE_END_OF_SCAN_E, CapSenseEndOfScanCallback, &amp;cy_capsense_context);
</pre>
<h2>Starting a scan (run the hardware block)</h2>
<pre class="EnlighterJSRAW" data-enlighter-language="c">    Cy_CapSense_ScanAllWidgets(&amp;cy_capsense_context);  // Launch the initial scan   
</pre>
<h2>Processing Raw Data when the scan completes, and Send Message</h2>
<pre class="EnlighterJSRAW" data-enlighter-language="c">        if (CY_CAPSENSE_NOT_BUSY == Cy_CapSense_IsBusy(&amp;cy_capsense_context))
        {
            Cy_CapSense_ProcessAllWidgets(&amp;cy_capsense_context);
            uint32_t currBtn0Status = Cy_CapSense_IsSensorActive(CY_CAPSENSE_BUTTON0_WDGT_ID, CY_CAPSENSE_BUTTON0_SNS0_ID, &amp;cy_capsense_context);        
            uint32_t currBtn1Status = Cy_CapSense_IsSensorActive(CY_CAPSENSE_BUTTON1_WDGT_ID, CY_CAPSENSE_BUTTON1_SNS0_ID, &amp;cy_capsense_context);       

            if(currBtn0Status != prevBtn0Status &amp;&amp; currBtn0Status==1 )
            {
                tempSendDeltaSetpointF(-0.1);
            }
            prevBtn0Status = currBtn0Status;
    
            if(currBtn1Status != prevBtn1Status &amp;&amp; currBtn1Status == 1)
            {
                tempSendDeltaSetpointF(0.1);
            } 
            prevBtn1Status = currBtn1Status;

             
        } 
</pre>
<h2>Starting another Scan</h2>
<pre class="EnlighterJSRAW" data-enlighter-language="c">Cy_CapSense_ScanAllWidgets(&amp;cy_capsense_context);</pre>
<p>Here is the whole file:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#include "mbed.h"
#include "cy_pdl.h"
#include "cycfg_capsense.h"
#include "cycfg.h"
#include "temperatureThread.h"

static Semaphore capsense_sem;


/*****************************************************************************
* Function Name: CapSense_InterruptHandler()
******************************************************************************
* Summary:
*  Wrapper function for handling interrupts from CSD block.
*
*****************************************************************************/
static void CapSense_InterruptHandler(void)
{
    Cy_CapSense_InterruptHandler(CYBSP_CSD_HW, &amp;cy_capsense_context);
}


/*****************************************************************************
* Function Name: CapSenseEndOfScanCallback()
******************************************************************************
* Summary:
*  This function releases a semaphore to indicate end of a CapSense scan.
*
* Parameters:
*  cy_stc_active_scan_sns_t* : pointer to active sensor details.
*
*****************************************************************************/
static void CapSenseEndOfScanCallback(cy_stc_active_scan_sns_t * ptrActiveScan)
{
    capsense_sem.release();
}


void capsenseThread(void)
{

    /* Configure AMUX bus for CapSense */
    init_cycfg_routing();
    /* Configure PERI clocks for CapSense */
    Cy_SysClk_PeriphAssignDivider(PCLK_CSD_CLOCK, CYBSP_CSD_CLK_DIV_HW, CYBSP_CSD_CLK_DIV_NUM);
    Cy_SysClk_PeriphDisableDivider(CYBSP_CSD_CLK_DIV_HW, CYBSP_CSD_CLK_DIV_NUM);
    Cy_SysClk_PeriphSetDivider(CYBSP_CSD_CLK_DIV_HW, CYBSP_CSD_CLK_DIV_NUM, 0u);
    Cy_SysClk_PeriphEnableDivider(CYBSP_CSD_CLK_DIV_HW, CYBSP_CSD_CLK_DIV_NUM);
    

    /* Initialize the CSD HW block to the default state. */
    Cy_CapSense_Init(&amp;cy_capsense_context);

    const cy_stc_sysint_t CapSense_ISR_cfg =
    {
        .intrSrc = CYBSP_CSD_IRQ,
        .intrPriority = 4u
    };
    /* Initialize CapSense interrupt */
    Cy_SysInt_Init(&amp;CapSense_ISR_cfg, &amp;CapSense_InterruptHandler);
    NVIC_ClearPendingIRQ(CapSense_ISR_cfg.intrSrc);
    NVIC_EnableIRQ(CapSense_ISR_cfg.intrSrc);

    /* Initialize the CapSense firmware modules. */
    Cy_CapSense_Enable(&amp;cy_capsense_context);
    Cy_CapSense_RegisterCallback(CY_CAPSENSE_END_OF_SCAN_E, CapSenseEndOfScanCallback, &amp;cy_capsense_context);

    Cy_CapSense_ScanAllWidgets(&amp;cy_capsense_context);  // Launch the initial scan   
    
    uint32_t prevBtn0Status = 0u; 
    uint32_t prevBtn1Status = 0u;
     
    while(1)
    {

        capsense_sem.acquire();
        if (CY_CAPSENSE_NOT_BUSY == Cy_CapSense_IsBusy(&amp;cy_capsense_context))
        {
            Cy_CapSense_ProcessAllWidgets(&amp;cy_capsense_context);
            uint32_t currBtn0Status = Cy_CapSense_IsSensorActive(CY_CAPSENSE_BUTTON0_WDGT_ID, CY_CAPSENSE_BUTTON0_SNS0_ID, &amp;cy_capsense_context);        
            uint32_t currBtn1Status = Cy_CapSense_IsSensorActive(CY_CAPSENSE_BUTTON1_WDGT_ID, CY_CAPSENSE_BUTTON1_SNS0_ID, &amp;cy_capsense_context);       

            if(currBtn0Status != prevBtn0Status &amp;&amp; currBtn0Status==1 )
            {
                tempSendDeltaSetpointF(-0.1);
            }
            prevBtn0Status = currBtn0Status;
    
            if(currBtn1Status != prevBtn1Status &amp;&amp; currBtn1Status == 1)
            {
                tempSendDeltaSetpointF(0.1);
            } 
            prevBtn1Status = currBtn1Status;

            Cy_CapSense_ScanAllWidgets(&amp;cy_capsense_context);  
        } 

    }
}
</pre>
<h1>Update main.cpp</h1>
<p>Inside of the main.cpp I will make the usual changes to turn on the CapSense thread.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#include "mbed.h"
#include "blinkThread.h"
#include "displayThread.h"
#include "temperatureThread.h"
#include "capsenseThread.h"

Thread blinkThreadHandle;
Thread displayThreadHandle;
Thread temperatureThreadHandle;
Thread capsenseThreadHandle;

int main()
{

    printf("Started System\n");

    blinkThreadHandle.start(blinkThread);
    displayThreadHandle.start(displayThread);
    temperatureThreadHandle.start(temperatureThread);
    capsenseThreadHandle.start(capsenseThread);

}
</pre>
<h1>Build, Program and Test</h1>
<p>When I build, program and test I can see that by pressing the two CapSense Buttons I can raise and lower the setPoint.</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l5-capsense-thread/img_1166-2/" rel="attachment wp-att-8214"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/IMG_1166-2-1024x741.jpg" alt="" class="alignnone size-large wp-image-8214" width="1024" height="741" srcset="https://iotexpert.com/wp-content/uploads/2019/12/IMG_1166-2-1024x741.jpg 1024w, https://iotexpert.com/wp-content/uploads/2019/12/IMG_1166-2-600x434.jpg 600w, https://iotexpert.com/wp-content/uploads/2019/12/IMG_1166-2-300x217.jpg 300w, https://iotexpert.com/wp-content/uploads/2019/12/IMG_1166-2-768x556.jpg 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l5-capsense-thread/feed/</wfw:commentRss>
			<slash:comments>8</slash:comments>
		
		
			</item>
		<item>
		<title>Mouser PSoC 6 WiFi/BT MBED: L7 The CY8CKIT-062-WiFi-BT</title>
		<link>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l7-the-cy8ckit-062-wifi-bt/</link>
					<comments>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l7-the-cy8ckit-062-wifi-bt/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Mon, 09 Dec 2019 17:03:33 +0000</pubDate>
				<category><![CDATA[Mouser PSoC 6 WiFi/BT MBED]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=8003</guid>

					<description><![CDATA[Summary This weekend as I was getting ready for the workshop, my son, Nicholas, was making fun of me for my user interface.  To fix this I decided to show how you could move platforms.  Specifically to the CY8CKIT-062-WiFi-BT which you can buy from mouser.com You could literally just change the target and things would [&#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 weekend as I was getting ready for the workshop, my son, Nicholas, was making fun of me for my user interface.  To fix this I decided to show how you could move platforms.  Specifically to the <a href="https://www.cypress.com/documentation/development-kitsboards/psoc-6-wifi-bt-pioneer-kit-cy8ckit-062-wifi-bt" target="_blank" rel="noopener noreferrer">CY8CKIT-062-WiFi-BT </a>which you can buy from <a href="https://www.mouser.com/new/cypress-semiconductor/cypress-psoc6-wifi-bt-pioneer-kit/" target="_blank" rel="noopener noreferrer">mouser.com</a></p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l7-the-cy8ckit-062-wifi-bt/cy8ckit-062_family_pic_700x600/" rel="attachment wp-att-8189"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/CY8CKIT-062_Family_Pic_700x600.jpg" alt="" width="450" height="385" class="alignnone size-full wp-image-8189" srcset="https://iotexpert.com/wp-content/uploads/2019/12/CY8CKIT-062_Family_Pic_700x600.jpg 450w, https://iotexpert.com/wp-content/uploads/2019/12/CY8CKIT-062_Family_Pic_700x600-300x257.jpg 300w" sizes="auto, (max-width: 450px) 100vw, 450px" /></a></p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l7-the-cy8ckit-062-wifi-bt/lesson7-3/" rel="attachment wp-att-8104"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/lesson7-2-1024x651.png" alt="" width="1024" height="651" class="alignnone size-large wp-image-8104" srcset="https://iotexpert.com/wp-content/uploads/2019/12/lesson7-2-1024x651.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/lesson7-2-600x381.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/lesson7-2-300x191.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/lesson7-2-768x488.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/lesson7-2.png 1662w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>You could literally just change the target and things would work&#8230; almost.  The one exception is that this development kit doesn&#8217;t have a thermistor.  So, I soldered a different kind of temperature sensor, called a TMP36, onto the kit which means I have to make a few small code updates to the temperatureThread.</p>
<p>In addition to changing to the TMP36 I will also use the TFT as a display for the system, so I need to modify the displayThread.</p>
<p>One of the major points that I wanted to make with this lesson is that if you design your code correctly, a change like this isn’t very hard.</p>
<p>To implement this I will:</p>
<ol>
<li>Provide a TMP36 Temperature Sensor Tutorial</li>
<li>Modify the CY8CKIT-028-TFT</li>
<li>Import Lesson06</li>
<li>Update temperatureThread.cpp</li>
<li>Build, Program and Test</li>
<li>Add Segger emWin Library</li>
<li>Add IoTExpert CY8CKIT-028-TFT configuration</li>
<li>Update mbed_app.json to include driver</li>
<li>Update displayThread.cpp</li>
<li>Build, Program and Test</li>
</ol>
<h1>TMP36 Temperature Sensor</h1>
<p>The TMP36 is a single wire temperature sensor that gives you a voltage that is directly proportional to the temperature.  Specifically, it is 10mV per degree C.</p>
<p>The Analog Devices TMP36 that I am using I bought <a href="https://www.mouser.com/ProductDetail/Analog-Devices/TMP36GT9Z?qs=sGAEpiMZZMv9Q1JI0Mo%2FtZYNPIqRJ81F" target="_blank" rel="noopener noreferrer">here</a> from mouser.com.  It looks like a little 3-wire transistor looking thing.</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l7-the-cy8ckit-062-wifi-bt/adi_to_92_3/" rel="attachment wp-att-8184"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/ADI_TO_92_3.jpg" alt="" width="300" height="300" class="alignnone size-full wp-image-8184" srcset="https://iotexpert.com/wp-content/uploads/2019/12/ADI_TO_92_3.jpg 300w, https://iotexpert.com/wp-content/uploads/2019/12/ADI_TO_92_3-100x100.jpg 100w, https://iotexpert.com/wp-content/uploads/2019/12/ADI_TO_92_3-150x150.jpg 150w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Here is a snapshot from the data sheet of the temperature voltage response</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l7-the-cy8ckit-062-wifi-bt/screen-shot-2019-12-08-at-2-11-24-pm/" rel="attachment wp-att-8185"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.11.24-PM-1024x712.png" alt="" width="1024" height="712" class="alignnone size-large wp-image-8185" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.11.24-PM-1024x712.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.11.24-PM-600x417.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.11.24-PM-300x209.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.11.24-PM-768x534.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.11.24-PM.png 1472w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Yes I know that I am a digital guy, but for just three wires, signal, ground and power, it sure looks like there is a lot going on in the package.</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l7-the-cy8ckit-062-wifi-bt/screen-shot-2019-12-08-at-2-13-25-pm/" rel="attachment wp-att-8186"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.13.25-PM-1024x821.png" alt="" width="1024" height="821" class="alignnone size-large wp-image-8186" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.13.25-PM-1024x821.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.13.25-PM-600x481.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.13.25-PM-300x241.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.13.25-PM-768x616.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.13.25-PM.png 1454w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>The <a href="https://www.mouser.com/datasheet/2/609/TMP35_36_37-1504323.pdf" target="_blank" rel="noopener noreferrer">data sheet</a> (which is actually really interesting)  gives you the parameters to make the linear equation for temperature</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l7-the-cy8ckit-062-wifi-bt/screen-shot-2019-12-08-at-2-15-12-pm/" rel="attachment wp-att-8187"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.15.12-PM-1024x354.png" alt="" width="1024" height="354" class="alignnone size-large wp-image-8187" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.15.12-PM-1024x354.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.15.12-PM-600x208.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.15.12-PM-300x104.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.15.12-PM-768x266.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-2.15.12-PM.png 1376w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>To calculate the temperature you just calculate:</p>
<p>T = (degree C/10mV) * V &#8211; 50 degree C</p>
<p>Here is the function to read the temperature:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">static AnalogIn tmp36(A5);
static void readTemp()
{
    float volts;
    
    volts = tmp36.read() * 2.4;
    float temperatureC = 1/.01 * volts - 50.0;
    temperatureF = (temperatureC * 9.0/5.0) + 32;
}</pre>
<h1>Modify the CY8CKIT-028-TFT</h1>
<p>Start this process by attaching the TMP36.  On the back of the CY8CKIT-028-TFT I solder three wires onto the temperature sensor.  One to 3.3v, one to ground and one to A5.  Here is the picture of my ugly ugly solder job.  Yes, that is duct-tape holding it onto the back of the shield.  And yes that is a prototype sticker.</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l7-the-cy8ckit-062-wifi-bt/img_1159/" rel="attachment wp-att-8115"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/IMG_1159-1024x846.jpg" alt="" width="1024" height="846" class="alignnone size-large wp-image-8115" srcset="https://iotexpert.com/wp-content/uploads/2019/12/IMG_1159-1024x846.jpg 1024w, https://iotexpert.com/wp-content/uploads/2019/12/IMG_1159-600x496.jpg 600w, https://iotexpert.com/wp-content/uploads/2019/12/IMG_1159-300x248.jpg 300w, https://iotexpert.com/wp-content/uploads/2019/12/IMG_1159-768x634.jpg 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>I also remove the PDM microphone which is also attached to A5 (I’m not sure that it would cause a problem&#8230; but better safe than sorry)</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l7-the-cy8ckit-062-wifi-bt/img_1150/" rel="attachment wp-att-8191"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/IMG_1150-768x1024.jpg" alt="" width="768" height="1024" class="alignnone size-large wp-image-8191" srcset="https://iotexpert.com/wp-content/uploads/2019/12/IMG_1150-768x1024.jpg 768w, https://iotexpert.com/wp-content/uploads/2019/12/IMG_1150-600x800.jpg 600w, https://iotexpert.com/wp-content/uploads/2019/12/IMG_1150-225x300.jpg 225w, https://iotexpert.com/wp-content/uploads/2019/12/IMG_1150-scaled.jpg 1920w" sizes="auto, (max-width: 768px) 100vw, 768px" /></a></p>
<h1>Import Lesson06</h1>
<p>Now, fix the code.  As always, start by importing the previous lesson.</p>
<p>https://github.com/iotexpert/mouser-mbed-06.git</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l7-the-cy8ckit-062-wifi-bt/screen-shot-2019-12-07-at-7-53-58-pm/" rel="attachment wp-att-8117"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.53.58-PM.png" alt="" width="890" height="612" class="alignnone size-full wp-image-8117" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.53.58-PM.png 890w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.53.58-PM-600x413.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.53.58-PM-300x206.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.53.58-PM-768x528.png 768w" sizes="auto, (max-width: 890px) 100vw, 890px" /></a></p>
<h1>Update temperatureThread.cpp</h1>
<p>In order to switch between the thermistor and the TMP36 I create two #defines based on the target that is currently active.  This is cool because the Mbed OS creates these #defines automatically.</p>
<pre class="start-line:5 EnlighterJSRAW" data-enlighter-language="c"">#ifdef TARGET_CY8CPROTO_062_4343W
#define THERMISTOR
#endif

#ifdef TARGET_CY8CKIT_062_WIFI_BT
#define TMP36
#endif</pre>
<p>There are a bunch of ways that could have been done, including with the Mbed configuration system which you control with the mbed_app.json.  But this was expedient.</p>
<p>Next, I create the code to measure the temperature using the AnalogIn object. Notice that it is connected to the Arduino A5 pin. Also notice that when the TMP36 is active I have a different readTemp function so I don’t need to change anything else to get the temperature.</p>
<pre class="start-line:125 EnlighterJSRAW" data-enlighter-language="c"">#ifdef TMP36
static AnalogIn tmp36(A5);
static void readTemp()
{
    float volts;
    
    volts = tmp36.read() * 2.4;
    float temperatureC = 1/.01 * volts - 50.0; // from the data sheet
    temperatureF = (temperatureC * 9.0/5.0) + 32; // conver to F
}
#endif
</pre>
<p>Then I update the thermistor readTemp function with the THERMISTOR #define</p>
<pre class="start-line:103 EnlighterJSRAW" data-enlighter-language="c"">#ifdef THERMISTOR
static DigitalOut thermVDD(P10_3,1);
static DigitalOut thermGND(P10_0,0);
static AnalogIn thermOut(P10_1);

static void readTemp()
{
    float refVoltage = thermOut.read() * 2.4; // Range of ADC 0-&gt;2*Vref
    float refCurrent = refVoltage  / 10000.0; // 10k Reference Resistor
    float thermVoltage = 3.3 - refVoltage;    // Assume supply voltage is 3.3v
    float thermResistance = thermVoltage / refCurrent; 
    float logrT = (float32_t)log((float64_t)thermResistance);

    /* Calculate temperature from the resistance of thermistor using Steinhart-Hart Equation */
    float stEqn = (float32_t)((0.0009032679) + ((0.000248772) * logrT) + 
                             ((2.041094E-07) * pow((float64)logrT, (float32)3)));

    float temperatureC = (float32_t)(((1.0 / stEqn) - 273.15)  + 0.5);
    temperatureF = (temperatureC * 9.0/5.0) + 32;
}
#endif</pre>
<p>Here is the whole file:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c" ">#include "mbed.h"
#include "temperatureThread.h"
#include "displayThread.h"


#ifdef TARGET_CY8CPROTO_062_4343W
#define THERMISTOR
#endif

#ifdef TARGET_CY8CKIT_062_WIFI_BT
#define TMP36
#endif


static float temperatureF;
static float setPoint = 75.0;

static void readTemp();

typedef enum {
    CMD_setPointDelta,
    CMD_setPoint,

} command_t;


typedef struct {
    command_t cmd;
    float    value;   /* AD result of measured voltage */
} msg_t;


static Queue&lt;msg_t, 32&gt; queue;
static MemoryPool&lt;msg_t, 16&gt; mpool;

void tempSendDeltaSetpointF(float delta)
{
    msg_t *message = mpool.alloc();
    if(message)
    {
        message-&gt;cmd = CMD_setPointDelta;
        message-&gt;value = delta;
        queue.put(message);
    }
}

void tempSendUpdateCurrentSetPointF(float setPoint)
{
    msg_t *message = mpool.alloc();
    if(message)
    {
        message-&gt;cmd = CMD_setPoint;
        message-&gt;value = setPoint;
        queue.put(message);
    }
}

void temperatureThread()
{

    char buffer[128];
    displaySendUpdateTemp(temperatureF);
    displaySendUpdateSetPoint(setPoint);
    
    while(1)
    {
        osEvent evt = queue.get(200);
        if (evt.status == osEventMessage) {
            msg_t *message = (msg_t*)evt.value.p;
            switch(message-&gt;cmd)
            {
                case CMD_setPointDelta:
                    setPoint += message-&gt;value;
                    displaySendUpdateSetPoint(setPoint);
                break;
                case CMD_setPoint:
                    setPoint = message-&gt;value;
                    displaySendUpdateSetPoint(setPoint);
                break;

            }
            mpool.free(message);

        }
        else
        {
            readTemp();

            // Control the HVAC system with +- 0.5 degree of Hystersis
            if(temperatureF &lt; setPoint - 0.5)
                displaySendUpdateMode(-1.0);
            else if (temperatureF &gt; setPoint + 0.5)
                displaySendUpdateMode(1.0);
            else
                displaySendUpdateMode(0.0);

            displaySendUpdateTemp(temperatureF);
        
        }
    }

}


#ifdef THERMISTOR
static DigitalOut thermVDD(P10_3,1);
static DigitalOut thermGND(P10_0,0);
static AnalogIn thermOut(P10_1);

static void readTemp()
{
    float refVoltage = thermOut.read() * 2.4; // Range of ADC 0-&gt;2*Vref
    float refCurrent = refVoltage  / 10000.0; // 10k Reference Resistor
    float thermVoltage = 3.3 - refVoltage;    // Assume supply voltage is 3.3v
    float thermResistance = thermVoltage / refCurrent; 
    float logrT = (float32_t)log((float64_t)thermResistance);

    /* Calculate temperature from the resistance of thermistor using Steinhart-Hart Equation */
    float stEqn = (float32_t)((0.0009032679) + ((0.000248772) * logrT) + 
                             ((2.041094E-07) * pow((float64)logrT, (float32)3)));

    float temperatureC = (float32_t)(((1.0 / stEqn) - 273.15)  + 0.5);
    temperatureF = (temperatureC * 9.0/5.0) + 32;
}
#endif

#ifdef TMP36
static AnalogIn tmp36(A5);
static void readTemp()
{
    float volts;
    
    volts = tmp36.read() * 2.4;
    float temperatureC = 1/.01 * volts - 50.0;
    temperatureF = (temperatureC * 9.0/5.0) + 32;
}
#endif
</pre>
<h1>Build, Program and Test</h1>
<p>With that little update I can now build, program and test. Notice that my display is still working&#8230; and I can change the temperature by holding the TMP36 between my fingers.</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l7-the-cy8ckit-062-wifi-bt/screen-shot-2019-12-07-at-7-34-40-pm/" rel="attachment wp-att-8106"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.34.40-PM-1024x136.png" alt="" width="1024" height="136" class="alignnone size-large wp-image-8106" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.34.40-PM-1024x136.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.34.40-PM-600x80.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.34.40-PM-300x40.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.34.40-PM-768x102.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Add Segger emWin Library</h1>
<p>But, I haven’t really addressed Nicholas’ complaint, the GUI.  To do this I am going to use the Segger emWin library to control the TFT display.  Go to the library manager and add the library.</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l7-the-cy8ckit-062-wifi-bt/screen-shot-2019-12-07-at-7-36-22-pm/" rel="attachment wp-att-8107"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.36.22-PM-1024x242.png" alt="" width="1024" height="242" class="alignnone size-large wp-image-8107" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.36.22-PM-1024x242.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.36.22-PM-600x142.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.36.22-PM-300x71.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.36.22-PM-768x182.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>https://github.com/cypresssemiconductorco/emwin.git</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l7-the-cy8ckit-062-wifi-bt/screen-shot-2019-12-07-at-7-37-51-pm/" rel="attachment wp-att-8109"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.37.51-PM.png" alt="" width="788" height="560" class="alignnone size-large wp-image-8109" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.37.51-PM.png 788w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.37.51-PM-600x426.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.37.51-PM-300x213.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.37.51-PM-768x546.png 768w" sizes="auto, (max-width: 788px) 100vw, 788px" /></a></p>
<p>Use the master branch:</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l7-the-cy8ckit-062-wifi-bt/screen-shot-2019-12-07-at-7-38-00-pm/" rel="attachment wp-att-8110"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.38.00-PM.png" alt="" width="784" height="392" class="alignnone size-large wp-image-8110" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.38.00-PM.png 784w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.38.00-PM-600x300.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.38.00-PM-300x150.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.38.00-PM-768x384.png 768w" sizes="auto, (max-width: 784px) 100vw, 784px" /></a></p>
<h1>Add IoTExpert CY8CKIT-028-TFT configuration</h1>
<p>The emWin library doesn&#8217;t know anything about how the TFT is attached.  So, I created a driver library which you can use for all of the Cypress development kits.</p>
<p>https://github.com/iotexpert/mbed-os-emwin-st7789v.git</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l7-the-cy8ckit-062-wifi-bt/screen-shot-2019-12-07-at-7-39-00-pm/" rel="attachment wp-att-8111"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.39.00-PM.png" alt="" width="802" height="564" class="alignnone size-large wp-image-8111" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.39.00-PM.png 802w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.39.00-PM-600x422.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.39.00-PM-300x211.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.39.00-PM-768x540.png 768w" sizes="auto, (max-width: 802px) 100vw, 802px" /></a></p>
<p>Use the master branch:</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l7-the-cy8ckit-062-wifi-bt/screen-shot-2019-12-07-at-7-39-09-pm/" rel="attachment wp-att-8112"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.39.09-PM.png" alt="" width="798" height="390" class="alignnone size-large wp-image-8112" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.39.09-PM.png 798w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.39.09-PM-600x293.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.39.09-PM-300x147.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.39.09-PM-768x375.png 768w" sizes="auto, (max-width: 798px) 100vw, 798px" /></a></p>
<p>Now your libraries should look like this.</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l7-the-cy8ckit-062-wifi-bt/screen-shot-2019-12-07-at-7-39-25-pm/" rel="attachment wp-att-8113"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.39.25-PM-1024x353.png" alt="" width="1024" height="353" class="alignnone size-large wp-image-8113" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.39.25-PM-1024x353.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.39.25-PM-600x207.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.39.25-PM-300x103.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-7.39.25-PM-768x265.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Update mbed_app.json to include emWin Driver</h1>
<p>In order to use this driver you need to tell Mbed OS to add the correct archive file.  To do this update mbed_app.json</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c" ">{
    "target_overrides": {
        "*": {
            "target.components_add": ["EMWIN_OSNTS"],
            "platform.stdio-baud-rate": 115200
        }
    }
}
</pre>
<h1>Update displayThread.cpp</h1>
<p>Finally update the displayThread.  Start by adding the include for the Segger library.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#ifdef TARGET_CY8CKIT_062_WIFI_BT
#include "GUI.h"
#endif
</pre>
<p>Then update the displayAtXY function to also print on the display.  By doing it here I don’t have to change anything else in the code because this is the only function that draws on the screen.</p>
<pre class="start-line:71 EnlighterJSRAW" data-enlighter-language="c"">static void displayAtXY(int x, int y,char *buffer)
{
    #ifdef TARGET_CY8CKIT_062_WIFI_BT
    GUI_SetTextAlign(GUI_TA_LEFT);
    GUI_DispStringAt(buffer,(x-1)*8,(y-1)*16); // 8x16 font
    #endif
    // row column
    printf("\033[%d;%dH%s",y,x,buffer);
    fflush(stdout);
}</pre>
<p>Update the main thread to initialize the display when the thread starts.</p>
<pre class="start-line:85 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);

    #ifdef TARGET_CY8CKIT_062_WIFI_BT
        GUI_Init();
        GUI_SetColor(GUI_WHITE);
        GUI_SetBkColor(GUI_BLACK);
        GUI_SetFont(GUI_FONT_8X16_1);
    #endif</pre>
<h1>Build, Program and Test</h1>
<p>When you program, now you should have a TFT display.  Happy Nicholas?</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l7-the-cy8ckit-062-wifi-bt/img_1156/" rel="attachment wp-att-8116"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/IMG_1156-1024x591.jpg" alt="" width="1024" height="591" class="alignnone size-large wp-image-8116" srcset="https://iotexpert.com/wp-content/uploads/2019/12/IMG_1156-1024x591.jpg 1024w, https://iotexpert.com/wp-content/uploads/2019/12/IMG_1156-600x346.jpg 600w, https://iotexpert.com/wp-content/uploads/2019/12/IMG_1156-300x173.jpg 300w, https://iotexpert.com/wp-content/uploads/2019/12/IMG_1156-768x443.jpg 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l7-the-cy8ckit-062-wifi-bt/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Mouser PSoC 6 WiFi/BT MBED: L8 Amazon AWS MQTT Thread &#8211; Part1</title>
		<link>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l8-amazon-aws-mqtt-thread-part1/</link>
					<comments>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l8-amazon-aws-mqtt-thread-part1/#comments</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Mon, 09 Dec 2019 17:03:19 +0000</pubDate>
				<category><![CDATA[Mouser PSoC 6 WiFi/BT MBED]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=8004</guid>

					<description><![CDATA[Summary In this lesson we will plumb in the ability to talk to the Amazon Web Services MQTT broker.  Specifically to publish messages from the broker to change the setPoint of the thermostat. To implement this I will: Discuss MQTT Import Lesson 07 Add the Cypress AWS IoT Middleware Add the Cypress Connectivity Utilities Library [&#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 plumb in the ability to talk to the Amazon Web Services MQTT broker.  Specifically to publish messages from the broker to change the setPoint of the thermostat.</p>
<p><a href="https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l8-amazon-aws-mqtt-thread-part1/lesson8/"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/lesson8-1024x651.png" alt="" class="alignnone wp-image-8029 size-large" width="1024" height="651" srcset="https://iotexpert.com/wp-content/uploads/2019/12/lesson8-1024x651.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/lesson8-600x381.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/lesson8-300x191.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/lesson8-768x488.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/lesson8.png 1662w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>To implement this I will:</p>
<ol>
<li>Discuss MQTT</li>
<li>Import Lesson 07</li>
<li>Add the Cypress AWS IoT Middleware</li>
<li>Add the Cypress Connectivity Utilities Library</li>
<li>Create an AWS Policy, Thing, and Certificate</li>
<li>Modify the keys to &#8220;C&#8221; format</li>
<li>Create and Code awsThread.h</li>
<li>Create and Code awsThread.cpp</li>
<li>Update main.cpp</li>
<li>Build, Program and Test</li>
</ol>
<h1>MQTT</h1>
<p>There are five basic ideas that you need to understand when using <a href="https://en.m.wikipedia.org/wiki/MQTT" target="_blank" rel="noopener noreferrer">MQTT</a>.</p>
<ul>
<li>(Message) Broker</li>
<li>Topic</li>
<li>Subscriber</li>
<li>Publisher</li>
<li>Messages</li>
</ul>
<p>The Broker is a TCP/IP server sitting at the middle of an MQTT network.  It is responsible for receiving Messages from Publishers and forwarding them on to Subscribers.  A broker can run multiple simultaneous communication channels called Topics.</p>
<p>Topics are ad-hoc (application semantics) and are just a string of characters &#8230; like “setPoint” or “thing/setPoint”</p>
<p>Messages are just a string of bytes.  Typically formatted as JSON.  This is by convention and is not a requirement.</p>
<p>MQTT clients can be Publishers or Subscribers or both.</p>
<h1>Import Lesson 07</h1>
<p>Start by importing Lesson 07.</p>
<p>https://github.com/iotexpert/mouser-mbed-07.git</p>
<h1><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l8-amazon-aws-mqtt-thread-part1/screen-shot-2019-12-07-at-8-03-36-pm/" rel="attachment wp-att-8119"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.03.36-PM.png" alt="" class="alignnone size-full wp-image-8119" width="890" height="596" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.03.36-PM.png 890w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.03.36-PM-600x402.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.03.36-PM-300x201.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.03.36-PM-768x514.png 768w" sizes="auto, (max-width: 890px) 100vw, 890px" /></a><br />
Add the Cypress AWS IoT Middleware</h1>
<p>Cypress has built a library which will help you manage connections to AWS.  We call it the aws IoT middleware library.  Go to the library manager and add it:</p>
<ul>
<li>https://github.com/cypresssemiconductorco/aws-iot.git</li>
</ul>
<h1><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l8-amazon-aws-mqtt-thread-part1/screen-shot-2019-12-07-at-8-05-36-pm/" rel="attachment wp-att-8123"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.05.36-PM.png" alt="" class="alignnone size-large wp-image-8123" width="796" height="552" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.05.36-PM.png 796w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.05.36-PM-600x416.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.05.36-PM-300x208.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.05.36-PM-768x533.png 768w" sizes="auto, (max-width: 796px) 100vw, 796px" /></a></h1>
<p>Use the master branch:</p>
<h1><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l8-amazon-aws-mqtt-thread-part1/screen-shot-2019-12-07-at-8-05-46-pm/" rel="attachment wp-att-8124"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.05.46-PM.png" alt="" class="alignnone size-large wp-image-8124" width="794" height="400" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.05.46-PM.png 794w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.05.46-PM-600x302.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.05.46-PM-300x151.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.05.46-PM-768x387.png 768w" sizes="auto, (max-width: 794px) 100vw, 794px" /></a></h1>
<h1>Add the Cypress Connectivity Utilities Library</h1>
<p>The AWS IoT library needs to use another library of connectivity functions.  Add it:</p>
<ul>
<li>https://github.com/cypresssemiconductorco/connectivity-utilities.git</li>
</ul>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l8-amazon-aws-mqtt-thread-part1/screen-shot-2019-12-08-at-6-07-54-pm/" rel="attachment wp-att-8222"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.07.54-PM.png" alt="" class="alignnone size-full wp-image-8222" width="790" height="558" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.07.54-PM.png 790w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.07.54-PM-600x424.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.07.54-PM-300x212.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.07.54-PM-768x542.png 768w" sizes="auto, (max-width: 790px) 100vw, 790px" /></a></p>
<p>Select the master branch:</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l8-amazon-aws-mqtt-thread-part1/screen-shot-2019-12-08-at-6-08-05-pm/" rel="attachment wp-att-8223"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.08.05-PM.png" alt="" class="alignnone size-large wp-image-8223" width="798" height="378" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.08.05-PM.png 798w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.08.05-PM-600x284.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.08.05-PM-300x142.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.08.05-PM-768x364.png 768w" sizes="auto, (max-width: 798px) 100vw, 798px" /></a></p>
<h1>Create an AWS Policy, Thing, and Certificate</h1>
<p>In order to make a connection to AWS you need to have a policy attached to a certificate.  In addition it makes sense to have an AWS “Thing” to represent your system.</p>
<p>Start from the AWS Console and press &#8220;Secure-&gt;Policies&#8221;.  Then press &#8220;Create&#8221;</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l8-amazon-aws-mqtt-thread-part1/screen-shot-2019-12-08-at-6-21-18-pm/" rel="attachment wp-att-8229"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.21.18-PM-1024x421.png" alt="" class="alignnone size-large wp-image-8229" width="1024" height="421" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.21.18-PM-1024x421.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.21.18-PM-600x247.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.21.18-PM-300x123.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.21.18-PM-768x316.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Give your policy a name.  Add all &#8220;iot:*&#8221; and all resource and &#8220;allow&#8221;.  Then press &#8220;Create&#8221;:</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l8-amazon-aws-mqtt-thread-part1/screen-shot-2019-12-08-at-6-22-19-pm/" rel="attachment wp-att-8230"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.22.19-PM-1024x873.png" alt="" class="alignnone size-large wp-image-8230" width="1024" height="873" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.22.19-PM-1024x873.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.22.19-PM-600x511.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.22.19-PM-300x256.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.22.19-PM-768x654.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.22.19-PM.png 1988w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Once the policy is created you will see it in the catalog:</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l8-amazon-aws-mqtt-thread-part1/screen-shot-2019-12-08-at-6-22-30-pm/" rel="attachment wp-att-8231"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.22.30-PM-1024x567.png" alt="" class="alignnone size-large wp-image-8231" width="1024" height="567" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.22.30-PM-1024x567.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.22.30-PM-600x332.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.22.30-PM-300x166.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.22.30-PM-768x425.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.22.30-PM.png 2036w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Create a new Thing by clicking &#8220;Manage -&gt; Things&#8221;.  Then click &#8220;Create&#8221;&#8221;</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l8-amazon-aws-mqtt-thread-part1/screen-shot-2019-12-08-at-6-22-44-pm/" rel="attachment wp-att-8232"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.22.44-PM-1024x578.png" alt="" class="alignnone size-large wp-image-8232" width="1024" height="578" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.22.44-PM-1024x578.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.22.44-PM-600x339.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.22.44-PM-300x169.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.22.44-PM-768x434.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Press &#8220;Create a single thing&#8221;:</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l8-amazon-aws-mqtt-thread-part1/screen-shot-2019-12-08-at-6-26-32-pm/" rel="attachment wp-att-8234"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.26.32-PM-1024x613.png" alt="" class="alignnone size-large wp-image-8234" width="1024" height="613" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.26.32-PM-1024x613.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.26.32-PM-600x359.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.26.32-PM-300x180.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.26.32-PM-768x460.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>First give your thing a name (in this case mouser) then click &#8220;Next&#8221;:</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l8-amazon-aws-mqtt-thread-part1/screen-shot-2019-12-08-at-6-26-54-pm/" rel="attachment wp-att-8235"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.26.54-PM-1024x1004.png" alt="" class="alignnone size-large wp-image-8235" width="1024" height="1004" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.26.54-PM-1024x1004.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.26.54-PM-600x588.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.26.54-PM-300x294.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.26.54-PM-768x753.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.26.54-PM.png 1738w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Click &#8220;Create certificate&#8221;</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l8-amazon-aws-mqtt-thread-part1/screen-shot-2019-12-08-at-6-27-02-pm/" rel="attachment wp-att-8236"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.02-PM-1024x666.png" alt="" class="alignnone size-large wp-image-8236" width="1024" height="666" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.02-PM-1024x666.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.02-PM-600x390.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.02-PM-300x195.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.02-PM-768x500.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.02-PM.png 1724w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>You <strong>MUST DOWNLOAD these files now</strong>.  You will not be given another chance. Press activate:</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l8-amazon-aws-mqtt-thread-part1/screen-shot-2019-12-08-at-6-27-15-pm/" rel="attachment wp-att-8237"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.15-PM-1024x701.png" alt="" class="alignnone size-large wp-image-8237" width="1024" height="701" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.15-PM-1024x701.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.15-PM-600x411.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.15-PM-300x205.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.15-PM-768x526.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.15-PM.png 1704w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Which will show the certificate as active.  Next press &#8220;attach a policy&#8221;:</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l8-amazon-aws-mqtt-thread-part1/screen-shot-2019-12-08-at-6-27-39-pm/" rel="attachment wp-att-8239"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.39-PM-1024x688.png" alt="" class="alignnone size-large wp-image-8239" width="1024" height="688" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.39-PM-1024x688.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.39-PM-600x403.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.39-PM-300x202.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.39-PM-768x516.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.39-PM.png 1792w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Then pick the Mouser policy:</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l8-amazon-aws-mqtt-thread-part1/screen-shot-2019-12-08-at-6-27-48-pm/" rel="attachment wp-att-8240"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.48-PM-1024x523.png" alt="" class="alignnone size-large wp-image-8240" width="1024" height="523" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.48-PM-1024x523.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.48-PM-600x307.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.48-PM-300x153.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.48-PM-768x392.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.48-PM.png 1750w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Now you have your new &#8220;Thing&#8221;.</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l8-amazon-aws-mqtt-thread-part1/screen-shot-2019-12-08-at-6-27-59-pm/" rel="attachment wp-att-8241"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.59-PM-1024x449.png" alt="" class="alignnone size-large wp-image-8241" width="1024" height="449" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.59-PM-1024x449.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.59-PM-600x263.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.59-PM-300x131.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.59-PM-768x336.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-6.27.59-PM.png 1584w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Modify the keys to &#8220;C&#8221; Format</h1>
<p>In order to make a connection to AWS you need a valid certificate, the private key that goes with the certificate and the CA certificate of AWS.    You just created these files in the previous step.</p>
<p>These keys come looking like this:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEAsRLypD2uhZNZgtfPAuX8M3ZFNYcBU/BHulG9CJrETKwmjXOV
j1l9U/Tlu3p/hGIFEhrkbqt1SGvPEj8x7U5kyCpJde1JojObW4m2S5T7WuXxd5JQ
Y+rqWkyrvwp/1HPFLRB3n3OopGaUcnEZwegsMznUcsi+kZwrUDkqBWFIQbEEKjW8
UzZxqmbmNSCsJQXHCv9OPrKdeisBnkQrpRkTz4uSG3yZI6jG7acx3UZkMcc6DvDo
bbz8PoBisZq4JcKthwpQdiV1RdS4aqCc0wq5Jv7DvhifqNcrOK3PT+zkck82jqIC
VDd58NkY6Y0URIyqjPCPPIltCbrAB/+u41rrtQIDAQABAoIBAQCQAhvprOxpX+u1
OLP35HjWlYI1xSU0Ub7T7bPx8oRg4sS711uz6JC/nfTUIwzf6iO7lLlgs/q/OkZ+
zXxaRZ47GAEEckWnL5dSu83Q7En7o/RcTVcp25xace5fgTdy3fBm9PSEbjih83cZ
F5heFecUhhyceVxa6YpkRQlCtNph6SwFfsY1BmfhHISHh4U7XYityUatdalQfOtL
Vf79TRIE/X1aX/H/xXYsqNQPCSGUzNj1BU5aHOM93B+hNg8q1t+Ze5w6Q/HkMBTb
5VPI8fabvaAV6WUrrWtEl8ErcokutYWNRadXH0ieCGiuI2uoK0qqgrBb2MwZwv81
ZtzCm3QlAoGBAOj5zlZtcWN5Mfb9PHonPSwFPE4pud2fZCJjO9btQWb6ELYwp9qW
2aRaoaQm9bA7pTwMaSRQYGC9eKPu8hu+cqPXJZ1gg1GrYP+IfJMChDAM0x7Faks4
B7ZDjfQlRGUJGAkqLQ4/4+k2y75KtZdnri5Z40myh4f0+PuiDDRwPcGjAoGBAMKS
2VuNefMvzqKW7g/drRLzChudUL96r2BWI8nkl7S9UChtKVgdqJcrNSiKXbTv0wLn
pWsnlOIxPVJAi1u5we045U+ZQadgIg4UqeIBVfRVKm4ZKrInSCT4uMriGDDJuvQl
NXBv9PIX8WCaPWpG2rcsOFsi0mNBcImVHMAhc2LHAoGBAIk6k8Ku5opMWhT9J0Fg
mZSzZMk5pMSZXXcv8pBv4gVRKMTYNhb4oixAQlQZqsBq8bJEMS51tb9l+4i8d5nF
/WrqkLp5ngBeLV13PMGvSsOu2jCW4jx6PXirpBL6XKYSzDihwjZRheLaJvrosLwF
E0E0K0A+y7xWnM5DrmK49nd3AoGAQdp70F24yZMDp8nXdu07F6/EWwZKfxQh6UQe
RsWkhtqQF66ikJ0xI0DPdBIolwWYcGJAfVzfKhMqQv1vbTMYrJZWHjOrod+KhyN9
P+3dzp1IiAzig3uCEmlP+fK95z1PljRFuvFZgNqTqnNpl9+1RMulo0rM1CUg1p/u
JCTuLZ8CgYEAwUsBplIARj4i+hhyVWC1WOR+I4AqgRAauCwliO9gvToJzjkQsc5q
RZxPbXLbm907wy6/7P/tKT20WhZ0b7szZsXchdeX20xSfAa4N0bJTZy3OiS0CYtF
3+Xw1Mlu3Gihr89X9QeSot0tH9m6QZky032aLW/8jbNT3Eb49niqQZA=
-----END RSA PRIVATE KEY-----
</pre>
<p>But you need them to look like this so that they can be read in by the Mbed TLS library.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">// Private key
const char SSL_CLIENTKEY_PEM[] = \
"-----BEGIN RSA PRIVATE KEY-----\n"\
"MIIEpQIBAAKCAQEAsRLypD2uhZNZgtfPAuX8M3ZFNYcBU/BHulG9CJrETKwmjXOV\n"\
"j1l9U/Tlu3p/hGIFEhrkbqt1SGvPEj8x7U5kyCpJde1JojObW4m2S5T7WuXxd5JQ\n"\
"Y+rqWkyrvwp/1HPFLRB3n3OopGaUcnEZwegsMznUcsi+kZwrUDkqBWFIQbEEKjW8\n"\
"UzZxqmbmNSCsJQXHCv9OPrKdeisBnkQrpRkTz4uSG3yZI6jG7acx3UZkMcc6DvDo\n"\
"bbz8PoBisZq4JcKthwpQdiV1RdS4aqCc0wq5Jv7DvhifqNcrOK3PT+zkck82jqIC\n"\
"VDd58NkY6Y0URIyqjPCPPIltCbrAB/+u41rrtQIDAQABAoIBAQCQAhvprOxpX+u1\n"\
"OLP35HjWlYI1xSU0Ub7T7bPx8oRg4sS711uz6JC/nfTUIwzf6iO7lLlgs/q/OkZ+\n"\
"zXxaRZ47GAEEckWnL5dSu83Q7En7o/RcTVcp25xace5fgTdy3fBm9PSEbjih83cZ\n"\
"F5heFecUhhyceVxa6YpkRQlCtNph6SwFfsY1BmfhHISHh4U7XYityUatdalQfOtL\n"\
"Vf79TRIE/X1aX/H/xXYsqNQPCSGUzNj1BU5aHOM93B+hNg8q1t+Ze5w6Q/HkMBTb\n"\
"5VPI8fabvaAV6WUrrWtEl8ErcokutYWNRadXH0ieCGiuI2uoK0qqgrBb2MwZwv81\n"\
"ZtzCm3QlAoGBAOj5zlZtcWN5Mfb9PHonPSwFPE4pud2fZCJjO9btQWb6ELYwp9qW\n"\
"2aRaoaQm9bA7pTwMaSRQYGC9eKPu8hu+cqPXJZ1gg1GrYP+IfJMChDAM0x7Faks4\n"\
"B7ZDjfQlRGUJGAkqLQ4/4+k2y75KtZdnri5Z40myh4f0+PuiDDRwPcGjAoGBAMKS\n"\
"2VuNefMvzqKW7g/drRLzChudUL96r2BWI8nkl7S9UChtKVgdqJcrNSiKXbTv0wLn\n"\
"pWsnlOIxPVJAi1u5we045U+ZQadgIg4UqeIBVfRVKm4ZKrInSCT4uMriGDDJuvQl\n"\
"NXBv9PIX8WCaPWpG2rcsOFsi0mNBcImVHMAhc2LHAoGBAIk6k8Ku5opMWhT9J0Fg\n"\
"mZSzZMk5pMSZXXcv8pBv4gVRKMTYNhb4oixAQlQZqsBq8bJEMS51tb9l+4i8d5nF\n"\
"/WrqkLp5ngBeLV13PMGvSsOu2jCW4jx6PXirpBL6XKYSzDihwjZRheLaJvrosLwF\n"\
"E0E0K0A+y7xWnM5DrmK49nd3AoGAQdp70F24yZMDp8nXdu07F6/EWwZKfxQh6UQe\n"\
"RsWkhtqQF66ikJ0xI0DPdBIolwWYcGJAfVzfKhMqQv1vbTMYrJZWHjOrod+KhyN9\n"\
"P+3dzp1IiAzig3uCEmlP+fK95z1PljRFuvFZgNqTqnNpl9+1RMulo0rM1CUg1p/u\n"\
"JCTuLZ8CgYEAwUsBplIARj4i+hhyVWC1WOR+I4AqgRAauCwliO9gvToJzjkQsc5q\n"\
"RZxPbXLbm907wy6/7P/tKT20WhZ0b7szZsXchdeX20xSfAa4N0bJTZy3OiS0CYtF\n"\
"3+Xw1Mlu3Gihr89X9QeSot0tH9m6QZky032aLW/8jbNT3Eb49niqQZA=\n"\
"-----END RSA PRIVATE KEY-----";</pre>
<p>There are a number of ways to change the format including manual editing.</p>
<p>For this lesson I put the keys into a file called “aws_config.h”  There are bunches of bad stories out there about people finding encryption keys on the internet (like these).  I am going to disable the keys as soon as this workshop is over, but you should be careful with yours.</p>
<p>Here is my aws_config.h</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">/* Change device certificate and device private key based on your account */
// certificate
const char SSL_CLIENTCERT_PEM[] =  \
"-----BEGIN CERTIFICATE-----\n\
MIIDWjCCAkKgAwIBAgIVAJ4u/gU7NxWiV2NwBRTFJk/mPPkvMA0GCSqGSIb3DQEB\n\
CwUAME0xSzBJBgNVBAsMQkFtYXpvbiBXZWIgU2VydmljZXMgTz1BbWF6b24uY29t\n\
IEluYy4gTD1TZWF0dGxlIFNUPVdhc2hpbmd0b24gQz1VUzAeFw0xOTA3MDMxMTM5\n\
MTZaFw00OTEyMzEyMzU5NTlaMB4xHDAaBgNVBAMME0FXUyBJb1QgQ2VydGlmaWNh\n\
dGUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCxEvKkPa6Fk1mC188C\n\
5fwzdkU1hwFT8Ee6Ub0ImsRMrCaNc5WPWX1T9OW7en+EYgUSGuRuq3VIa88SPzHt\n\
TmTIKkl17UmiM5tbibZLlPta5fF3klBj6upaTKu/Cn/Uc8UtEHefc6ikZpRycRnB\n\
6CwzOdRyyL6RnCtQOSoFYUhBsQQqNbxTNnGqZuY1IKwlBccK/04+sp16KwGeRCul\n\
GRPPi5IbfJkjqMbtpzHdRmQxxzoO8OhtvPw+gGKxmrglwq2HClB2JXVF1LhqoJzT\n\
Crkm/sO+GJ+o1ys4rc9P7ORyTzaOogJUN3nw2RjpjRREjKqM8I88iW0JusAH/67j\n\
Wuu1AgMBAAGjYDBeMB8GA1UdIwQYMBaAFIJyQZprW3SRNIXe+X22/uZ6sdO9MB0G\n\
A1UdDgQWBBT+al32O2+dH5qoClpyEWRRoMk6oTAMBgNVHRMBAf8EAjAAMA4GA1Ud\n\
DwEB/wQEAwIHgDANBgkqhkiG9w0BAQsFAAOCAQEAoRg4QETRC1rMKJytxthLuGDj\n\
WtB9Zow3TONnq1HZ4yMUQFQeflYCZ96khBuWu91cj2iZengikEJkl+6HGCL+9ZKA\n\
ybWPRyQNvJQ13ju/iQyl89ZIbYh5UGmGrk6G8ryyvPezVP8AxpB5usz9YxTTz/m6\n\
eQMs38zUK5Dv4297NBJ6Xxwoqb8ivJkHEmnkDxKeErd4Qb7Q9ukWYlo5ksjqib8F\n\
NYTv8fhcx4S3UFhbNB+z/iaGtJXk7WIzgGpSX/CiRtGcV776c94LdgIfIZ9DpLgi\n\
GWSrCjsCr6yNtc708vwC+0jKoBcrk3HdVII2N4ciNuzJaoGyuHi+YuiXnO8kbg==\n\
-----END CERTIFICATE-----";

// Private key
const char SSL_CLIENTKEY_PEM[] = \
"-----BEGIN RSA PRIVATE KEY-----\n"\
"MIIEpQIBAAKCAQEAsRLypD2uhZNZgtfPAuX8M3ZFNYcBU/BHulG9CJrETKwmjXOV\n"\
"j1l9U/Tlu3p/hGIFEhrkbqt1SGvPEj8x7U5kyCpJde1JojObW4m2S5T7WuXxd5JQ\n"\
"Y+rqWkyrvwp/1HPFLRB3n3OopGaUcnEZwegsMznUcsi+kZwrUDkqBWFIQbEEKjW8\n"\
"UzZxqmbmNSCsJQXHCv9OPrKdeisBnkQrpRkTz4uSG3yZI6jG7acx3UZkMcc6DvDo\n"\
"bbz8PoBisZq4JcKthwpQdiV1RdS4aqCc0wq5Jv7DvhifqNcrOK3PT+zkck82jqIC\n"\
"VDd58NkY6Y0URIyqjPCPPIltCbrAB/+u41rrtQIDAQABAoIBAQCQAhvprOxpX+u1\n"\
"OLP35HjWlYI1xSU0Ub7T7bPx8oRg4sS711uz6JC/nfTUIwzf6iO7lLlgs/q/OkZ+\n"\
"zXxaRZ47GAEEckWnL5dSu83Q7En7o/RcTVcp25xace5fgTdy3fBm9PSEbjih83cZ\n"\
"F5heFecUhhyceVxa6YpkRQlCtNph6SwFfsY1BmfhHISHh4U7XYityUatdalQfOtL\n"\
"Vf79TRIE/X1aX/H/xXYsqNQPCSGUzNj1BU5aHOM93B+hNg8q1t+Ze5w6Q/HkMBTb\n"\
"5VPI8fabvaAV6WUrrWtEl8ErcokutYWNRadXH0ieCGiuI2uoK0qqgrBb2MwZwv81\n"\
"ZtzCm3QlAoGBAOj5zlZtcWN5Mfb9PHonPSwFPE4pud2fZCJjO9btQWb6ELYwp9qW\n"\
"2aRaoaQm9bA7pTwMaSRQYGC9eKPu8hu+cqPXJZ1gg1GrYP+IfJMChDAM0x7Faks4\n"\
"B7ZDjfQlRGUJGAkqLQ4/4+k2y75KtZdnri5Z40myh4f0+PuiDDRwPcGjAoGBAMKS\n"\
"2VuNefMvzqKW7g/drRLzChudUL96r2BWI8nkl7S9UChtKVgdqJcrNSiKXbTv0wLn\n"\
"pWsnlOIxPVJAi1u5we045U+ZQadgIg4UqeIBVfRVKm4ZKrInSCT4uMriGDDJuvQl\n"\
"NXBv9PIX8WCaPWpG2rcsOFsi0mNBcImVHMAhc2LHAoGBAIk6k8Ku5opMWhT9J0Fg\n"\
"mZSzZMk5pMSZXXcv8pBv4gVRKMTYNhb4oixAQlQZqsBq8bJEMS51tb9l+4i8d5nF\n"\
"/WrqkLp5ngBeLV13PMGvSsOu2jCW4jx6PXirpBL6XKYSzDihwjZRheLaJvrosLwF\n"\
"E0E0K0A+y7xWnM5DrmK49nd3AoGAQdp70F24yZMDp8nXdu07F6/EWwZKfxQh6UQe\n"\
"RsWkhtqQF66ikJ0xI0DPdBIolwWYcGJAfVzfKhMqQv1vbTMYrJZWHjOrod+KhyN9\n"\
"P+3dzp1IiAzig3uCEmlP+fK95z1PljRFuvFZgNqTqnNpl9+1RMulo0rM1CUg1p/u\n"\
"JCTuLZ8CgYEAwUsBplIARj4i+hhyVWC1WOR+I4AqgRAauCwliO9gvToJzjkQsc5q\n"\
"RZxPbXLbm907wy6/7P/tKT20WhZ0b7szZsXchdeX20xSfAa4N0bJTZy3OiS0CYtF\n"\
"3+Xw1Mlu3Gihr89X9QeSot0tH9m6QZky032aLW/8jbNT3Eb49niqQZA=\n"\
"-----END RSA PRIVATE KEY-----";


const char SSL_CA_PEM[] = \
"-----BEGIN CERTIFICATE-----\n"\
"MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsF\n"\
"ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n"\
"b24gUm9vdCBDQSAxMB4XDTE1MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTEL\n"\
"MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv\n"\
"b3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALJ4gHHKeNXj\n"\
"ca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgHFzZM\n"\
"9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qw\n"\
"IFAGbHrQgLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6\n"\
"VOujw5H5SNz/0egwLX0tdHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L\n"\
"93FcXmn/6pUCyziKrlA4b9v7LWIbxcceVOF34GfID5yHI9Y/QCB/IIDEgEw+OyQm\n"\
"jgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC\n"\
"AYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3DQEBCwUA\n"\
"A4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDI\n"\
"U5PMCCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUs\n"\
"N+gDS63pYaACbvXy8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vv\n"\
"o/ufQJVtMVT8QtPHRh8jrdkPSHCa2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU\n"\
"5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2xJNDd2ZhwLnoQdeXeGADbkpy\n"\
"rqXRfboQnoZsG4q5WTP468SQvvG5\n"\
"-----END CERTIFICATE-----";
</pre>
<h1>Create and Code awsThread.h</h1>
<p>Now create a new header file for the awsThread:</p>
<h1><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l8-amazon-aws-mqtt-thread-part1/screen-shot-2019-12-07-at-8-04-07-pm/" rel="attachment wp-att-8120"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.04.07-PM.png" alt="" class="alignnone size-large wp-image-8120" width="792" height="308" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.04.07-PM.png 792w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.04.07-PM-600x233.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.04.07-PM-300x117.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.04.07-PM-768x299.png 768w" sizes="auto, (max-width: 792px) 100vw, 792px" /></a></h1>
<p>This file just contains the thread function prototype.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#ifndef AWS_THREAD_H
#define AWS_THREAD_H

void awsThread(void);


#endif</pre>
<h1>Create and Code awsThread.cpp</h1>
<p>Now create the awsThread.cpp file for the aws implementation:</p>
<h1><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l8-amazon-aws-mqtt-thread-part1/screen-shot-2019-12-07-at-8-04-27-pm/" rel="attachment wp-att-8121"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.04.27-PM.png" alt="" class="alignnone size-large wp-image-8121" width="790" height="300" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.04.27-PM.png 790w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.04.27-PM-600x228.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.04.27-PM-300x114.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.04.27-PM-768x292.png 768w" sizes="auto, (max-width: 790px) 100vw, 790px" /></a></h1>
<p>The basis for this code is again taken from a code example that is provided by Cypress on GitHub. You can find that code example here:</p>
<p><a href="http://github.com/cypresssemiconductorco/aws-iot" target="_blank" rel="noopener noreferrer">github.com/cypresssemiconductorco/aws-iot</a></p>
<p>The awsThread starts with my evil extern.</p>
<p>Then I declare a function which is called when a message comes in from the MQTT broker.  I ASSUME that the message is an ASCII message formatted as %2.1f and I use sscanf to convert it to a float.  Many bugs have been made with this EXACT scheme.  It is expedient way to show people but it is a horrible habit.  I then send it to the temperature controller.</p>
<p>The main awsThread starts by initializing the AWS Client library, then connecting to AWS.  Lastly it subscribes to the setPoint topic.  Then it goes into an infinite loop calling the yield function which is responsible to listening to the aws MQTT socket and doing something with the data&#8230; specifically calling the callback.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#include "mbed.h"
#include "aws_client.h"
#include "aws_config.h"
#include "temperatureThread.h"

#define AWSIOT_ENDPOINT_ADDRESS             "a1c0l0bpd6pon3-ats.iot.us-east-2.amazonaws.com"


extern WiFiInterface *wifi;

static void messageArrived(aws_iot_message_t&amp; md)
{
    float setPoint; 
    aws_message_t &amp;message = md.message;
    sscanf((char*)message.payload,"%f",&amp;setPoint);
    tempSendUpdateSetpointF(setPoint);
}

void awsThread(void)
{
    AWSIoTClient client;
    AWSIoTEndpoint* ep = NULL;

    /* Initialize AWS Client library */
    AWSIoTClient AWSClient(wifi, "thermostat" , SSL_CLIENTKEY_PEM, strlen(SSL_CLIENTKEY_PEM), SSL_CLIENTCERT_PEM, strlen(SSL_CLIENTCERT_PEM));

    aws_connect_params conn_params = { 0,0,NULL,NULL,NULL,NULL,NULL };
    ep = AWSClient.create_endpoint(AWS_TRANSPORT_MQTT_NATIVE, AWSIOT_ENDPOINT_ADDRESS, 8883, SSL_CA_PEM, strlen(SSL_CA_PEM));

    /* set MQTT connection parameters */
    conn_params.username = NULL;
    conn_params.password = NULL;
    conn_params.keep_alive = 60;
    conn_params.peer_cn = (uint8_t*) AWSIOT_ENDPOINT_ADDRESS;
    conn_params.client_id = (uint8_t*)"thermostat";

    /* connect to an AWS endpoint */
    AWSClient.connect (ep, conn_params);
 
    AWSClient.subscribe(ep, "setPoint", AWS_QOS_ATMOST_ONCE, messageArrived);
    while(1)
    {
        AWSClient.yield(1000);
    }
}
</pre>
<h1>Update main.cpp</h1>
<p>The last step is to start up the awsThread in main:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#include "mbed.h"
#include "blinkThread.h"
#include "displayThread.h"
#include "temperatureThread.h"
#include "capsenseThread.h"
#include "ntpThread.h"
#include "awsThread.h"

Thread blinkThreadHandle;
Thread displayThreadHandle;
Thread temperatureThreadHandle;
Thread capsenseThreadHandle;
Thread ntpThreadHandle;
Thread awsThreadHandle;

WiFiInterface *wifi;

int main()
{

    printf("Started System\n");

    int ret;
    wifi = WiFiInterface::get_default_instance();

    do {
            ret = wifi-&gt;connect("CYFI_IOT_EXT", "cypresswicedwifi101", NSAPI_SECURITY_WPA_WPA2);
            if (ret != 0) {
            ThisThread::sleep_for(2000); // If for some reason it doesnt work wait 2s and try again
            }
    } while(ret !=0);


    ntpThreadHandle.start(ntpThread);
    blinkThreadHandle.start(blinkThread);
    displayThreadHandle.start(displayThread);
    temperatureThreadHandle.start(temperatureThread);
    capsenseThreadHandle.start(capsenseThread);
    awsThreadHandle.start(awsThread);
    
}
</pre>
<h1>Build, Program and Test</h1>
<p>When you build and program the development kit.  You will be able to publish messages to the “setPoint” topic which will then change the setPoint on your system.  Remember that my parser is really not safe so just send %2.1f.</p>
<p>In the case below you can see that I publish 51.1:</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l8-amazon-aws-mqtt-thread-part1/screen-shot-2019-12-07-at-8-23-50-pm/" rel="attachment wp-att-8127"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.23.50-PM-1024x268.png" alt="" class="alignnone size-large wp-image-8127" width="1024" height="268" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.23.50-PM-1024x268.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.23.50-PM-600x157.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.23.50-PM-300x78.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.23.50-PM-768x201.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Which changes the setPoint on my board.</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l8-amazon-aws-mqtt-thread-part1/screen-shot-2019-12-07-at-8-24-08-pm/" rel="attachment wp-att-8128"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.24.08-PM-1024x312.png" alt="" class="alignnone size-large wp-image-8128" width="1024" height="312" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.24.08-PM-1024x312.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.24.08-PM-600x183.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.24.08-PM-300x91.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.24.08-PM-768x234.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.24.08-PM.png 1314w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>&nbsp;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l8-amazon-aws-mqtt-thread-part1/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Mouser PSoC 6 WiFi/BT MBED: L9 Amazon AWS MQTT Thread &#8211; Part2</title>
		<link>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l9-amazon-aws-mqtt-thread-part2/</link>
					<comments>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l9-amazon-aws-mqtt-thread-part2/#comments</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Mon, 09 Dec 2019 17:03:06 +0000</pubDate>
				<category><![CDATA[Mouser PSoC 6 WiFi/BT MBED]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=8005</guid>

					<description><![CDATA[Summary In the last lesson we added an MQTT subscription that let’s the AWS servers control the setPoint.  In this lesson we will update the system to send out the current temperature every second &#8211; which I know is excessive. To make the temperature publish changes I need to modify the awsThread to have a [&#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 the last lesson we added an MQTT subscription that let’s the AWS servers control the setPoint.  In this lesson we will update the system to send out the current temperature every second &#8211; which I know is excessive.</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l9-amazon-aws-mqtt-thread-part2/lesson9-4/" rel="attachment wp-att-8133"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/lesson9-3-1024x651.png" alt="" width="1024" height="651" class="alignnone size-large wp-image-8133" srcset="https://iotexpert.com/wp-content/uploads/2019/12/lesson9-3-1024x651.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/lesson9-3-600x381.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/lesson9-3-300x191.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/lesson9-3-768x488.png 768w, https://iotexpert.com/wp-content/uploads/2019/12/lesson9-3.png 1662w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>To make the temperature publish changes I need to modify the awsThread to have a queue/command scheme just like the displayThread and the temperatureThread.  Then I will modify the temperatureThread to send out temperature changes to the awsThread which will take care of publishing changes.</p>
<p>To implement this I will:</p>
<ol>
<li>Import Lesson 08</li>
<li>Modify awsThread.h</li>
<li>Modify awsThread.cpp</li>
<li>Modify temperatureThread.cpp</li>
<li>Build, Program and Test</li>
</ol>
<h1>Import Lesson 09</h1>
<p>Start by importing Lesson 08.</p>
<p>https://github.com/iotexpert/mouser-mbed-08.git</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l9-amazon-aws-mqtt-thread-part2/screen-shot-2019-12-07-at-8-28-27-pm/" rel="attachment wp-att-8130"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.28.27-PM.png" alt="" width="894" height="620" class="alignnone size-full wp-image-8130" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.28.27-PM.png 894w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.28.27-PM-600x416.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.28.27-PM-300x208.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.28.27-PM-768x533.png 768w" sizes="auto, (max-width: 894px) 100vw, 894px" /></a></p>
<h1>Modify awsThread.h</h1>
<p>Add the function prototype for the other threads to queue temperature changes.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c" ">#ifndef AWS_THREAD_H
#define AWS_THREAD_H

void awsThread(void);
void awsSendUpdateTemperature(float temperature);

#endif</pre>
<h1>Modify awsThread.cpp</h1>
<p>I will copy the scheme I built for the other threads.  There will be only one command, the one to send the temperature.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">typedef enum {
    CMD_sendTemperature,
} command_t;

typedef struct {
    command_t cmd;
    float    value;   /* AD result of measured voltage */
} msg_t;


static Queue&lt;msg_t, 32&gt; queue;
static MemoryPool&lt;msg_t, 16&gt; mpool;

void awsSendUpdateTemperature(float temperature)
{
    msg_t *message = mpool.alloc();
    if(message)
    {
        message-&gt;cmd = CMD_sendTemperature;
        message-&gt;value = temperature;
        queue.put(message);
    }
}</pre>
<p>Now I modify the main loop of the awsThread.  The AWSClient.yield function will time out every 1000ms which gives you the opportunity to do something.  That “something” is that I completely empty queue and then send the LAST update.</p>
<pre class="start-line:65 EnlighterJSRAW" data-enlighter-language="c""> bool doPublish=false;
    float currentTemp;
    while(1)
    {
        AWSClient.yield(1000);
        while(!queue.empty())
        {
            osEvent evt = queue.get(0);
            if (evt.status == osEventMessage) {
                msg_t *message = (msg_t*)evt.value.p;
                switch(message-&gt;cmd)
                {
                    case CMD_sendTemperature:
                        doPublish = true;
                        currentTemp = message-&gt;value;
                    break;

                }
                mpool.free(message);
            }
        }
        if(doPublish)
        {
            char buffer[128];
            sprintf(buffer,"%2.1f",currentTemp);
            AWSClient.publish(ep,"currentTemp", buffer, strlen(buffer),  publish_params);
        }
        doPublish = false;
    }</pre>
<p>Here is the whole awsThread.cpp:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c" ">#include "mbed.h"
#include "aws_client.h"
#include "aws_config.h"
#include "temperatureThread.h"

#define AWSIOT_ENDPOINT_ADDRESS             "a1c0l0bpd6pon3-ats.iot.us-east-2.amazonaws.com"


extern WiFiInterface *wifi;

typedef enum {
    CMD_sendTemperature,
} command_t;

typedef struct {
    command_t cmd;
    float    value;   /* AD result of measured voltage */
} msg_t;


static Queue&lt;msg_t, 32&gt; queue;
static MemoryPool&lt;msg_t, 16&gt; mpool;

void awsSendUpdateTemperature(float temperature)
{
    msg_t *message = mpool.alloc();
    if(message)
    {
        message-&gt;cmd = CMD_sendTemperature;
        message-&gt;value = temperature;
        queue.put(message);
    }
}

void messageArrived(aws_iot_message_t&amp; md)
{
    float setPoint; 
    aws_message_t &amp;message = md.message;
    sscanf((char*)message.payload,"%f",&amp;setPoint);
    tempSendUpdateSetpointF(setPoint);
}

void awsThread(void)
{
    AWSIoTClient client;
    AWSIoTEndpoint* ep = NULL;

    /* Initialize AWS Client library */
    AWSIoTClient AWSClient(wifi, "thermostat" , SSL_CLIENTKEY_PEM, strlen(SSL_CLIENTKEY_PEM), SSL_CLIENTCERT_PEM, strlen(SSL_CLIENTCERT_PEM));

    aws_connect_params conn_params = { 0,0,NULL,NULL,NULL,NULL,NULL };
    ep = AWSClient.create_endpoint(AWS_TRANSPORT_MQTT_NATIVE, AWSIOT_ENDPOINT_ADDRESS, 8883, SSL_CA_PEM, strlen(SSL_CA_PEM));

    /* set MQTT connection parameters */
    conn_params.username = NULL;
    conn_params.password = NULL;
    conn_params.keep_alive = 60;
    conn_params.peer_cn = (uint8_t*) AWSIOT_ENDPOINT_ADDRESS;
    conn_params.client_id = (uint8_t*)"thermostat";

    /* connect to an AWS endpoint */
    AWSClient.connect (ep, conn_params);
 
    AWSClient.subscribe(ep, "setPoint", AWS_QOS_ATMOST_ONCE, messageArrived);
    aws_publish_params publish_params = { AWS_QOS_ATMOST_ONCE };
    
    bool doPublish=false;
    float currentTemp;
    while(1)
    {
        AWSClient.yield(1000);
        while(!queue.empty())
        {
            osEvent evt = queue.get(0);
            if (evt.status == osEventMessage) {
                msg_t *message = (msg_t*)evt.value.p;
                switch(message-&gt;cmd)
                {
                    case CMD_sendTemperature:
                        doPublish = true;
                        currentTemp = message-&gt;value;
                    break;

                }
                mpool.free(message);
            }
        }
        if(doPublish)
        {
            char buffer[128];
            sprintf(buffer,"%2.1f",currentTemp);
            AWSClient.publish(ep,"currentTemp", buffer, strlen(buffer),  publish_params);
        }
        doPublish = false;
    }
}
</pre>
<h1>Modify temperatureThread.cpp</h1>
<p>In order to use the new functionality in the awsThread you need to modify the temperatureThread.</p>
<p>First add the #include “awsThread.h” (so that it has access to the awsThread public interface):</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c" ">#include "mbed.h"
#include "temperatureThread.h"
#include "displayThread.h"
#include "awsThread.h"
</pre>
<p>Each time the temperature changes send the awsThread the update.</p>
<pre class="start-line:86 EnlighterJSRAW" data-enlighter-language="c" ">        {
            readTemp();

            // Control the HVAC system with +- 0.5 degree of Hystersis
            if(temperatureF &lt; setPoint - 0.5)
                displaySendUpdateMode(-1.0);
            else if (temperatureF &gt; setPoint + 0.5)
                displaySendUpdateMode(1.0);
            else
                displaySendUpdateMode(0.0);

            displaySendUpdateTemp(temperatureF);
            awsSendUpdateTemperature(temperatureF);
        }</pre>
<h1>Build, Program and Test</h1>
<p>In order to test this I log into the AWS Test Console, and subscribe to the currentTemp topic.  Notice that temperatures keep coming!</p>
<p><a href="https://iotexpert.com/2019/12/09/mouser-psoc-6-wifi-bt-mbed-l9-amazon-aws-mqtt-thread-part2/screen-shot-2019-12-07-at-8-43-03-pm/" rel="attachment wp-att-8134"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.43.03-PM-1024x689.png" alt="" width="1024" height="689" class="alignnone size-large wp-image-8134" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.43.03-PM-1024x689.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.43.03-PM-600x404.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.43.03-PM-300x202.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-07-at-8.43.03-PM-768x517.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>&nbsp;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l9-amazon-aws-mqtt-thread-part2/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Mouser PSoC 6 WiFi/BT MBED: L0 Introduction</title>
		<link>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l0-introduction/</link>
					<comments>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l0-introduction/#comments</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Sun, 08 Dec 2019 13:10:35 +0000</pubDate>
				<category><![CDATA[Mouser PSoC 6 WiFi/BT MBED]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=7990</guid>

					<description><![CDATA[Summary Register for my Virtual Training Workshop &#8211; IoT Design with Cypress PSoC® 6 MCUs and Wi-Fi/Bluetooth using Arm® Mbed™ on December, 9 at 1:00PM Eastern Time!  I will be live-streaming a complete IoT Design using PSoC and WiFi &#8211; live for your entertainment &#8230; and hopefully education. Hello everyone.  This is lesson 0 of [&#8230;]]]></description>
										<content:encoded><![CDATA[<h1>Summary</h1>
<p><a href="https://www.electronicdesign.com/webcasts/iot-design-cypress-psoc-6-mcus-and-wi-fibluetooth-using-arm-mbed?partnerref=CYPRESS1209" target="_blank" rel="noopener noreferrer">Register</a> for my Virtual Training Workshop &#8211; 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;" /> on December, 9 at 1:00PM Eastern Time!  I will be live-streaming a complete IoT Design using PSoC and WiFi &#8211; live for your entertainment &#8230; and hopefully education.</p>
<p><a href="https://iotexpert.com/2019/12/08/mouser-psoc-6-wifi-bt-mbed-l0-introduction/1200x400_8/" rel="attachment wp-att-8136"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/1200x400_8-1024x341.jpg" alt="" width="1024" height="341" class="alignnone size-large wp-image-8136" srcset="https://iotexpert.com/wp-content/uploads/2019/12/1200x400_8-1024x341.jpg 1024w, https://iotexpert.com/wp-content/uploads/2019/12/1200x400_8-600x200.jpg 600w, https://iotexpert.com/wp-content/uploads/2019/12/1200x400_8-300x100.jpg 300w, https://iotexpert.com/wp-content/uploads/2019/12/1200x400_8-768x256.jpg 768w, https://iotexpert.com/wp-content/uploads/2019/12/1200x400_8.jpg 1200w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Hello everyone.  This is lesson 0 of a series of 10 lessons about creating an IoT application using the Cypress PSoC 6 MCU &amp; WiFi radios.  For this class I will be building the solution using the Arm Mbed OS development platform.  This will include Mbed Studio and Mbed OS.  And I will be using the CY8CPROTO-062-4343W dev kit which you can purchase from <a href="https://www.mouser.com/new/cypress-semiconductor/cypress-psoc-6-wifi-bt-proto-kit/">Mouser</a>.  As always I will be writing this code live &#8230; no powerpoint.  This is always an adventure and should make for good fun for everyone.</p>
<p>I am going to start by showing you the development kit and demonstrating how to use it.  Then we will build up a complete IoT application that acts like a IoT-ified thermostat by reading and controlling temperature, plus connecting to the internet.</p>
<p>I will attempt to go slowly enough for you to follow along, but if I go too fast, don’t worry you should be able to follow along with the instructions on this website.  I have attempted to put in screen shots and step-by-step instructions.</p>
<p>Today&#8217;s virtual workshop has this agenda table which will show also show up on every page.  The links will work to take you through the different lessons.</p>
<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>
<p>You will need a few things for this class:</p>
<ul>
<li>Hardware:
<ul>
<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>
</ul>
</li>
<li>Software (free):
<ul>
<li><a href="https://www.cypress.com/products/modustoolbox-software-environment" target="_blank" rel="noopener noreferrer">ModusToolBox 2.0</a></li>
<li><a href="https://os.mbed.com/studio/" target="_blank" rel="noopener noreferrer">Mbed Studio</a></li>
<li><a href="https://os.mbed.com/docs/mbed-os/v5.15/quick-start/offline-with-mbed-cli.html" target="_blank" rel="noopener noreferrer">Mbed CLI</a></li>
</ul>
</li>
</ul>
<h1>CY8CPROTO-062-4343W</h1>
<p>This development kit (which you can buy from Mouser <a href="https://www.mouser.com/ProductDetail/Cypress-Semiconductor/CY8CPROTO-062-4343W?qs=PqoDHHvF648g2StA%252brE42w%3D%3D&amp;gclid=CjwKCAiA27LvBRB0EiwAPc8XWU9J9WI7gBwg3HrwR2NDzMH_AbwWcvKtRUsAZCRM_OnjzL07cd7A9BoCkq0QAvD_BwE" target="_blank" rel="noopener noreferrer">here</a>) has a bunch of features which we will be using including:</p>
<ol>
<li>Programmer</li>
<li>PSoC 6 MCU</li>
<li>CYW4343W (WiFi Bluetooth combo chip)</li>
<li>CapSense</li>
<li>Thermistor</li>
<li>LED</li>
</ol>
<p><a href="https://iotexpert.com/2019/12/08/mouser-psoc-6-wifi-bt-mbed-l0-introduction/cy8cproto_062_4343w_v2-png/" rel="attachment wp-att-8138"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/CY8CPROTO_062_4343W_v2.png.jpeg" alt="" width="500" height="340" class="alignnone size-full wp-image-8138" srcset="https://iotexpert.com/wp-content/uploads/2019/12/CY8CPROTO_062_4343W_v2.png.jpeg 500w, https://iotexpert.com/wp-content/uploads/2019/12/CY8CPROTO_062_4343W_v2.png-300x204.jpeg 300w" sizes="auto, (max-width: 500px) 100vw, 500px" /></a></p>
<h1>ModusToolbox 2.0</h1>
<p><a href="https://www.cypress.com/products/modustoolbox-software-environment" target="_blank" rel="noopener noreferrer">ModusToolbox 2.0</a> is the Cypress multi-platform development tool suite.  It includes several IDEs, Graphical Chip configurators, SDKs for Bluetooth, WiFi and PSoC 6 MCUs.</p>
<p><a href="https://iotexpert.com/2019/12/08/mouser-psoc-6-wifi-bt-mbed-l0-introduction/screen-shot-2019-12-08-at-7-09-28-am/" rel="attachment wp-att-8142"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.09.28-AM.png" alt="" width="998" height="662" class="alignnone size-full wp-image-8142" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.09.28-AM.png 998w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.09.28-AM-600x398.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.09.28-AM-300x199.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.09.28-AM-768x509.png 768w" sizes="auto, (max-width: 998px) 100vw, 998px" /></a> <a href="https://iotexpert.com/2019/12/08/mouser-psoc-6-wifi-bt-mbed-l0-introduction/screen-shot-2019-12-08-at-7-09-44-am/" rel="attachment wp-att-8143"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.09.44-AM-1024x642.png" alt="" width="1024" height="642" class="alignnone size-large wp-image-8143" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.09.44-AM-1024x642.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.09.44-AM-600x376.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.09.44-AM-300x188.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.09.44-AM-768x482.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Mbed Studio</h1>
<p>Arm <a href="https://os.mbed.com/studio/?_ga=2.154651256.1340306692.1575848117-1016667877.1568852374">Mbed Studio</a> is an IDE for developing Mbed OS programs that target the Cypress PSoC 6 MCU.</p>
<p><a href="https://iotexpert.com/2019/12/08/mouser-psoc-6-wifi-bt-mbed-l0-introduction/screen-shot-2019-12-08-at-7-06-10-am/" rel="attachment wp-att-8139"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.06.10-AM-1024x662.png" alt="" width="1024" height="662" class="alignnone size-large wp-image-8139" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.06.10-AM-1024x662.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.06.10-AM-600x388.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.06.10-AM-300x194.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.06.10-AM-768x496.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Mbed Command Line Interface</h1>
<p>The <a href="https://os.mbed.com/docs/mbed-os/v5.9/tutorials/quick-start-offline.html" target="_blank" rel="noopener noreferrer">Mbed CLI</a> is a command line interface for building and programming Mbed OS projects onto the PSoC 6 MCU.<br />
<a href="https://iotexpert.com/2019/12/08/mouser-psoc-6-wifi-bt-mbed-l0-introduction/screen-shot-2019-12-08-at-7-08-30-am/" rel="attachment wp-att-8140"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.08.30-AM-1024x628.png" alt="" width="1024" height="628" class="alignnone size-large wp-image-8140" srcset="https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.08.30-AM-1024x628.png 1024w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.08.30-AM-600x368.png 600w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.08.30-AM-300x184.png 300w, https://iotexpert.com/wp-content/uploads/2019/12/Screen-Shot-2019-12-08-at-7.08.30-AM-768x471.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/mouser-psoc-6-wifi-bt-mbed-l0-introduction/feed/</wfw:commentRss>
			<slash:comments>7</slash:comments>
		
		
			</item>
	</channel>
</rss>
