<?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/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>ESP8266 Peripherals &#8211; Squix &#8211; TechBlog</title>
	<atom:link href="https://blog.squix.org/category/esp8266-peripherals/feed" rel="self" type="application/rss+xml" />
	<link>https://blog.squix.org</link>
	<description></description>
	<lastBuildDate>Thu, 09 Dec 2021 08:14:49 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.5.8</generator>
<site xmlns="com-wordpress:feed-additions:1">121913304</site>	<item>
		<title>ESP8266 Periphery: CJMCU-530 ToF Distance Sensor</title>
		<link>https://blog.squix.org/2017/04/esp8266-peripherie-cjmcu-530-tof-distance-sensor.html</link>
					<comments>https://blog.squix.org/2017/04/esp8266-peripherie-cjmcu-530-tof-distance-sensor.html#comments</comments>
		
		<dc:creator><![CDATA[Daniel Eichhorn]]></dc:creator>
		<pubDate>Sat, 01 Apr 2017 12:14:45 +0000</pubDate>
				<category><![CDATA[ESP8266 Peripherals]]></category>
		<category><![CDATA[distance sensor]]></category>
		<category><![CDATA[ESP8266]]></category>
		<category><![CDATA[laser ranging]]></category>
		<category><![CDATA[ranging sensor]]></category>
		<category><![CDATA[time-of-flight]]></category>
		<category><![CDATA[tof]]></category>
		<guid isPermaLink="false">https://blog.squix.org/?p=2117</guid>

					<description><![CDATA[The CJMCU-530 is a breakout module featuring the VL53L0X by ST Microelectronics which is a laser-ranging sensor for distances of up to 200cm. The module works without problems with the ESP8266 which makes it an interesting option for your next IoT project. Getting Started This module ... <p><a class="read-more btn btn-secondary" href="https://blog.squix.org/2017/04/esp8266-peripherie-cjmcu-530-tof-distance-sensor.html">Read More</a></p>]]></description>
										<content:encoded><![CDATA[<p>The CJMCU-530 is a breakout module featuring the VL53L0X by ST Microelectronics which is a laser-ranging sensor for distances of up to 200cm. The module works without problems with the ESP8266 which makes it an interesting option for your next IoT project.</p>
<p><span id="more-2117"></span></p>
<h3>Getting Started</h3>
<p>This module has much more features than what I will describe here. I will just show how to connect the module to your ESP8266, which library to install and how to run your first measurements within minutes.</p>
<ol>
<li>Use four wires to connect the following pins:
<ol>
<li>GND with GND</li>
<li>VCC with V3V</li>
<li>SLC with D5</li>
<li>SDA with D6</li>
</ol>
</li>
<li>Open your Arduino IDE and install the following library from Sketch &gt; Include Library &gt; Manage Libraries: VL53L0X by Polulu</li>
<li>Select from File &gt; Examples &gt; VL53L0X &gt; Single the Example sketch and change the following line
<pre>Wire.begin();</pre>
<p>into</p>
<pre>Wire.begin(D6, D5);</pre>
</li>
<li>Compile your sketch, upload it to the ESP8266 and open the serial console. If everything went well you should see now the millimeters of distance measured by the laser-ranging sensor.</li>
</ol>
<p>&nbsp;</p>
<h3>Pitfalls</h3>
<p>At first my measurements were really inaccurate and I was disappointed that the values were always off by about 20mm! Then I searched the web and found out that often the sensor is covered by a protection. Remove this protection to get very precise measurements</p>
<figure id="attachment_2133" aria-describedby="caption-attachment-2133" style="width: 300px" class="wp-caption aligncenter"><a href="https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/04/RemoveProtectiveLiner.jpg?ssl=1"><img data-recalc-dims="1" decoding="async" data-attachment-id="2133" data-permalink="https://blog.squix.org/2017/04/esp8266-peripherie-cjmcu-530-tof-distance-sensor.html/removeprotectiveliner" data-orig-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/04/RemoveProtectiveLiner.jpg?fit=1200%2C453&amp;ssl=1" data-orig-size="1200,453" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Remove protective liner to get good accuracy" data-image-description="" data-image-caption="&lt;p&gt;Remove protective liner to get good accuracy&lt;/p&gt;
" data-medium-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/04/RemoveProtectiveLiner.jpg?fit=300%2C113&amp;ssl=1" data-large-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/04/RemoveProtectiveLiner.jpg?fit=730%2C276&amp;ssl=1" class="wp-image-2133 size-medium" src="https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/04/RemoveProtectiveLiner.jpg?resize=300%2C113&#038;ssl=1" alt="" width="300" height="113" srcset="https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/04/RemoveProtectiveLiner.jpg?resize=300%2C113&amp;ssl=1 300w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/04/RemoveProtectiveLiner.jpg?resize=768%2C290&amp;ssl=1 768w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/04/RemoveProtectiveLiner.jpg?resize=1024%2C387&amp;ssl=1 1024w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/04/RemoveProtectiveLiner.jpg?w=1200&amp;ssl=1 1200w" sizes="(max-width: 300px) 100vw, 300px" /></a><figcaption id="caption-attachment-2133" class="wp-caption-text">Remove protective liner to get good accuracy</figcaption></figure>
<h3>Accuracy</h3>
<p>After removing the protection the measurements were really good. I just tested values below 30cm and the were within 1mm accuracy. This might be a good option for a robotics project to apply <a href="https://de.wikipedia.org/wiki/Simultaneous_Localization_and_Mapping" target="_blank">SLAM</a>.</p>
<figure id="attachment_2122" aria-describedby="caption-attachment-2122" style="width: 300px" class="wp-caption aligncenter"><a href="https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/04/BIRU-WP-20170401T133648GMT0200.jpg?ssl=1"><img data-recalc-dims="1" fetchpriority="high" decoding="async" data-attachment-id="2122" data-permalink="https://blog.squix.org/2017/04/esp8266-peripherie-cjmcu-530-tof-distance-sensor.html/biru-wp-20170401t133648gmt0200-jpg" data-orig-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/04/BIRU-WP-20170401T133648GMT0200.jpg?fit=1280%2C1280&amp;ssl=1" data-orig-size="1280,1280" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;2.2&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;iPhone 6s&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1491053808&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;4.15&quot;,&quot;iso&quot;:&quot;25&quot;,&quot;shutter_speed&quot;:&quot;0.010309278350515&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}" data-image-title="My simple test rig to measure sensor accuracy" data-image-description="" data-image-caption="&lt;p&gt;My simple test rig to measure sensor accuracy&lt;/p&gt;
" data-medium-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/04/BIRU-WP-20170401T133648GMT0200.jpg?fit=300%2C300&amp;ssl=1" data-large-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/04/BIRU-WP-20170401T133648GMT0200.jpg?fit=730%2C730&amp;ssl=1" class="size-medium wp-image-2122" src="https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/04/BIRU-WP-20170401T133648GMT0200.jpg?resize=300%2C300&#038;ssl=1" alt="" width="300" height="300" srcset="https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/04/BIRU-WP-20170401T133648GMT0200.jpg?resize=300%2C300&amp;ssl=1 300w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/04/BIRU-WP-20170401T133648GMT0200.jpg?resize=150%2C150&amp;ssl=1 150w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/04/BIRU-WP-20170401T133648GMT0200.jpg?resize=768%2C768&amp;ssl=1 768w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/04/BIRU-WP-20170401T133648GMT0200.jpg?resize=1024%2C1024&amp;ssl=1 1024w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/04/BIRU-WP-20170401T133648GMT0200.jpg?resize=180%2C180&amp;ssl=1 180w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/04/BIRU-WP-20170401T133648GMT0200.jpg?resize=200%2C200&amp;ssl=1 200w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/04/BIRU-WP-20170401T133648GMT0200.jpg?resize=450%2C450&amp;ssl=1 450w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/04/BIRU-WP-20170401T133648GMT0200.jpg?resize=120%2C120&amp;ssl=1 120w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/04/BIRU-WP-20170401T133648GMT0200.jpg?w=1280&amp;ssl=1 1280w" sizes="(max-width: 300px) 100vw, 300px" /></a><figcaption id="caption-attachment-2122" class="wp-caption-text">My simple test rig to measure sensor accuracy</figcaption></figure>
<h3>Where to buy?</h3>
<p>As always I bought this module from my preferred Online Shop: <a href="https://www.banggood.com/CJMCU-VL53L0X-Laser-ToF-Time-of-Flight-Ranging-Sensor-Module-p-1103114.html?p=6R31122484684201508S&#038;custlinkid=1587591" target="_blank">Banggood</a>. With around USD $12.30 it is more expensive than the <a href="https://blog.squix.org/2016/08/esp8266-peripherals-5-rcw-0001-ultrasonic-range-sensor.html">RCW-0001</a> but the accuracy is also a lot better.</p>
<h3>Summary</h3>
<p>The CJMCU-530 is a affordable and accurate laser-based range sensor. The break-out board offers many features (which I haven&#8217;t tested yet) but it is always promising to have more features to test after the initial run. Compatibility with the ESP8266 is good and you just need to change one line in the sample code to get it running with our preferred WiFi chip.</p>
<h3>Links</h3>
<ul>
<li><a href="https://www.banggood.com/CJMCU-VL53L0X-Laser-ToF-Time-of-Flight-Ranging-Sensor-Module-p-1103114.html?p=6R31122484684201508S&#038;custlinkid=1587591" target="_blank">Shopping Link to Banggood</a></li>
<li><a href="https://github.com/pololu/vl53l0x-arduino" target="_blank">Library from Polulu on Github</a></li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.squix.org/2017/04/esp8266-peripherie-cjmcu-530-tof-distance-sensor.html/feed</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2117</post-id>	</item>
		<item>
		<title>ESP8266 Peripherals: 2.7&#8243; ePaper display</title>
		<link>https://blog.squix.org/2017/02/esp8266-peripherals-2-7-epaper-display.html</link>
					<comments>https://blog.squix.org/2017/02/esp8266-peripherals-2-7-epaper-display.html#comments</comments>
		
		<dc:creator><![CDATA[Daniel Eichhorn]]></dc:creator>
		<pubDate>Thu, 23 Feb 2017 23:00:09 +0000</pubDate>
				<category><![CDATA[ESP8266 Peripherals]]></category>
		<guid isPermaLink="false">https://blog.squix.org/?p=1952</guid>

					<description><![CDATA[This post describes how to connect the 2.7&#8243; ePaper display development module from Embedded Artists to the ESP8266. ePapers are very interesting in the IoT field since they only require power during the update. Depending on the type of display they can then maintain the image ... <p><a class="read-more btn btn-secondary" href="https://blog.squix.org/2017/02/esp8266-peripherals-2-7-epaper-display.html">Read More</a></p>]]></description>
										<content:encoded><![CDATA[<p>This post describes how to connect the 2.7&#8243; ePaper display development module from <a href="https://www.embeddedartists.com/products/displays/lcd_27_epaper.php" target="_blank">Embedded Artists</a> to the ESP8266. ePapers are very interesting in the IoT field since they only require power during the update. Depending on the type of display they can then maintain the image while the connect micro controller goes back to sleep.</p>
<p><span id="more-1952"></span></p>
<p>Connecting this display required a bit of creative thinking. At first I thought that the ESP8266 wouldn&#8217;t have enough pins to connect the display. I decided to strip some aspects and I&#8217;m honestly not 100% sure what the side effects are. The board comes with a temperature sensor and I decided to set the temperature manually to save pins. This probably yields better quality for displayed pictures.</p>
<p>[the_ad_placement id=&#8221;inpostplacement&#8221;]</p>
<p>Another problem was to figure out how the pins on the connector were arranged. Here the following schematic helped:</p>
<p><a href="https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/02/Screen-Shot-2017-02-21-at-08.11.08.png?ssl=1"><img data-recalc-dims="1" decoding="async" data-attachment-id="1955" data-permalink="https://blog.squix.org/2017/02/esp8266-peripherals-2-7-epaper-display.html/screen-shot-2017-02-21-at-08-11-08" data-orig-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/02/Screen-Shot-2017-02-21-at-08.11.08.png?fit=502%2C429&amp;ssl=1" data-orig-size="502,429" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Screen Shot 2017-02-21 at 08.11.08" data-image-description="" data-image-caption="" data-medium-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/02/Screen-Shot-2017-02-21-at-08.11.08.png?fit=300%2C256&amp;ssl=1" data-large-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/02/Screen-Shot-2017-02-21-at-08.11.08.png?fit=502%2C429&amp;ssl=1" class="aligncenter size-medium wp-image-1955" src="https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/02/Screen-Shot-2017-02-21-at-08.11.08.png?resize=300%2C256&#038;ssl=1" alt="" width="300" height="256" srcset="https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/02/Screen-Shot-2017-02-21-at-08.11.08.png?resize=300%2C256&amp;ssl=1 300w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/02/Screen-Shot-2017-02-21-at-08.11.08.png?w=502&amp;ssl=1 502w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>So here is how you connect it:</p>

<table id="tablepress-7" class="tablepress tablepress-id-7">
<thead>
<tr class="row-1">
	<th class="column-1">ePaper Function</th><th class="column-2">ePaper PIN</th><th class="column-3">NodeMCU (Generic)</th><th class="column-4">ESP Function</th>
</tr>
</thead>
<tbody class="row-striping row-hover">
<tr class="row-2">
	<td class="column-1">GND</td><td class="column-2">1</td><td class="column-3">GND</td><td class="column-4"></td>
</tr>
<tr class="row-3">
	<td class="column-1">VCC</td><td class="column-2">2</td><td class="column-3">3V3</td><td class="column-4"></td>
</tr>
<tr class="row-4">
	<td class="column-1">SCK</td><td class="column-2">3</td><td class="column-3">D5 (14)</td><td class="column-4">CLK</td>
</tr>
<tr class="row-5">
	<td class="column-1">MOSI</td><td class="column-2">4</td><td class="column-3">D7 (13)</td><td class="column-4">MOSI</td>
</tr>
<tr class="row-6">
	<td class="column-1">MISO</td><td class="column-2">5</td><td class="column-3">D6 (12)</td><td class="column-4">MISO</td>
</tr>
<tr class="row-7">
	<td class="column-1">SSEL</td><td class="column-2">6</td><td class="column-3">D3 (0)</td><td class="column-4">CS</td>
</tr>
<tr class="row-8">
	<td class="column-1">UART RX</td><td class="column-2">7</td><td class="column-3"></td><td class="column-4"></td>
</tr>
<tr class="row-9">
	<td class="column-1">UART TX</td><td class="column-2">8</td><td class="column-3">D4 (2)</td><td class="column-4"></td>
</tr>
<tr class="row-10">
	<td class="column-1">I2C SCL</td><td class="column-2">9</td><td class="column-3"></td><td class="column-4"></td>
</tr>
<tr class="row-11">
	<td class="column-1">I2C SDA</td><td class="column-2">10</td><td class="column-3"></td><td class="column-4"></td>
</tr>
<tr class="row-12">
	<td class="column-1">GPIO</td><td class="column-2">11</td><td class="column-3"></td><td class="column-4"></td>
</tr>
<tr class="row-13">
	<td class="column-1">EPD Reset</td><td class="column-2">12</td><td class="column-3">D0 (16)</td><td class="column-4"></td>
</tr>
<tr class="row-14">
	<td class="column-1">EPD Panel On</td><td class="column-2">13</td><td class="column-3">D2 (4)</td><td class="column-4"></td>
</tr>
<tr class="row-15">
	<td class="column-1">EPD Discharge</td><td class="column-2">14</td><td class="column-3">D1 (5)</td><td class="column-4"></td>
</tr>
</tbody>
</table>

<p>When you have connected the display download this sample code:<br />
<a href="https://github.com/squix78/ePaperDemo1" target="_blank">https://github.com/squix78/ePaperDemo1</a></p>
<figure id="attachment_1960" aria-describedby="caption-attachment-1960" style="width: 300px" class="wp-caption aligncenter"><a href="https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/02/IMG_0704.jpg?ssl=1"><img data-recalc-dims="1" loading="lazy" decoding="async" data-attachment-id="1960" data-permalink="https://blog.squix.org/2017/02/esp8266-peripherals-2-7-epaper-display.html/img_0704" data-orig-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/02/IMG_0704.jpg?fit=4032%2C3024&amp;ssl=1" data-orig-size="4032,3024" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;2.2&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;iPhone 6s&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1487763612&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;4.15&quot;,&quot;iso&quot;:&quot;100&quot;,&quot;shutter_speed&quot;:&quot;0.033333333333333&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}" data-image-title="IMG_0704" data-image-description="" data-image-caption="&lt;p&gt;The ePaperDemo &lt;/p&gt;
" data-medium-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/02/IMG_0704.jpg?fit=300%2C225&amp;ssl=1" data-large-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/02/IMG_0704.jpg?fit=730%2C548&amp;ssl=1" class="size-medium wp-image-1960" src="https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/02/IMG_0704.jpg?resize=300%2C225&#038;ssl=1" alt="" width="300" height="225" srcset="https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/02/IMG_0704.jpg?resize=300%2C225&amp;ssl=1 300w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/02/IMG_0704.jpg?resize=768%2C576&amp;ssl=1 768w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/02/IMG_0704.jpg?resize=1024%2C768&amp;ssl=1 1024w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/02/IMG_0704.jpg?resize=100%2C75&amp;ssl=1 100w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/02/IMG_0704.jpg?resize=935%2C700&amp;ssl=1 935w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/02/IMG_0704.jpg?w=1460&amp;ssl=1 1460w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2017/02/IMG_0704.jpg?w=2190&amp;ssl=1 2190w" sizes="(max-width: 300px) 100vw, 300px" /></a><figcaption id="caption-attachment-1960" class="wp-caption-text">The ePaperDemo</figcaption></figure>
<p>I adjusted my OLED library for the SSD1306 to the ePaper display. It has the advantage that you first create the content of the ePaper display in a buffer. When you are ready to write everything to the display call the appropriate method and the content of the buffer will be written to the display. The library currently supports the following function:</p>
<ul>
<li>Draw Text at a given location. Define text alignment and get information how much space the text will consume</li>
<li>Create custom font files with <a href="http://oleddisplay.squix.ch/" target="_blank">http://oleddisplay.squix.ch/</a> and include them in your firmware</li>
<li>Draw lines, circles, boxes and fill them</li>
</ul>
<p>I hope to extract a library from it but until then just use the demo code to get started with your own project.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.squix.org/2017/02/esp8266-peripherals-2-7-epaper-display.html/feed</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1952</post-id>	</item>
		<item>
		<title>ESP8266 Peripherals: 5$ RCW-0001 Ultrasonic Range Sensor</title>
		<link>https://blog.squix.org/2016/08/esp8266-peripherals-5-rcw-0001-ultrasonic-range-sensor.html</link>
					<comments>https://blog.squix.org/2016/08/esp8266-peripherals-5-rcw-0001-ultrasonic-range-sensor.html#respond</comments>
		
		<dc:creator><![CDATA[Daniel Eichhorn]]></dc:creator>
		<pubDate>Mon, 15 Aug 2016 19:53:13 +0000</pubDate>
				<category><![CDATA[ESP8266 Peripherals]]></category>
		<guid isPermaLink="false">http://blog.squix.org/?p=759</guid>

					<description><![CDATA[There are many applications for distance measuring: in robotic as a cheap way to sense the environment and detect obstacles, in IoT applications to measure fill levels of containers containing food and in alarm systems to detect intruders &#8211; to name just a few. I ... <p><a class="read-more btn btn-secondary" href="https://blog.squix.org/2016/08/esp8266-peripherals-5-rcw-0001-ultrasonic-range-sensor.html">Read More</a></p>]]></description>
										<content:encoded><![CDATA[<p>There are many applications for distance measuring: in robotic as a cheap way to sense the environment and detect obstacles, in IoT applications to measure fill levels of containers containing food and in alarm systems to detect intruders &#8211; to name just a few.</p>
<p><span id="more-759"></span></p>
<p>I have been trying to use the popular HC-SR04 ultrasonic sensor together with the ESP8266 in the past but I wasn&#8217;t succesful. I guess this sensor needs 5V for proper operation and in order to do that I would have to add a voltage divider for the response pin to accommodate for the 3.3V of the ESP8266. So I went looking for a distance sensor working easily with the ESP8266 and I found it on <a href="https://www.banggood.com/Wholesale-Geekcreit-Ultrasonic-Module-HC-SR04-Distance-Measuring-Ranging-Transducers-Sensor-DC-5V-2-450cm-p-40313.html?p=6R31122484684201508S&#038;custlinkid=1587755" target="_blank">Banggood</a> for less than USD $5.</p>
<figure id="attachment_760" aria-describedby="caption-attachment-760" style="width: 297px" class="wp-caption aligncenter"><a href="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/08/Screenshot-2016-08-15-21.31.59.png?ssl=1"><img data-recalc-dims="1" loading="lazy" decoding="async" data-attachment-id="760" data-permalink="https://blog.squix.org/2016/08/esp8266-peripherals-5-rcw-0001-ultrasonic-range-sensor.html/screenshot-2016-08-15-21-31-59" data-orig-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/08/Screenshot-2016-08-15-21.31.59.png?fit=333%2C336&amp;ssl=1" data-orig-size="333,336" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="RCW-0001" data-image-description="" data-image-caption="&lt;p&gt;RCW-0001&lt;/p&gt;
" data-medium-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/08/Screenshot-2016-08-15-21.31.59.png?fit=297%2C300&amp;ssl=1" data-large-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/08/Screenshot-2016-08-15-21.31.59.png?fit=333%2C336&amp;ssl=1" class="wp-image-760 size-medium" src="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/08/Screenshot-2016-08-15-21.31.59.png?resize=297%2C300&#038;ssl=1" alt="RCW-0001" width="297" height="300" srcset="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/08/Screenshot-2016-08-15-21.31.59.png?resize=297%2C300&amp;ssl=1 297w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/08/Screenshot-2016-08-15-21.31.59.png?resize=300%2C303&amp;ssl=1 300w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/08/Screenshot-2016-08-15-21.31.59.png?resize=120%2C120&amp;ssl=1 120w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/08/Screenshot-2016-08-15-21.31.59.png?w=333&amp;ssl=1 333w" sizes="(max-width: 297px) 100vw, 297px" /></a><figcaption id="caption-attachment-760" class="wp-caption-text">RCW-0001: 3.3V compatible distance sensor</figcaption></figure>
<h1>Get it to work</h1>
<p>To get it to work with the ESP8266 in the Arduino IDE you need a library or write the code yourself. The first library that I tried worked almost immediately. Just download the library from here: <a href="https://bitbucket.org/teckel12/arduino-new-ping/wiki/Home" target="_blank">https://bitbucket.org/teckel12/arduino-new-ping/wiki/Home</a></p>
<p>Then go to <strong>Sketch &gt; Include Library &gt; Add Zip library..</strong> and you are good to go. Sadly the library doesn&#8217;t seem to be listed in the Arduino Library manager but the download and import by ZIP is easy enough. Now go to <strong>File &gt; Examples &gt; NewPing &gt; New Ping Example </strong>which opens a new Sketch window. Now just change the pins according to your wiring. I think most GPIO pins will work but I used D4 and D3 on the NodeMCU. Connect</p>
<ul>
<li>VCC with 3.3V</li>
<li>GND and GND,</li>
<li>TRIG and D4 and</li>
<li>ECHO and D3</li>
</ul>
<p>My Sketch looks like this:</p>
<pre><code>
#include &lt;NewPing.h&gt;

#define TRIGGER_PIN D4 // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN D3 // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 400 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.

void setup() {
 Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.
}

void loop() {
 delay(50); // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
 Serial.print(&amp;quot;Ping: &amp;quot;);
 Serial.print(sonar.ping_cm()); // Send ping, get distance in cm and print result (0 = outside set distance range)
 Serial.println(&amp;quot;cm&amp;quot;);
}
</code></pre>
<p>Then open the serial console and you get a wonderful stream of distance measurements!</p>
<h1>Where to buy?</h1>
<p>Order it now from <a href="/go/ultrasonic-distance-sensor" target="_blank">Banggood</a></p>
<h1></h1>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.squix.org/2016/08/esp8266-peripherals-5-rcw-0001-ultrasonic-range-sensor.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">759</post-id>	</item>
		<item>
		<title>ESP8266: SSD1306 Oled Library Release</title>
		<link>https://blog.squix.org/2016/06/esp8266-ssd1306-oled-library-release.html</link>
					<comments>https://blog.squix.org/2016/06/esp8266-ssd1306-oled-library-release.html#comments</comments>
		
		<dc:creator><![CDATA[Daniel Eichhorn]]></dc:creator>
		<pubDate>Sun, 05 Jun 2016 17:53:22 +0000</pubDate>
				<category><![CDATA[ESP8266 Peripherals]]></category>
		<category><![CDATA[ESP8266]]></category>
		<category><![CDATA[OLED]]></category>
		<category><![CDATA[SSD1306]]></category>
		<category><![CDATA[weather station]]></category>
		<guid isPermaLink="false">http://blog.squix.org/?p=538</guid>

					<description><![CDATA[The &#8220;ESP8266 OLED SSD1306&#8243; is an open source library which allows you to control those pretty OLED modules from our beloved ESP8266 module. Fabrice Weinberg cleaned up all the ugly pieces of code which I initially wrote caused by my near C/C++ illiteracy. He also added support for ... <p><a class="read-more btn btn-secondary" href="https://blog.squix.org/2016/06/esp8266-ssd1306-oled-library-release.html">Read More</a></p>]]></description>
										<content:encoded><![CDATA[<p>The &#8220;<a href="https://github.com/squix78/esp8266-oled-ssd1306">ESP8266 OLED SSD1306&#8243;</a> is an open source library which allows you to control <a href="https://www.banggood.com/Geekcreit-0_96-Inch-4Pin-White-IIC-I2C-OLED-Display-Module-12864-LED-Geekcreit-for-Arduino-products-that-work-with-official-Arduino-boards-p-958196.html?p=0P21061109440201501M&amp;custlinkid=1587780">those pretty OLED modules</a> from our beloved ESP8266 module. <a href="https://github.com/FWeinb">Fabrice Weinberg</a> cleaned up all the ugly pieces of code which I initially wrote caused by my near C/C++ illiteracy. He also added support for Pasko&#8217;s <a href="https://github.com/pasko-zh/brzo_i2c" target="_blank" rel="noopener">BRZO I2C</a> library which is partially written in assembler and allows a much higher throughput over the I2C channel.<span id="more-538"></span></p>
<p>Fabrice&#8217;s video below compares the the two I2C implementations:</p>
<p><iframe loading="lazy" src="https://player.vimeo.com/video/168362918" width="640" height="360" frameborder="0" allowfullscreen="allowfullscreen"></iframe></p>
<p>Other changes:</p>
<ul>
<li>The font format was refactored for better memory efficiency and the web based font generator (<a href="http://oleddisplay.squix.ch/" target="_blank" rel="noopener">http://oleddisplay.squix.ch/</a>) now lets you generate font files for the older library versions or the new ones</li>
<li>The hardware protocol level implementations (SPI, I2C) have been separated from the low level graphical functions. This affects how you instantiate the display classes</li>
<li>To be open for future support of similar displays the core classes were renamed to Oled* instead of SSD1306</li>
<li>More graphical functions have been added, including drawing of circles, non-vertical lines and a progress bar</li>
<li>In case you want to use the display for simple log output you can now use print(..) and println(..) and the library will take care of scrolling. See Fabrice&#8217;s video below:</li>
</ul>
<p>&nbsp;</p>
<p><iframe loading="lazy" src="https://www.youtube.com/embed/8Fiss77A3TE" width="560" height="315" frameborder="0" allowfullscreen="allowfullscreen"></iframe></p>
<p>&nbsp;</p>
<p>For a full list of new features and how to upgrade your existing code please have a look at the comprehensive upgrade guide: <a href="https://github.com/squix78/esp8266-oled-ssd1306/blob/master/UPGRADE-3.0.md">https://github.com/squix78/esp8266-oled-ssd1306/blob/master/UPGRADE-3.0.md</a></p>
<p><strong>Please note:</strong> this release will break with your code based on the older 2.0.0 version. In case you have created fonts you&#8217;ll have to re-generate them as well. This also affects the <a href="https://github.com/squix78/esp8266-weather-station">Weather Station</a> library!</p>
<p>Many thanks again to <strong>Fabrice Weinberg</strong> and all other contributors to make this release possible!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.squix.org/2016/06/esp8266-ssd1306-oled-library-release.html/feed</wfw:commentRss>
			<slash:comments>28</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">538</post-id>	</item>
		<item>
		<title>ESP8266 Peripherals: Indoor Positioning with IR Camera</title>
		<link>https://blog.squix.org/2016/05/esp8266-peripherals-indoor-positioning-with-ir-camera.html</link>
					<comments>https://blog.squix.org/2016/05/esp8266-peripherals-indoor-positioning-with-ir-camera.html#comments</comments>
		
		<dc:creator><![CDATA[Daniel Eichhorn]]></dc:creator>
		<pubDate>Sat, 28 May 2016 12:21:16 +0000</pubDate>
				<category><![CDATA[ESP8266 Peripherals]]></category>
		<category><![CDATA[ESP8266]]></category>
		<category><![CDATA[Indoor Positioning]]></category>
		<category><![CDATA[Positioning IR Camera]]></category>
		<category><![CDATA[Sensor]]></category>
		<guid isPermaLink="false">http://blog.squix.org/?p=516</guid>

					<description><![CDATA[The sensor I&#8217;m going to talk about here is a very powerful one. And you actually might have a very similar one in your home somewhere. The DF Robot Positioning IR Camera uses the same or similar module that is built into the Nintendo Wiimote ... <p><a class="read-more btn btn-secondary" href="https://blog.squix.org/2016/05/esp8266-peripherals-indoor-positioning-with-ir-camera.html">Read More</a></p>]]></description>
										<content:encoded><![CDATA[<p>The sensor I&#8217;m going to talk about here is a very powerful one. And you actually might have a very similar one in your home somewhere. The DF Robot Positioning IR Camera uses the same or similar module that is built into the Nintendo Wiimote controller. The sensor module is capable of simultaneously detect up to four sources of IR light and make them accessible through a I2C interface.<span id="more-516"></span></p>
<figure id="attachment_517" aria-describedby="caption-attachment-517" style="width: 300px" class="wp-caption aligncenter"><a href="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/IrCameraSensor.jpg?ssl=1"><img data-recalc-dims="1" loading="lazy" decoding="async" data-attachment-id="517" data-permalink="https://blog.squix.org/2016/05/esp8266-peripherals-indoor-positioning-with-ir-camera.html/ircamerasensor" data-orig-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/IrCameraSensor.jpg?fit=900%2C600&amp;ssl=1" data-orig-size="900,600" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="IrCameraSensor" data-image-description="" data-image-caption="&lt;p&gt;DF Robot IR Camera Sensor&lt;/p&gt;
" data-medium-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/IrCameraSensor.jpg?fit=300%2C200&amp;ssl=1" data-large-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/IrCameraSensor.jpg?fit=730%2C487&amp;ssl=1" class="wp-image-517 size-medium" src="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/IrCameraSensor.jpg?resize=300%2C200&#038;ssl=1" alt="DF Robot IR Camera Sensor" width="300" height="200" srcset="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/IrCameraSensor.jpg?resize=300%2C200&amp;ssl=1 300w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/IrCameraSensor.jpg?resize=768%2C512&amp;ssl=1 768w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/IrCameraSensor.jpg?w=900&amp;ssl=1 900w" sizes="(max-width: 300px) 100vw, 300px" /></a><figcaption id="caption-attachment-517" class="wp-caption-text">DF Robot IR Camera Sensor</figcaption></figure>
<p>&nbsp;</p>
<p><strong>Specification</strong></p>
<ul>
<li>Operating voltage: 3.3-5v</li>
<li>Interface: I2C</li>
<li>Detecting distance: 0~3m</li>
<li>Horizontal detecting angle: 33 degrees</li>
<li>Vertical detecting angle: 23 degrees</li>
<li>Dimensions: 32mm x 16mm(1.26&#215;0.63&#8243;)</li>
<li>Resolution is 128&#215;96 pixel, with 8 sub pixels, so 1024&#215;768</li>
<li>track four objects (IR emitting or reflecting objects)</li>
<li>Cost: USD ~$23.55</li>
</ul>
<p>&nbsp;</p>
<p><strong>How does it work? </strong></p>
<p>The chip in the sensor module does all the hard work for you: filtering the noise and figuring out the strongest sources of light that passed through the IR filter in front of the camera. It will send then 4 pairs of x and y coordinates through the I2C interface to your ESP8266 (or any other MCU). If no IR source was detected the pair will just return the maximal value for 2^10 = 1023. If a source has been detected it will return the coordinates with a resolution of 1024&#215;768 pixels to you.</p>
<p>&nbsp;</p>
<p><strong>How to wire it to the ESP8266? How to program?</strong></p>
<p>Just connect the RED pin to 3.3V, the BLACK to GND and the GREEN (e.g. D6) and YELLOW (e.g. D5) to a free GPIO pin. Then use the following script, adapt the GPIO pins if necessary and upload the script to your ESP8266:<br />
<script src="https://gist.github.com/squix78/0f472c82f8d4ea7a4aa8ebd0f040a687.js"></script></p>
<p><strong>How to visualize the results?</strong></p>
<p>I used <a href="https://processing.org/">Processing</a> to visualize the data points the ESP8266 returns over  the serial line. Here is the <a href="https://gist.github.com/squix78/cfdd85eb0204689b5f9c87cc6b151256">Processing script</a>:<br />
<script src="https://gist.github.com/squix78/cfdd85eb0204689b5f9c87cc6b151256.js"></script></p>
<p>&nbsp;</p>
<p>Then I used an IR bar I still had from my Nintendo Wii and waved it in front of the camera.</p>
<figure id="attachment_519" aria-describedby="caption-attachment-519" style="width: 300px" class="wp-caption aligncenter"><a href="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/image-17.jpeg?ssl=1"><img data-recalc-dims="1" loading="lazy" decoding="async" data-attachment-id="519" data-permalink="https://blog.squix.org/2016/05/esp8266-peripherals-indoor-positioning-with-ir-camera.html/image-18" data-orig-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/image-17.jpeg?fit=4032%2C3024&amp;ssl=1" data-orig-size="4032,3024" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;2.2&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;iPhone 6s&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1464443407&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;4.15&quot;,&quot;iso&quot;:&quot;200&quot;,&quot;shutter_speed&quot;:&quot;0.03030303030303&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}" data-image-title="IR Bar" data-image-description="" data-image-caption="&lt;p&gt;Wireless IR Bar from my Wii&lt;/p&gt;
" data-medium-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/image-17.jpeg?fit=300%2C225&amp;ssl=1" data-large-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/image-17.jpeg?fit=730%2C548&amp;ssl=1" class="wp-image-519 size-medium" src="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/image-17.jpeg?resize=300%2C225&#038;ssl=1" alt="Wireless IR Bar from my Wii" width="300" height="225" srcset="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/image-17.jpeg?resize=300%2C225&amp;ssl=1 300w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/image-17.jpeg?resize=768%2C576&amp;ssl=1 768w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/image-17.jpeg?resize=1024%2C768&amp;ssl=1 1024w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/image-17.jpeg?w=1460&amp;ssl=1 1460w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/image-17.jpeg?w=2190&amp;ssl=1 2190w" sizes="(max-width: 300px) 100vw, 300px" /></a><figcaption id="caption-attachment-519" class="wp-caption-text">Wireless IR Bar from my Wii</figcaption></figure>
<p>And here is the result:</p>
<p><iframe loading="lazy" src="https://www.youtube.com/embed/3U0v_xFz5uE" width="420" height="315" frameborder="0" allowfullscreen="allowfullscreen"></iframe></p>
<p>&nbsp;</p>
<p><strong>What can you use the sensor for?</strong></p>
<p>I bought it because I plan to help my robot navigate indoor with the help of the IR Camera. I&#8217;m not yet sure if then the camera should be on the robot and the IR sources all over the room or if several cameras should track the IR sources on the Robot and send its coordinates to the robot.</p>
<p>You could also build a whiteboard or a head tracker. Just search for Wiimote hack on Google and you&#8217;ll get plenty of ideas what you can do with the sensor!</p>
<p><strong>Where to buy?</strong></p>
<ul>
<li><a href="http://www.dfrobot.com/index.php?route=product/product&amp;product_id=1088">DF Robot</a></li>
<li><a href="http://www.aliexpress.com/item/Positioning-IR-Camera/32598576585.html">Aliexpress</a></li>
</ul>
<p>&nbsp;</p>
<p><strong>Where can I get more resources?</strong></p>
<ul>
<li><a href="http://www.dfrobot.com/wiki/index.php/Positioning_ir_camera">http://www.dfrobot.com/wiki/index.php/Positioning_ir_camera</a></li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.squix.org/2016/05/esp8266-peripherals-indoor-positioning-with-ir-camera.html/feed</wfw:commentRss>
			<slash:comments>9</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">516</post-id>	</item>
		<item>
		<title>ESP8266 Peripherals: Mini PIR Motion Sensor</title>
		<link>https://blog.squix.org/2016/05/esp8266-peripherals-mini-pir-motion-sensor.html</link>
					<comments>https://blog.squix.org/2016/05/esp8266-peripherals-mini-pir-motion-sensor.html#comments</comments>
		
		<dc:creator><![CDATA[Daniel Eichhorn]]></dc:creator>
		<pubDate>Sat, 14 May 2016 20:04:48 +0000</pubDate>
				<category><![CDATA[ESP8266 Peripherals]]></category>
		<guid isPermaLink="false">http://blog.squix.org/?p=435</guid>

					<description><![CDATA[&#160; The ESP8266 is all about Internet of Things, right? So lets start sensing something in the real world! What about (human) presence in your apartment? There are various ways to do that but one of the most common type is sensing with pyro electric sensors ... <p><a class="read-more btn btn-secondary" href="https://blog.squix.org/2016/05/esp8266-peripherals-mini-pir-motion-sensor.html">Read More</a></p>]]></description>
										<content:encoded><![CDATA[<p>&nbsp;</p>
<p>The ESP8266 is all about Internet of Things, right? So lets start sensing something in the real world! What about (human) presence in your apartment? There are various ways to do that but one of the most common type is sensing with pyro electric sensors which also called passive infrared (PIR) sensors (see <a href="https://en.wikipedia.org/wiki/Passive_infrared_sensor" target="_blank">Wikipedia</a>). The one I am presenting in this post is also a PIR sensor; a really tiny one and with its 3.3V support very suitable for the ESP8266.<span id="more-435"></span></p>
<figure id="attachment_461" aria-describedby="caption-attachment-461" style="width: 300px" class="wp-caption aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" data-attachment-id="461" data-permalink="https://blog.squix.org/2016/05/esp8266-peripherals-mini-pir-motion-sensor.html/pirsensor" data-orig-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/PIRSensor.jpg?fit=600%2C600&amp;ssl=1" data-orig-size="600,600" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;16&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;Canon EOS 550D&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1446652728&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;55&quot;,&quot;iso&quot;:&quot;200&quot;,&quot;shutter_speed&quot;:&quot;0.008&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="PIRSensor" data-image-description="" data-image-caption="&lt;p&gt;PIR Sensor with 3.3V support&lt;/p&gt;
" data-medium-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/PIRSensor.jpg?fit=300%2C300&amp;ssl=1" data-large-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/PIRSensor.jpg?fit=600%2C600&amp;ssl=1" class="size-medium wp-image-461" src="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/PIRSensor.jpg?resize=300%2C300&#038;ssl=1" alt="PIR Sensor with 3.3V support" width="300" height="300" srcset="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/PIRSensor.jpg?resize=300%2C300&amp;ssl=1 300w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/PIRSensor.jpg?resize=150%2C150&amp;ssl=1 150w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/PIRSensor.jpg?resize=120%2C120&amp;ssl=1 120w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/PIRSensor.jpg?w=600&amp;ssl=1 600w" sizes="(max-width: 300px) 100vw, 300px" /><figcaption id="caption-attachment-461" class="wp-caption-text">PIR Sensor with 3.3V support</figcaption></figure>
<p>&nbsp;</p>
<p><strong>Features</strong></p>
<ul>
<li>Working voltage: DC 2.7-12V</li>
<li>Static power consumption: I measured between 0.016mA (source detected) and 0.076mA (sensor active)</li>
<li>Delay time: when detecting a source the sensor will hold the output high for 2 seconds</li>
<li>Sensing range: ≤100 degree cone angle, about 2m, possibly more in friendlier environmentWorking</li>
<li>Total size: Approx. 12mm x 25 mm</li>
</ul>
<div></div>
<p>&nbsp;</p>
<div>
<div><strong>How to use it with the ESP8266?</strong></div>
<div></div>
<div>Since the Mini PIR sensor can handle 3.3V its output level will be ESP8266 compatible. It only has three pins, one for Vin, GND and Data (output) pin. You can wire it up like this:</div>
<div>
<figure id="attachment_463" aria-describedby="caption-attachment-463" style="width: 177px" class="wp-caption aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" data-attachment-id="463" data-permalink="https://blog.squix.org/2016/05/esp8266-peripherals-mini-pir-motion-sensor.html/wiringminipir" data-orig-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/WiringMiniPIR.jpg?fit=196%2C332&amp;ssl=1" data-orig-size="196,332" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Wiring Mini PIR with ESP8266" data-image-description="" data-image-caption="&lt;p&gt;Wiring Mini PIR with ESP8266&lt;/p&gt;
" data-medium-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/WiringMiniPIR.jpg?fit=177%2C300&amp;ssl=1" data-large-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/WiringMiniPIR.jpg?fit=196%2C332&amp;ssl=1" class="size-medium wp-image-463" src="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/WiringMiniPIR.jpg?resize=177%2C300&#038;ssl=1" alt="Wiring Mini PIR with ESP8266" width="177" height="300" srcset="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/WiringMiniPIR.jpg?resize=177%2C300&amp;ssl=1 177w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/WiringMiniPIR.jpg?w=196&amp;ssl=1 196w" sizes="(max-width: 177px) 100vw, 177px" /><figcaption id="caption-attachment-463" class="wp-caption-text">Wiring Mini PIR with ESP8266</figcaption></figure>
<p>Connect</p>
<ul>
<li>3.3V with Vin (left)</li>
<li>D2 with Data (middle)</li>
<li>GND with GND (right)</li>
</ul>
<p>then paste this code to your Arduino IDE and upload it to the connected NodeMCU:</p>
<pre><code>
int oldValue = 0;

void setup() {
  // put your setup code here, to run once:
  pinMode(D2, INPUT_PULLUP);
  Serial.begin(115200);

}

void loop() {
  int value = digitalRead(D2);
  if (value != oldValue) {
    Serial.println("New Value: " + String(value));
    oldValue = value;
    if (value == 1) {
      Serial.println("##########################");
    }
  }
  delay(100);
}
</code></pre>
<p>&nbsp;</p>
<p>Open the serial console and you should see movement in front of the sensor as output in your serial console.</p>
</div>
<p>&nbsp;</p>
<p><strong>Where to use?</strong></p>
<p>The fact that there is no need of additional components makes this motion sensor very useful for a series of applications. While not detecting any heat source the sensor consumes 0.076mA and in the two seconds after detection even goes down to 0.016mA. So in theory the sensor alone could run on a 1200mAh battery for nearly two years.  Together with a clever circuit you can put the ESP8266&#8217;s CH_EN (chip enable) pin low and send it to an ultra deep sleep (0.5µA!!!) and only wake it up when motion has been detected. Read more in this post over at the ESP8266 forum how it can be done: <a href="http://www.esp8266.com/viewtopic.php?f=11&amp;t=4458" target="_blank">http://www.esp8266.com/viewtopic.php?f=11&amp;t=4458</a></p>
<p>The schema looks promising but I haven&#8217;t tried it out yet.<img data-recalc-dims="1" loading="lazy" decoding="async" data-attachment-id="464" data-permalink="https://blog.squix.org/2016/05/esp8266-peripherals-mini-pir-motion-sensor.html/pir-esp8266-low-power" data-orig-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/PIR-ESP8266-Low-Power.png?fit=692%2C223&amp;ssl=1" data-orig-size="692,223" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;PIR ESP8266 Low Power&quot;,&quot;orientation&quot;:&quot;0&quot;,&quot;is_drawit&quot;:&quot;1&quot;,&quot;drawit_xml&quot;:&quot;&lt;?xml version=\&quot;1.0\&quot;?&gt;\n&lt;mxGraphModel dx=\&quot;731\&quot; dy=\&quot;348\&quot; grid=\&quot;0\&quot; gridSize=\&quot;10\&quot; guides=\&quot;1\&quot; tooltips=\&quot;1\&quot; connect=\&quot;1\&quot; arrows=\&quot;1\&quot; fold=\&quot;1\&quot; page=\&quot;0\&quot; pageScale=\&quot;1\&quot; pageWidth=\&quot;826\&quot; pageHeight=\&quot;1169\&quot; background=\&quot;#ffffff\&quot; math=\&quot;0\&quot; shadow=\&quot;0\&quot; pan=\&quot;1\&quot; zoom=\&quot;1\&quot; resize=\&quot;1\&quot; fit=\&quot;1\&quot; nav=\&quot;0\&quot; border=\&quot;0\&quot; links=\&quot;1\&quot;&gt;&lt;root&gt;&lt;mxCell id=\&quot;0\&quot;\/&gt;&lt;mxCell id=\&quot;1\&quot; parent=\&quot;0\&quot;\/&gt;&lt;mxCell id=\&quot;15\&quot; style=\&quot;rounded=0;html=1;exitX=0.25;exitY=0;endArrow=none;endFill=0;jettySize=auto;orthogonalLoop=1;\&quot; edge=\&quot;1\&quot; parent=\&quot;1\&quot; source=\&quot;2\&quot;&gt;&lt;mxGeometry relative=\&quot;1\&quot; as=\&quot;geometry\&quot;&gt;&lt;mxPoint x=\&quot;173\&quot; y=\&quot;120\&quot; as=\&quot;targetPoint\&quot;\/&gt;&lt;\/mxGeometry&gt;&lt;\/mxCell&gt;&lt;mxCell id=\&quot;19\&quot; style=\&quot;edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;exitX=0.25;exitY=0;endArrow=none;endFill=0;jettySize=auto;orthogonalLoop=1;\&quot; edge=\&quot;1\&quot; parent=\&quot;1\&quot; source=\&quot;2\&quot;&gt;&lt;mxGeometry relative=\&quot;1\&quot; as=\&quot;geometry\&quot;&gt;&lt;mxPoint x=\&quot;40\&quot; y=\&quot;120\&quot; as=\&quot;targetPoint\&quot;\/&gt;&lt;Array as=\&quot;points\&quot;&gt;&lt;mxPoint x=\&quot;173\&quot; y=\&quot;120\&quot;\/&gt;&lt;\/Array&gt;&lt;\/mxGeometry&gt;&lt;\/mxCell&gt;&lt;mxCell id=\&quot;28\&quot; value=\&quot;VCC\&quot; style=\&quot;text;html=1;resizable=0;points=[];align=center;verticalAlign=middle;labelBackgroundColor=#ffffff;\&quot; vertex=\&quot;1\&quot; connectable=\&quot;0\&quot; parent=\&quot;19\&quot;&gt;&lt;mxGeometry x=\&quot;-0.7572\&quot; y=\&quot;-1\&quot; relative=\&quot;1\&quot; as=\&quot;geometry\&quot;&gt;&lt;mxPoint as=\&quot;offset\&quot;\/&gt;&lt;\/mxGeometry&gt;&lt;\/mxCell&gt;&lt;mxCell id=\&quot;20\&quot; style=\&quot;edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;exitX=0.75;exitY=0;endArrow=none;endFill=0;jettySize=auto;orthogonalLoop=1;\&quot; edge=\&quot;1\&quot; parent=\&quot;1\&quot; source=\&quot;2\&quot;&gt;&lt;mxGeometry relative=\&quot;1\&quot; as=\&quot;geometry\&quot;&gt;&lt;mxPoint x=\&quot;40\&quot; y=\&quot;120\&quot; as=\&quot;targetPoint\&quot;\/&gt;&lt;Array as=\&quot;points\&quot;&gt;&lt;mxPoint x=\&quot;218\&quot; y=\&quot;120\&quot;\/&gt;&lt;\/Array&gt;&lt;\/mxGeometry&gt;&lt;\/mxCell&gt;&lt;mxCell id=\&quot;21\&quot; style=\&quot;edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;exitX=0.75;exitY=0;endArrow=none;endFill=0;jettySize=auto;orthogonalLoop=1;\&quot; edge=\&quot;1\&quot; parent=\&quot;1\&quot; source=\&quot;2\&quot;&gt;&lt;mxGeometry relative=\&quot;1\&quot; as=\&quot;geometry\&quot;&gt;&lt;mxPoint x=\&quot;680\&quot; y=\&quot;120\&quot; as=\&quot;targetPoint\&quot;\/&gt;&lt;Array as=\&quot;points\&quot;&gt;&lt;mxPoint x=\&quot;218\&quot; y=\&quot;120\&quot;\/&gt;&lt;\/Array&gt;&lt;\/mxGeometry&gt;&lt;\/mxCell&gt;&lt;mxCell id=\&quot;29\&quot; value=\&quot;RST\&quot; style=\&quot;text;html=1;resizable=0;points=[];align=center;verticalAlign=middle;labelBackgroundColor=#ffffff;\&quot; vertex=\&quot;1\&quot; connectable=\&quot;0\&quot; parent=\&quot;21\&quot;&gt;&lt;mxGeometry x=\&quot;-0.9084\&quot; y=\&quot;-1\&quot; relative=\&quot;1\&quot; as=\&quot;geometry\&quot;&gt;&lt;mxPoint as=\&quot;offset\&quot;\/&gt;&lt;\/mxGeometry&gt;&lt;\/mxCell&gt;&lt;mxCell id=\&quot;23\&quot; style=\&quot;edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;exitX=0.5;exitY=1;endArrow=none;endFill=0;jettySize=auto;orthogonalLoop=1;\&quot; edge=\&quot;1\&quot; parent=\&quot;1\&quot; source=\&quot;2\&quot;&gt;&lt;mxGeometry relative=\&quot;1\&quot; as=\&quot;geometry\&quot;&gt;&lt;mxPoint x=\&quot;40\&quot; y=\&quot;320\&quot; as=\&quot;targetPoint\&quot;\/&gt;&lt;Array as=\&quot;points\&quot;&gt;&lt;mxPoint x=\&quot;195\&quot; y=\&quot;320\&quot;\/&gt;&lt;\/Array&gt;&lt;\/mxGeometry&gt;&lt;\/mxCell&gt;&lt;mxCell id=\&quot;24\&quot; style=\&quot;edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;exitX=0.5;exitY=1;endArrow=none;endFill=0;jettySize=auto;orthogonalLoop=1;\&quot; edge=\&quot;1\&quot; parent=\&quot;1\&quot; source=\&quot;2\&quot;&gt;&lt;mxGeometry relative=\&quot;1\&quot; as=\&quot;geometry\&quot;&gt;&lt;mxPoint x=\&quot;680\&quot; y=\&quot;320\&quot; as=\&quot;targetPoint\&quot;\/&gt;&lt;Array as=\&quot;points\&quot;&gt;&lt;mxPoint x=\&quot;195\&quot; y=\&quot;320\&quot;\/&gt;&lt;\/Array&gt;&lt;\/mxGeometry&gt;&lt;\/mxCell&gt;&lt;mxCell id=\&quot;27\&quot; value=\&quot;GND\&quot; style=\&quot;text;html=1;resizable=0;points=[];align=center;verticalAlign=middle;labelBackgroundColor=#ffffff;\&quot; vertex=\&quot;1\&quot; connectable=\&quot;0\&quot; parent=\&quot;24\&quot;&gt;&lt;mxGeometry x=\&quot;-0.9352\&quot; relative=\&quot;1\&quot; as=\&quot;geometry\&quot;&gt;&lt;mxPoint as=\&quot;offset\&quot;\/&gt;&lt;\/mxGeometry&gt;&lt;\/mxCell&gt;&lt;mxCell id=\&quot;2\&quot; value=\&quot;ESP8266\&quot; style=\&quot;whiteSpace=wrap;html=1;\&quot; vertex=\&quot;1\&quot; parent=\&quot;1\&quot;&gt;&lt;mxGeometry x=\&quot;150\&quot; y=\&quot;160\&quot; width=\&quot;90\&quot; height=\&quot;120\&quot; as=\&quot;geometry\&quot;\/&gt;&lt;\/mxCell&gt;&lt;mxCell id=\&quot;22\&quot; style=\&quot;edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;exitX=0.5;exitY=0;endArrow=none;endFill=0;jettySize=auto;orthogonalLoop=1;\&quot; edge=\&quot;1\&quot; parent=\&quot;1\&quot; source=\&quot;3\&quot;&gt;&lt;mxGeometry relative=\&quot;1\&quot; as=\&quot;geometry\&quot;&gt;&lt;mxPoint x=\&quot;680\&quot; y=\&quot;120\&quot; as=\&quot;targetPoint\&quot;\/&gt;&lt;Array as=\&quot;points\&quot;&gt;&lt;mxPoint x=\&quot;510\&quot; y=\&quot;120\&quot;\/&gt;&lt;\/Array&gt;&lt;\/mxGeometry&gt;&lt;\/mxCell&gt;&lt;mxCell id=\&quot;30\&quot; value=\&quot;VCC\&quot; style=\&quot;text;html=1;resizable=0;points=[];align=center;verticalAlign=middle;labelBackgroundColor=#ffffff;\&quot; vertex=\&quot;1\&quot; connectable=\&quot;0\&quot; parent=\&quot;22\&quot;&gt;&lt;mxGeometry x=\&quot;-0.7905\&quot; y=\&quot;-1\&quot; relative=\&quot;1\&quot; as=\&quot;geometry\&quot;&gt;&lt;mxPoint as=\&quot;offset\&quot;\/&gt;&lt;\/mxGeometry&gt;&lt;\/mxCell&gt;&lt;mxCell id=\&quot;25\&quot; style=\&quot;edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;exitX=0.5;exitY=1;endArrow=none;endFill=0;jettySize=auto;orthogonalLoop=1;\&quot; edge=\&quot;1\&quot; parent=\&quot;1\&quot; source=\&quot;3\&quot;&gt;&lt;mxGeometry relative=\&quot;1\&quot; as=\&quot;geometry\&quot;&gt;&lt;mxPoint x=\&quot;680\&quot; y=\&quot;320\&quot; as=\&quot;targetPoint\&quot;\/&gt;&lt;Array as=\&quot;points\&quot;&gt;&lt;mxPoint x=\&quot;510\&quot; y=\&quot;320\&quot;\/&gt;&lt;\/Array&gt;&lt;\/mxGeometry&gt;&lt;\/mxCell&gt;&lt;mxCell id=\&quot;31\&quot; value=\&quot;GND\&quot; style=\&quot;text;html=1;resizable=0;points=[];align=center;verticalAlign=middle;labelBackgroundColor=#ffffff;\&quot; vertex=\&quot;1\&quot; connectable=\&quot;0\&quot; parent=\&quot;25\&quot;&gt;&lt;mxGeometry x=\&quot;-0.7714\&quot; y=\&quot;1\&quot; relative=\&quot;1\&quot; as=\&quot;geometry\&quot;&gt;&lt;mxPoint as=\&quot;offset\&quot;\/&gt;&lt;\/mxGeometry&gt;&lt;\/mxCell&gt;&lt;mxCell id=\&quot;3\&quot; value=\&quot;PIR\&quot; style=\&quot;whiteSpace=wrap;html=1;\&quot; vertex=\&quot;1\&quot; parent=\&quot;1\&quot;&gt;&lt;mxGeometry x=\&quot;450\&quot; y=\&quot;160\&quot; width=\&quot;120\&quot; height=\&quot;120\&quot; as=\&quot;geometry\&quot;\/&gt;&lt;\/mxCell&gt;&lt;mxCell id=\&quot;9\&quot; style=\&quot;edgeStyle=none;rounded=0;html=1;exitX=1;exitY=0.5;exitPerimeter=0;entryX=0;entryY=0.5;entryPerimeter=0;endArrow=none;endFill=0;jettySize=auto;orthogonalLoop=1;\&quot; edge=\&quot;1\&quot; parent=\&quot;1\&quot; source=\&quot;4\&quot; target=\&quot;7\&quot;&gt;&lt;mxGeometry relative=\&quot;1\&quot; as=\&quot;geometry\&quot;\/&gt;&lt;\/mxCell&gt;&lt;mxCell id=\&quot;10\&quot; style=\&quot;edgeStyle=none;rounded=0;html=1;exitX=0;exitY=0.5;exitPerimeter=0;entryX=0.017;entryY=0.408;entryPerimeter=0;endArrow=none;endFill=0;jettySize=auto;orthogonalLoop=1;\&quot; edge=\&quot;1\&quot; parent=\&quot;1\&quot; source=\&quot;4\&quot; target=\&quot;3\&quot;&gt;&lt;mxGeometry relative=\&quot;1\&quot; as=\&quot;geometry\&quot;\/&gt;&lt;\/mxCell&gt;&lt;mxCell id=\&quot;32\&quot; value=\&quot;DATA\&quot; style=\&quot;text;html=1;resizable=0;points=[];align=center;verticalAlign=middle;labelBackgroundColor=#ffffff;\&quot; vertex=\&quot;1\&quot; connectable=\&quot;0\&quot; parent=\&quot;10\&quot;&gt;&lt;mxGeometry x=\&quot;0.2622\&quot; y=\&quot;-1\&quot; relative=\&quot;1\&quot; as=\&quot;geometry\&quot;&gt;&lt;mxPoint as=\&quot;offset\&quot;\/&gt;&lt;\/mxGeometry&gt;&lt;\/mxCell&gt;&lt;mxCell id=\&quot;11\&quot; style=\&quot;edgeStyle=none;rounded=0;html=1;exitX=1;exitY=0.5;exitPerimeter=0;entryX=1.011;entryY=0.425;entryPerimeter=0;endArrow=none;endFill=0;jettySize=auto;orthogonalLoop=1;\&quot; edge=\&quot;1\&quot; parent=\&quot;1\&quot; source=\&quot;4\&quot; target=\&quot;2\&quot;&gt;&lt;mxGeometry relative=\&quot;1\&quot; as=\&quot;geometry\&quot;\/&gt;&lt;\/mxCell&gt;&lt;mxCell id=\&quot;4\&quot; value=\&quot;\&quot; style=\&quot;fillColor=#000000;verticalLabelPosition=bottom;shadow=0;dashed=0;align=center;fillColor=#ffffff;html=1;verticalAlign=top;strokeWidth=1;shape=mxgraph.electrical.diodes.diode;rotation=180;\&quot; vertex=\&quot;1\&quot; parent=\&quot;1\&quot;&gt;&lt;mxGeometry x=\&quot;290\&quot; y=\&quot;200\&quot; width=\&quot;40\&quot; height=\&quot;20\&quot; as=\&quot;geometry\&quot;\/&gt;&lt;\/mxCell&gt;&lt;mxCell id=\&quot;8\&quot; style=\&quot;edgeStyle=none;rounded=0;html=1;exitX=1;exitY=0.5;exitPerimeter=0;entryX=1;entryY=0.5;entryPerimeter=0;jettySize=auto;orthogonalLoop=1;endArrow=none;endFill=0;\&quot; edge=\&quot;1\&quot; parent=\&quot;1\&quot; source=\&quot;5\&quot; target=\&quot;4\&quot;&gt;&lt;mxGeometry relative=\&quot;1\&quot; as=\&quot;geometry\&quot;\/&gt;&lt;\/mxCell&gt;&lt;mxCell id=\&quot;5\&quot; value=\&quot;1K\&quot; style=\&quot;verticalLabelPosition=bottom;shadow=0;dashed=0;align=center;fillColor=#ffffff;html=1;verticalAlign=top;strokeWidth=1;shape=mxgraph.electrical.resistors.resistor_1;\&quot; vertex=\&quot;1\&quot; parent=\&quot;1\&quot;&gt;&lt;mxGeometry x=\&quot;240\&quot; y=\&quot;170\&quot; width=\&quot;50\&quot; height=\&quot;10\&quot; as=\&quot;geometry\&quot;\/&gt;&lt;\/mxCell&gt;&lt;mxCell id=\&quot;6\&quot; value=\&quot;1K\&quot; style=\&quot;verticalLabelPosition=bottom;shadow=0;dashed=0;align=center;fillColor=#ffffff;html=1;verticalAlign=top;strokeWidth=1;shape=mxgraph.electrical.resistors.resistor_1;\&quot; vertex=\&quot;1\&quot; parent=\&quot;1\&quot;&gt;&lt;mxGeometry x=\&quot;240\&quot; y=\&quot;250\&quot; width=\&quot;50\&quot; height=\&quot;10\&quot; as=\&quot;geometry\&quot;\/&gt;&lt;\/mxCell&gt;&lt;mxCell id=\&quot;26\&quot; style=\&quot;edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;exitX=1;exitY=0.5;exitPerimeter=0;endArrow=none;endFill=0;jettySize=auto;orthogonalLoop=1;\&quot; edge=\&quot;1\&quot; parent=\&quot;1\&quot; source=\&quot;7\&quot;&gt;&lt;mxGeometry relative=\&quot;1\&quot; as=\&quot;geometry\&quot;&gt;&lt;mxPoint x=\&quot;680\&quot; y=\&quot;320\&quot; as=\&quot;targetPoint\&quot;\/&gt;&lt;Array as=\&quot;points\&quot;&gt;&lt;mxPoint x=\&quot;290\&quot; y=\&quot;320\&quot;\/&gt;&lt;\/Array&gt;&lt;\/mxGeometry&gt;&lt;\/mxCell&gt;&lt;mxCell id=\&quot;7\&quot; value=\&quot;10K\&quot; style=\&quot;verticalLabelPosition=bottom;shadow=0;dashed=0;align=center;fillColor=#ffffff;html=1;verticalAlign=top;strokeWidth=1;shape=mxgraph.electrical.resistors.resistor_1;rotation=0;direction=south;\&quot; vertex=\&quot;1\&quot; parent=\&quot;1\&quot;&gt;&lt;mxGeometry x=\&quot;285\&quot; y=\&quot;255\&quot; width=\&quot;10\&quot; height=\&quot;50\&quot; as=\&quot;geometry\&quot;\/&gt;&lt;\/mxCell&gt;&lt;mxCell id=\&quot;33\&quot; value=\&quot;CH_PD\&quot; style=\&quot;text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;overflow=hidden;\&quot; vertex=\&quot;1\&quot; parent=\&quot;1\&quot;&gt;&lt;mxGeometry x=\&quot;190\&quot; y=\&quot;200\&quot; width=\&quot;60\&quot; height=\&quot;20\&quot; as=\&quot;geometry\&quot;\/&gt;&lt;\/mxCell&gt;&lt;mxCell id=\&quot;35\&quot; value=\&quot;GPIO0\&quot; style=\&quot;text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;overflow=hidden;\&quot; vertex=\&quot;1\&quot; parent=\&quot;1\&quot;&gt;&lt;mxGeometry x=\&quot;190\&quot; y=\&quot;245\&quot; width=\&quot;60\&quot; height=\&quot;20\&quot; as=\&quot;geometry\&quot;\/&gt;&lt;\/mxCell&gt;&lt;mxCell id=\&quot;36\&quot; value=\&quot;GPIO2\&quot; style=\&quot;text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;overflow=hidden;\&quot; vertex=\&quot;1\&quot; parent=\&quot;1\&quot;&gt;&lt;mxGeometry x=\&quot;190\&quot; y=\&quot;165\&quot; width=\&quot;60\&quot; height=\&quot;20\&quot; as=\&quot;geometry\&quot;\/&gt;&lt;\/mxCell&gt;&lt;mxCell id=\&quot;37\&quot; value=\&quot;3.3V\&quot; style=\&quot;text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;overflow=hidden;\&quot; vertex=\&quot;1\&quot; parent=\&quot;1\&quot;&gt;&lt;mxGeometry x=\&quot;669\&quot; y=\&quot;110\&quot; width=\&quot;60\&quot; height=\&quot;20\&quot; as=\&quot;geometry\&quot;\/&gt;&lt;\/mxCell&gt;&lt;mxCell id=\&quot;38\&quot; value=\&quot;GND\&quot; style=\&quot;text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;overflow=hidden;\&quot; vertex=\&quot;1\&quot; parent=\&quot;1\&quot;&gt;&lt;mxGeometry x=\&quot;669\&quot; y=\&quot;310\&quot; width=\&quot;60\&quot; height=\&quot;20\&quot; as=\&quot;geometry\&quot;\/&gt;&lt;\/mxCell&gt;&lt;\/root&gt;&lt;\/mxGraphModel&gt;\n&quot;}" data-image-title="PIR-ESP8266-Low-Power" data-image-description="" data-image-caption="" data-medium-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/PIR-ESP8266-Low-Power.png?fit=300%2C97&amp;ssl=1" data-large-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/PIR-ESP8266-Low-Power.png?fit=692%2C223&amp;ssl=1" class="aligncenter wp-image-464" title="PIR ESP8266 Low Power" src="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/PIR-ESP8266-Low-Power.png?resize=692%2C223&#038;ssl=1" alt="PIR-ESP8266-Low-Power" width="692" height="223" srcset="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/PIR-ESP8266-Low-Power.png?w=692&amp;ssl=1 692w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/PIR-ESP8266-Low-Power.png?resize=300%2C97&amp;ssl=1 300w" sizes="(max-width: 692px) 100vw, 692px" /></p>
<p><strong>Pros and Cons</strong></p>
<p>The low price, small form factor, the simple interface and its ability to handle a wide range of voltages makes it very convenient to use with the ESP8266. The detection range on the other hand seems to be rather short, I had accurate detections within about 2 meters. Nonetheless there are still many applications that you can use this module for&#8230;</p>
<p>&nbsp;</p>
<p><strong>Where to buy?</strong></p>
<p>Order one now from <a href="https://www.banggood.com/Mini-IR-Infrared-Pyroelectric-PIR-Body-Motion-Human-Sensor-Detector-Module-p-1015337.html?p=6R31122484684201508S&#038;custlinkid=1587757" target="_blank">Banggood</a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.squix.org/2016/05/esp8266-peripherals-mini-pir-motion-sensor.html/feed</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">435</post-id>	</item>
		<item>
		<title>ESP8266 Peripherals: uBlox GPS Module</title>
		<link>https://blog.squix.org/2016/05/esp8266-peripherals-ublox-gps-module.html</link>
					<comments>https://blog.squix.org/2016/05/esp8266-peripherals-ublox-gps-module.html#comments</comments>
		
		<dc:creator><![CDATA[Daniel Eichhorn]]></dc:creator>
		<pubDate>Sat, 07 May 2016 07:04:29 +0000</pubDate>
				<category><![CDATA[ESP8266 Peripherals]]></category>
		<guid isPermaLink="false">http://blog.squix.org/?p=408</guid>

					<description><![CDATA[Almost 20 years ago when I studied a few semesters of electrical engineering at the famous ETH in Zurich I had a lecture about the basics of digital electronics. And I remember the professor doing many practical demonstrations such as drilling holes into a CD ... <p><a class="read-more btn btn-secondary" href="https://blog.squix.org/2016/05/esp8266-peripherals-ublox-gps-module.html">Read More</a></p>]]></description>
										<content:encoded><![CDATA[<p>Almost 20 years ago when I studied a few semesters of electrical engineering at the famous ETH in Zurich I had a lecture about the basics of digital electronics. And I remember the professor doing many practical demonstrations such as drilling holes into a CD to show the quality of error correction in different price categories of CD players. I also remember that he talked about tiny and cost efficient GPS receivers that soon would be part of every cell phone (remember, 20 years ago the real age of smart phones had still been a few years away). That Professor, Gerhard Tröster, followed that vision and co-founded a company called u-blox, a non-fab producer of positioning systems with about 450 employees today. I was very excited indeed when I found a <a class="thirstylink" title="very affordable GPS module" href="go/banggood-gps-module" target="_blank" rel="nofollow noopener">very affordable GPS module</a> in my favourite Chines online shop, with a design by u-blox! So in this second post of my ESP8266 peripheral series I will review this module, show you how to use it with the ESP8266 and give you some ideas for applications.<span id="more-408"></span></p>
<figure id="attachment_410" aria-describedby="caption-attachment-410" style="width: 300px" class="wp-caption aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" data-attachment-id="410" data-permalink="https://blog.squix.org/2016/05/esp8266-peripherals-ublox-gps-module.html/ubloxgps" data-orig-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/uBloxGPS.jpg?fit=600%2C600&amp;ssl=1" data-orig-size="600,600" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="uBloxGPS" data-image-description="" data-image-caption="" data-medium-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/uBloxGPS.jpg?fit=300%2C300&amp;ssl=1" data-large-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/uBloxGPS.jpg?fit=600%2C600&amp;ssl=1" class="wp-image-410 size-medium" src="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/uBloxGPS.jpg?resize=300%2C300&#038;ssl=1" alt="uBloxGPS" width="300" height="300" srcset="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/uBloxGPS.jpg?resize=300%2C300&amp;ssl=1 300w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/uBloxGPS.jpg?resize=150%2C150&amp;ssl=1 150w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/uBloxGPS.jpg?resize=120%2C120&amp;ssl=1 120w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/uBloxGPS.jpg?w=600&amp;ssl=1 600w" sizes="(max-width: 300px) 100vw, 300px" /><figcaption id="caption-attachment-410" class="wp-caption-text">The uBlox module VK2828U7G5LF for under $10</figcaption></figure>
<p>&nbsp;</p>
<p><strong>What is this module doing?</strong></p>
<p>At least since the iPhone 3G came to the market GPS based navigation has become a commodity for many people. The global positioning system receives signals from satellites. If the signals of at least four satellites are received the position of the device can be calculated. It can do this by comparing small differences in the  time the signal took to reach the receiver. Since the satellites broadcast these signals with relatively weak signal the receiver requires direct line-of-sight to the satellites and this means pure GPS often doesn&#8217;t work well indoors.</p>
<p>Enough about the theory, how can the ESP8266 talk to the u-blox module? The module exposes the positioning information through a serial interface, just like the one you are using to program the ESP8266. By default it is set to 9600 baud but this value can be changed also through the serial interface. Apparently it is a very common thing that GPS modules have a serial interface and another partially standardized aspect is the message format. This module sends messages in the NMEA (0183 V3.0) format. This format knows many different types of messages, some of them are vendor specific. We are here interested in general messages. If you look directly at the serial output you will see messages like this:</p>
<pre><code>
$GPGSV,5,1,19,01,,,29,02,,,30,05,,,27,07,,,29*72
$GPGSV,5,2,19,08,,,23,10,,,28,12,,,32,13,,,29*7F
$GPGSV,5,3,19,15,,,26,16,,,28,18,,,27,21,,,26*71
$GPGSV,5,4,19,22,,,29,23,,,30,24,,,27,28,,,27*75
$GPGSV,5,5,19,29,,,29,33,,,30,40,,,30*75
</code></pre>
<p>&nbsp;</p>
<p><strong>Setting up the module with the ESP8266</strong></p>
<figure id="attachment_413" aria-describedby="caption-attachment-413" style="width: 282px" class="wp-caption aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" data-attachment-id="413" data-permalink="https://blog.squix.org/2016/05/esp8266-peripherals-ublox-gps-module.html/ubloxwiring" data-orig-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/uBloxWiring.png?fit=631%2C671&amp;ssl=1" data-orig-size="631,671" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="uBloxWiring" data-image-description="" data-image-caption="&lt;p&gt;Connecting the uBlox Module to the ESP8266&lt;/p&gt;
" data-medium-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/uBloxWiring.png?fit=282%2C300&amp;ssl=1" data-large-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/uBloxWiring.png?fit=631%2C671&amp;ssl=1" class="size-medium wp-image-413" src="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/uBloxWiring.png?resize=282%2C300&#038;ssl=1" alt="Connecting the uBlox Module to the ESP8266" width="282" height="300" srcset="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/uBloxWiring.png?resize=282%2C300&amp;ssl=1 282w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/uBloxWiring.png?resize=300%2C319&amp;ssl=1 300w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/uBloxWiring.png?w=631&amp;ssl=1 631w" sizes="(max-width: 282px) 100vw, 282px" /><figcaption id="caption-attachment-413" class="wp-caption-text">Connecting the uBlox Module to the ESP8266</figcaption></figure>

<table id="tablepress-1" class="tablepress tablepress-id-1">
<thead>
<tr class="row-1">
	<th class="column-1">Pin</th><th class="column-2">Color</th><th class="column-3">ESP8266</th>
</tr>
</thead>
<tbody class="row-striping row-hover">
<tr class="row-2">
	<td class="column-1">E</td><td class="column-2">Yellow</td><td class="column-3">3.3V</td>
</tr>
<tr class="row-3">
	<td class="column-1">G</td><td class="column-2">Black</td><td class="column-3">GND</td>
</tr>
<tr class="row-4">
	<td class="column-1">R</td><td class="column-2">Green</td><td class="column-3">D6</td>
</tr>
<tr class="row-5">
	<td class="column-1">T</td><td class="column-2">Blue</td><td class="column-3">D5</td>
</tr>
<tr class="row-6">
	<td class="column-1">V</td><td class="column-2">Red</td><td class="column-3">3.3V</td>
</tr>
<tr class="row-7">
	<td class="column-1">P</td><td class="column-2">White</td><td class="column-3">N/A</td>
</tr>
</tbody>
</table>
<!-- #tablepress-1 from cache -->
<p>Now that we have connected the u-blox module it is ready for our first code. We want to read the NMEA messages in the NodeMCU and forward them to the serial console on the PC. This code here does the trick:</p>
<pre><code>
#include &lt;SoftwareSerial.h&gt;

// if you are not using a NodeMCU but another type of ESP8266
// you might want to replace this with the correct GPIO pin numbers you used
SoftwareSerial mySerial(D5, D6); // RX, TX

void setup() {
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);

}

void loop() {
  if (mySerial.available()) {
    Serial.write(mySerial.read());
  }
  if (Serial.available()) {
    mySerial.write(Serial.read());
  }
}
</code></pre>
<p>Upload the sketch to your ESP and open the serial console. Now you should see the NMEA messages come in.<br />
At first there might be values missing, but the more satellite signals the module receives the more complete the positioning information will be. After this first smoke test lets continue with a library that can make sense of the NMEA messages.</p>
<p>&nbsp;</p>
<p><strong>The TinyGPS+ library</strong></p>
<p>By installing this library you can finally get to the core of the GPS information: latitude, longitude, altitude, speed, etc. Go to <a href="http://arduiniana.org/libraries/tinygpsplus/" target="_blank" rel="noopener">http://arduiniana.org/libraries/tinygpsplus/</a> and download the library, extract it to your Arduino/libraries folder and restart your Arduino IDE. Then go to File &gt; Examples &gt; TinyGPSPlus and open the FullExample file. Now you have to adapt the baud rate to 9600 (this is the default serial speed of our u-blox module) and change the serial pins to D5 and D6 and run the code.</p>
<pre><code>
static const int RXPin = D5, TXPin = D6;
static const uint32_t GPSBaud = 9600;
</code></pre>
<p>If you are not getting any position information you might want to get closer to the window or even go outside. Pure GPS is notoriously famous for not working indoors, due to the weak satellite signals and interference with other RF sources.</p>
<p>&nbsp;</p>
<p><strong>Application Ideas</strong></p>
<p>Ok, great. Now we have a working GPS module. But what can we do with it? Here are a few ideas:</p>
<ul>
<li><strong>Bike computer</strong>: mix together an <a class="thirstylink" title="OLED display" href="https://www.banggood.com/1_3-Inch-4Pin-White-OLED-LCD-Display-12864-IIC-I2C-Interface-Module-p-1067874.html?p=0P21061109440201501M" target="_blank" rel="nofollow noopener">OLED display</a>, <a class="thirstylink" title="NodeMCU" href="https://www.banggood.com/custlink/KKmhNy2sgy" target="_blank" rel="nofollow noopener">NodeMCU</a>, a <a class="thirstylink" title="USB power bank" href="https://blog.squix.org/recommends/uncategorized/xiaomipowerbank5000mah" target="_blank" rel="nofollow noopener">USB power bank</a> and the <a class="thirstylink" title="GPS module" href="go/banggood-gps-module" target="_blank" rel="nofollow noopener">GPS module</a> and mount everything on your bike. With a little bit of code you can display information on the OLED display such as speed, altitude and you can use way points even to some basic navigation. Store the tracking data in the EEPROM and upload it to the cloud as soon as the device detects your home device</li>
<li><strong>War Drive Module</strong>: okay, I admit, this might not have the relevance anymore that it once had, but you could build it for less than USD $20! Wire up the <a class="thirstylink" title="GPS module" href="go/banggood-gps-module" target="_blank" rel="nofollow noopener">GPS module</a> and the <a class="thirstylink" title="NodeMCU" href="https://www.banggood.com/custlink/KKmhNy2sgy" target="_blank" rel="nofollow noopener">NodeMCU</a> and a <a class="thirstylink" title="Power Bank" href="https://blog.squix.org/recommends/uncategorized/xiaomipowerbank5000mah" target="_blank" rel="nofollow noopener">Power Bank</a> and bring it with you to work while it is running. Every 30 seconds or so list the SSID the NodeMCU lists through the Wifi Interface together with the location and store it in the EEPROM. Later use that information to create a map of (free?) Wifi access points</li>
<li><strong>High precision real time clock</strong>: In order to calculate your current position the satellite send highly precise time stamps which you can read with help of the TinyGPS+ library. True, you can use the network time protocol (NTP) to fetch the current time if your ESP is connected to the internet. But if you are offline for some reason the GPS clock might be handy. You could actually implement your own NTP server, backed by the GPS module</li>
</ul>
<p>&nbsp;</p>
<p><strong>Review</strong></p>
<p>The module is easy to use and with less than USD $10 it was a no-brainer to order it and to try it out. The serial interface makes it very convenient to use if you have two GPIO pins to spare. Without problems I could use the SoftwareSerial module so I still could be using the hardware serial interface for debugging. While I think it is a great module for your outdoor positioning project it doesn&#8217;t work very well indoors. Nowadays we are spoiled by quickly locking GPS modules on smartphones which also perform well indoors. But be warned: the GPS module isn&#8217;t as good as that, since it cannot use information like (GSM) cell Ids or Wifi SSIDs to improve speed and accuracy of the position signal. But the module will be a great addition to your tool box for your next project (see ideas above). I forgot to mention that the GPS module has a convenient way to save energy in case you don&#8217;t need it: setting the yellow pin to LOW will basically shutdown the module completely.</p>
<p><strong>Order the module now <a href="https://www.banggood.com/Geekcreit-1-5Hz-VK2828U7G5LF-TTL-GPS-Module-With-Antenna-1-5Hz-With-EEPROM-p-965540.html?p=0P21061109440201501M" target="_blank" rel="noopener">from Banggood</a></strong></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.squix.org/2016/05/esp8266-peripherals-ublox-gps-module.html/feed</wfw:commentRss>
			<slash:comments>10</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">408</post-id>	</item>
		<item>
		<title>ESP8266 Peripherals: KY-040 Rotary Encoder</title>
		<link>https://blog.squix.org/2016/05/esp8266-peripherals-ky-040-rotary-encoder.html</link>
					<comments>https://blog.squix.org/2016/05/esp8266-peripherals-ky-040-rotary-encoder.html#comments</comments>
		
		<dc:creator><![CDATA[Daniel Eichhorn]]></dc:creator>
		<pubDate>Wed, 04 May 2016 19:45:14 +0000</pubDate>
				<category><![CDATA[ESP8266 Peripherals]]></category>
		<category><![CDATA[ESP8266]]></category>
		<category><![CDATA[peripherals]]></category>
		<guid isPermaLink="false">http://blog.squix.org/?p=389</guid>

					<description><![CDATA[The ESP8266 took the hearts of the IoT and Do-It-Yourself community by storm, due the very attractive price, its internet connectivity and due to the relatively rich amount of available GPIO pins. But an internet connected device is not worth much without means to interact with ... <p><a class="read-more btn btn-secondary" href="https://blog.squix.org/2016/05/esp8266-peripherals-ky-040-rotary-encoder.html">Read More</a></p>]]></description>
										<content:encoded><![CDATA[<p>The ESP8266 took the hearts of the IoT and Do-It-Yourself community by storm, due the very attractive price, its internet connectivity and due to the relatively rich amount of available GPIO pins. But an internet connected device is not worth much without means to interact with the real world. Thanks to standardised communication protocols like I2C, SPI and serial interface and the work of the Arduino community there are many sensors and actors available for a really good price. But do they play well with the ESP8266? In this series of blog posts I will share my experience with these modules and how you can use them.</p>
<p><span id="more-389"></span></p>
<p>The start makes an input device which is surprisingly low tech but offers a nice way to adjust settings on a display without using too much of your valuable GPIO pins: <a href="https://www.banggood.com/KY-040-Rotary-Decoder-Encoder-Module-AVR-PIC-p-914010.html?p=0P21061109440201501M" target="_blank" rel="noopener">the KY-040 rotary encoder</a></p>
<figure id="attachment_390" aria-describedby="caption-attachment-390" style="width: 300px" class="wp-caption aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" data-attachment-id="390" data-permalink="https://blog.squix.org/2016/05/esp8266-peripherals-ky-040-rotary-encoder.html/ky-040" data-orig-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/KY-040.jpg?fit=600%2C600&amp;ssl=1" data-orig-size="600,600" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="KY-040" data-image-description="" data-image-caption="" data-medium-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/KY-040.jpg?fit=300%2C300&amp;ssl=1" data-large-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/KY-040.jpg?fit=600%2C600&amp;ssl=1" class="wp-image-390 size-medium" src="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/KY-040.jpg?resize=300%2C300&#038;ssl=1" alt="KY-040" width="300" height="300" srcset="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/KY-040.jpg?resize=300%2C300&amp;ssl=1 300w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/KY-040.jpg?resize=150%2C150&amp;ssl=1 150w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/KY-040.jpg?resize=120%2C120&amp;ssl=1 120w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/KY-040.jpg?w=600&amp;ssl=1 600w" sizes="(max-width: 300px) 100vw, 300px" /><figcaption id="caption-attachment-390" class="wp-caption-text">KY-040 Rotary Encoder</figcaption></figure>
<p>&nbsp;</p>
<p><strong>What is a Rotary Encoder?</strong></p>
<p>At first glance you might mistake the KY-040 for an adjustable resistor, a potentiometer. It has a knob which you can turn. But unlike real potentiometers the KY-040 can turn round and round without ever getting to a blocking limit. When turning the KY-04 you will also feel certain positions where the encoder will slide into. A potentiometer on the other hand can usually be turned smoothly until you get to the end stop. And there is another difference: the KY-040 (like most rotary encoders) has a switch which can be closed when pressing the knob vertically to the rotation axis. I have seen rotary encoders like this being used in modern radios or in built-in car navigation systems. The advantage is that they can be used relatively easy in a digital system as opposed to an analog/digital converter (ADC) reading the values from a potentiometer. There you also might have to deal with temperature drift and similar ugly problems. So in many ways a rotary encoder is the younger (millennial/digital) brother of a potentiometer.</p>
<p>&nbsp;</p>
<p><strong>How do you use  a Rotary Encoder?</strong></p>
<p>There are different types of rotary encoders. Some can determine the absolute position/angle of the knob without constantly keeping track of its movements. But the KY-040 a very simple minded fellow. By tracking the signals on two pins an MCU can determine if the knob was turned to the left or to the right. With a third pin the state of the knob button can be tracked. The wave form on the two rotation pins looks more or less like this:</p>
<p><figure id="attachment_391" aria-describedby="caption-attachment-391" style="width: 300px" class="wp-caption aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" data-attachment-id="391" data-permalink="https://blog.squix.org/2016/05/esp8266-peripherals-ky-040-rotary-encoder.html/rotaryencoderwaveform" data-orig-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/RotaryEncoderWaveform.gif?fit=354%2C230&amp;ssl=1" data-orig-size="354,230" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="RotaryEncoderWaveform" data-image-description="" data-image-caption="" data-medium-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/RotaryEncoderWaveform.gif?fit=300%2C195&amp;ssl=1" data-large-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/RotaryEncoderWaveform.gif?fit=354%2C230&amp;ssl=1" class="wp-image-391 size-medium" src="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/RotaryEncoderWaveform.gif?resize=300%2C195&#038;ssl=1" alt="RotaryEncoderWaveform" width="300" height="195" srcset="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/RotaryEncoderWaveform.gif?resize=300%2C195&amp;ssl=1 300w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/RotaryEncoderWaveform.gif?resize=230%2C150&amp;ssl=1 230w" sizes="(max-width: 300px) 100vw, 300px" /><figcaption id="caption-attachment-391" class="wp-caption-text">Rotary Encoder Wave Form. Picture from [http://playground.arduino.cc/Main/RotaryEncoders]</figcaption></figure>When turning the knob clockwise the signal on line B will first go high, before line A will also have a rising edge. Followed by a falling edge on line B and later by a falling edge on line A. The sequence from one click position to the next is then 00, 01, 11, 10, 00. For a counter clockwise movement the order is 00, 10, 11, 01, 00. Hence by tracking these signals carefully you can determine the direction of the rotation and also track 4 intermediate states between two clicks. If you have interrupts available you can have your code get some notification about a change of the signals on the two lines. If you don&#8217;t have interrupts available you&#8217;ll have to trust that your reading the signals often enough to not miss any important change of the signal (AKA polling the signals). And there is yet another complication: we are living in an imperfect world (in case you haven&#8217;t noticed that yet, that&#8217;s the bloody truth;-)). The mechanical contacts inside the KY-040 might &#8220;missfire&#8221; from time to time. Maybe there is some dust on the contacts or the copper has a tiny dent. However, your MCU might get a dirty signal unlike the one depicted above and draw wrong conclusions. This is where debouncing comes in. You can debounce buttons and rotary encoders like the KY-040 either in hardware or in software. The hardware solution is to use a tiny condensator to smoothen the signal from the noise a bit. But by applying a time frame where you&#8217;d expect changes to happen you can also filter out the noise pretty well. The library we will use here does that under the hood and we don&#8217;t have to worry about it. I just wanted to point out this fact so that you can understand why you might miss states occasionally and that you have to deal with that fact in your application.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong>Lets get our hands dirty!</strong></p>
<p>Now to a practical example. Wire up your encoder like this the following picture, make sure that you follow the labels and not the ordering, I might have turned something upside down:</p>
<figure id="attachment_399" aria-describedby="caption-attachment-399" style="width: 300px" class="wp-caption aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" data-attachment-id="399" data-permalink="https://blog.squix.org/2016/05/esp8266-peripherals-ky-040-rotary-encoder.html/rotaryencoderky-040-2" data-orig-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/RotaryEncoderKY-040-1.png?fit=559%2C389&amp;ssl=1" data-orig-size="559,389" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="RotaryEncoderKY-040" data-image-description="" data-image-caption="" data-medium-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/RotaryEncoderKY-040-1.png?fit=300%2C209&amp;ssl=1" data-large-file="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/RotaryEncoderKY-040-1.png?fit=559%2C389&amp;ssl=1" class="wp-image-399 size-medium" src="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/RotaryEncoderKY-040-1.png?resize=300%2C209&#038;ssl=1" alt="RotaryEncoderKY-040" width="300" height="209" srcset="https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/RotaryEncoderKY-040-1.png?resize=300%2C209&amp;ssl=1 300w, https://i0.wp.com/blog.squix.org/wp-content/uploads/2016/05/RotaryEncoderKY-040-1.png?w=559&amp;ssl=1 559w" sizes="(max-width: 300px) 100vw, 300px" /><figcaption id="caption-attachment-399" class="wp-caption-text">Wiring of the KY-040 with the NodeMCU</figcaption></figure>
<ul>
<li>GND to GND</li>
<li>+ to 3.3V</li>
<li>SW to D3</li>
<li>DT to D2</li>
<li>CLK to D1</li>
</ul>
<p>&nbsp;</p>
<p><strong>Installing the library</strong></p>
<p>There are different libraries that might work. This library worked well for me: <a href="https://github.com/PaulStoffregen/Encoder" target="_blank" rel="noopener">https://github.com/PaulStoffregen/Encoder</a> Download the ZIP and unpack it into your Arduino library directory. Restart the Arduino IDE and copy the code from here:</p>
<pre><code>
#include &lt;Encoder.h&gt;

Encoder myEnc(D1, D2);


long oldPosition  = -999;
boolean isButtonPressed = false;
long lastUpdateMillis = 0;

void handleKey() {
  isButtonPressed = true;  
}

void setup() {
  Serial.begin(115200);
  Serial.println("Basic Encoder Test:");
   pinMode(D3, INPUT_PULLUP);
   attachInterrupt(D3, handleKey, RISING);
}


void loop() {
  long newPosition = myEnc.read();
  if (newPosition != oldPosition) {
    oldPosition = newPosition;
    Serial.println(newPosition);
  }
  // software debounce
  if (isButtonPressed &amp;amp;&amp;amp; millis() - lastUpdateMillis &amp;gt; 50) {
    isButtonPressed = false;
    lastUpdateMillis = millis();
    // Reset the counter
    myEnc.write(0);
  }
}
</code></pre>
<p>After uploading the sketch you can open the serial console, turn the knob up and down and press the axis to reset the counter. Your output might look something like this:</p>
<pre><code>
Basic Encoder Test:
0
1
2
3
2
3
4
0 - Knob pressed
1
2
3
4
0 - Knob pressed
</code></pre>
<p>&nbsp;</p>
<p><strong>Suggested applications</strong></p>
<ul>
<li><strong>WeatherStation Frame Controller</strong>: Some readers were asking me how they could control the currently displayed frame of the <a href="https://blog.squix.org/product/weatherstation-kit-w-white-oled" target="_blank" rel="noopener">WeatherStation</a>. Depending on the amount of the frames you are using it might take a while until the one that interests you the most comes around. The rotary encoder is a nice extension which allows you to quickly zap through the frames without having to implement a lot of code</li>
<li><strong>Wifi Selector for unprotected APs</strong>: lets assume you have a setup with an ESP8266, a display and you want to quickly select an unprotected wifi to connect to without using the web interface: just implement some kind of menu and use the rotary encoder to move a cursor from one SSID to the next and the knob button to select the AP you actually want to connect to</li>
</ul>
<p>&nbsp;</p>
<p><strong>Where to buy?</strong></p>
<p>As always I recommend to order it from my favourite Chinese retailer <a href="/go/ky-040-rotary-encoder" target="_blank" rel="noopener">Banggood</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.squix.org/2016/05/esp8266-peripherals-ky-040-rotary-encoder.html/feed</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">389</post-id>	</item>
		<item>
		<title>ESP8266: NodeMCU Motor Shield Review</title>
		<link>https://blog.squix.org/2015/09/esp8266-nodemcu-motor-shield-review.html</link>
					<comments>https://blog.squix.org/2015/09/esp8266-nodemcu-motor-shield-review.html#comments</comments>
		
		<dc:creator><![CDATA[Daniel Eichhorn]]></dc:creator>
		<pubDate>Sat, 12 Sep 2015 10:08:00 +0000</pubDate>
				<category><![CDATA[ESP8266 Peripherals]]></category>
		<category><![CDATA[ESP8266]]></category>
		<category><![CDATA[motorshield]]></category>
		<category><![CDATA[nodemcu]]></category>
		<category><![CDATA[robotics]]></category>
		<category><![CDATA[smart car]]></category>
		<guid isPermaLink="false">http://blog.squix.org/2015/09/12/esp8266-nodemcu-motor-shield-review/</guid>

					<description><![CDATA[If you want to engage with your ESP8266 into robotics there is now an almost ready-to-go solution: the NodeMCU Motor Shield. If my research is correct then it was the Doctors of Intelligence &#38; Technology (http://doit.am/) who created it and also are offering some LUA ... <p><a class="read-more btn btn-secondary" href="https://blog.squix.org/2015/09/esp8266-nodemcu-motor-shield-review.html">Read More</a></p>]]></description>
										<content:encoded><![CDATA[<div dir="ltr" style="text-align: left;">If you want to engage with your ESP8266 into robotics there is now an almost ready-to-go solution: the NodeMCU Motor Shield. If my research is correct then it was the Doctors of Intelligence &amp; Technology (<a href="http://doit.am/">http://doit.am/</a>) who created it and also are offering some LUA code to get started. This post shares my experience with the motorshield and also with a two engine &#8220;Smart Car&#8221; kit that nicely combines with the motorshield.</p>
<h3 style="text-align: left;">Motorshield</h3>
<div>If you want to drive motors with your ESP8266 you have to be careful. The General Purpose Input/Output (GPIO) pins of the ESP8266 (as well as the similar Arduinos) don&#8217;t allow you to draw the amount of current required for a motor. But how to do that? You could build something on your own by using a few electronic components (transistor, capacitor, etc) or you could just pick something off the shelf that does exactly that for you. That&#8217;s where the Doctors of Intelligence &amp; Technology and their motor shield comes in. It is designed to carry a NodeMCU V1.0 on its back. <b>Note: the motor shield won&#8217;t fit for a NodeMCU V0.9! </b>It has convenient terminals to attach two two-ways motors (or according to some source one stepper motor). It also has terminals to attach the power source that drives the motors and the NodeMCU. And as a clever addition you can decide to have just one power source for both motors and NodeMCU by setting a jumper accordingly.</div>
<div>One of the two terminals (Vin for NodeMCU) can be cut off with a power switch which saves you from taking out the batteries.</div>
<div></div>
<div>Besides the terminals there are also male pins which lead out GPIO 0-8 (in NodeMCU terminology), the reset pin, the analog/digital converter, the UART pins and the SPI pins.</div>
<div></div>
<table class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;" cellspacing="0" cellpadding="0" align="center">
<tbody>
<tr>
<td style="text-align: center;"><a style="margin-left: auto; margin-right: auto;" href="https://i0.wp.com/2.bp.blogspot.com/-omdNIDIY7SE/VfQJMC-RH4I/AAAAAAAAAcU/eesUUM8MmGU/s1600/NodeMcuMotorshield.jpg"><img data-recalc-dims="1" loading="lazy" decoding="async" src="https://i0.wp.com/blog.squix.org/wp-content/uploads/2015/09/NodeMcuMotorshield.jpg?resize=320%2C219&#038;ssl=1" width="320" height="219" border="0" /></a></td>
</tr>
<tr>
<td class="tr-caption" style="text-align: center;">NodeMCU V1.0 Powershield</td>
</tr>
</tbody>
</table>
<div>A sign on the PCB makes it easy enough to plugin the NodeMCU the correct way: just make sure that the antenna of the ESP8266 and the antenna symbol on the motor shield are on the same side.</div>
<div></div>
<h3 style="text-align: left;">Smart Car Kit</h3>
<div>The Smart Car Kit is the ideal companion for the NodeMCU if you want to get started into WiFi controlled cars or robotics. Some vendors even sell it in one big package for about USD $22 (<a href="https://www.banggood.com/Geekcreit-2WD-L293D-WIFI-Smart-Robot-Car-With-NodeMCU-+-Shield-Kit-For-ESP-12E-Based-On-ESP8266-p-995166.html?p=0P21061109440201501M&amp;custlinkid=1587783" target="_blank" rel="noopener">see here</a>). It comes with 2 two-ways motors with reduction gear, two main wheels and one support wheel, a chassis, a battery pack for 4 AA cells and additional screw driver.</div>
<div>You can put everything to getter within just about 15 minutes once you have figured out where the parts have to go. I only had two issues with the kit: while you might be able to attach the wires to the engine without soldering I would recommend that you do this with a soldering iron. The other (bigger) problem was the supporting wheel. It turns easy enough around the axis of the wheel itself but the z-axis which should adjust when the car makes a turn is not working so smoothly. This can have the effect that even if both motors go at the same speed the supporting wheel is stuck in a weird position and keeps your car to pull to one side. I solved this by using some duct tape and fixing the wheel at the &#8220;forward&#8221; position. This might be suboptimal for turning but works good enough on smooth floors. It might be a problem though on soft carpets but I haven&#8217;t tried that.</div>
<div></div>
<table class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;" cellspacing="0" cellpadding="0" align="center">
<tbody>
<tr>
<td style="text-align: center;"><a style="margin-left: auto; margin-right: auto;" href="https://i0.wp.com/1.bp.blogspot.com/-63lGVhW0hsU/VfQPt3pG5SI/AAAAAAAAAck/VDyC4BMe-Go/s1600/SmartCarKit.png"><img data-recalc-dims="1" loading="lazy" decoding="async" src="https://i0.wp.com/blog.squix.org/wp-content/uploads/2015/09/SmartCarKit.png?resize=294%2C320&#038;ssl=1" width="294" height="320" border="0" /></a></td>
</tr>
<tr>
<td class="tr-caption" style="text-align: center;">The Smart Car Kit</td>
</tr>
</tbody>
</table>
<div></div>
<div></div>
<h3 style="text-align: left;">Bringing it together: the WiFi Car</h3>
<div>The next step was to put all the pieces (Smart Car, battery pack, NodeMCU V1.0 and Motor Shield) together. The holes of the motor shield fit perfectly into the holes of the acrylic chassis and the kit comes with enough screws and nuts to attach it. Also the battery pack can be screwed easily onto the chassis. The way I placed the components onto the chassis left only little space between the motor shield and the battery pack which made it hard to attach the wires with the terminals.</div>
<div></div>
<h3 style="text-align: left;">Programming the Car from the Arduino Environment</h3>
<div>The inventors of the kit have sample code for LUA on their website. But I decided to try to program the car with the Arduino IDE. And that is really easy: 4 pins control the engines. Pins 4 and 5 (Arduino Terminology) control the speed of the engines with PWM in a default range of 0..1023 while pins 0 and 2 define the direction the engines will turn. 0 is backwards and 1 is forward but this might depend on who you wired the engines up to the shield. In my case I had to swap the wires of one of the two engines so a &#8220;1&#8221; would symbolise the same direction for both engines.</div>
<div>First I wrote a little Arduino sketch to test if everything was working alright and if I understood the interface correctly. From there I incrementally improved the code and I&#8217;m now able to steer it with any device with a modern browser, a built in accelerometer by just balancing the device in the direction I want to car to move. While it is still far from perfect it works surprisingly well: a javascript program reads out the accelerometer of the controlling device (e.g. an iPhone) and sends AJAX requests to the WiFi connected Smart Car. These commands are then taken to steer the motors.</div>
<div>In this scenario a big part of the logic is in the javascript code. While this could be hosted on the ESP8266 EEPROM I decided to load it from an external server which makes it really easy to program: I only have to change the file on the remote server. The ESP8266 firmware remains unchanged for most of the time.</div>
<div>To connect to the device you only have to find out the IP that has been assigned to the NodeMCU. Then open that IP in your Smart Phone browser and move level your device to steer the car.</div>
<div></div>
<div>Here is a little video of that setup:</div>
<div><iframe loading="lazy" src="https://www.youtube.com/embed/dLR6jnUdpXE" width="560" height="315" frameborder="0" allowfullscreen="allowfullscreen"></iframe></div>
<div>
<p>Source Code:</p>
<ul style="text-align: left;">
<li><a href="https://github.com/squix78/esp8266-projects/tree/master/arduino-ide/wifi-car">https://github.com/squix78/esp8266-projects/tree/master/arduino-ide/wifi-car</a></li>
</ul>
</div>
<h3 style="text-align: left;">Shopping List:</h3>
<div>
<ul style="text-align: left;">
<li><a href="https://www.banggood.com/Geekcreit-2WD-L293D-WIFI-Smart-Robot-Car-With-NodeMCU-+-Shield-Kit-For-ESP-12E-Based-On-ESP8266-p-995166.html?p=0P21061109440201501M&amp;custlinkid=1587783" target="_blank" rel="noopener">Complete Kit from Banggood</a> (~USD $23)</li>
<li><a href="http://www.banggood.com/ESP8266-WiFi-Motor-Drive-Expansion-Board-For-NodeMCU-ESP-12E-p-991603.html?p=0P21061109440201501M" target="_blank" rel="noopener">Motor Shield for NodeMCU V1.0</a> (~USD $5.30)</li>
<li><a href="http://www.banggood.com/NodeMcu-Lua-ESP8266-ESP-12E-and-WiFi-Motor-Drive-Expansion-Board-p-995417.html?p=0P21061109440201501M" target="_blank" rel="noopener">Kit NodeMCU + MotorShield</a> (~USD $11.60)</li>
<li><a href="http://www.banggood.com/Smart-Robot-Car-Chassis-Kit-Speed-Encoder-Battery-Box-For-Arduino-p-981975.html?p=0P21061109440201501M" target="_blank" rel="noopener">Smart Car Kit</a> (~USD $12)</li>
</ul>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.squix.org/2015/09/esp8266-nodemcu-motor-shield-review.html/feed</wfw:commentRss>
			<slash:comments>7</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">29</post-id>	</item>
		<item>
		<title>ESP8266/Arduino: MAX7219 8&#215;8 Led Matrix Library</title>
		<link>https://blog.squix.org/2015/04/esp8266arduino-max7219-8x8-led-matrix.html</link>
					<comments>https://blog.squix.org/2015/04/esp8266arduino-max7219-8x8-led-matrix.html#comments</comments>
		
		<dc:creator><![CDATA[Daniel Eichhorn]]></dc:creator>
		<pubDate>Thu, 16 Apr 2015 17:05:00 +0000</pubDate>
				<category><![CDATA[ESP8266 Peripherals]]></category>
		<category><![CDATA[8x8 Matrix]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[ESP8266]]></category>
		<category><![CDATA[ESP8266/Arduino]]></category>
		<category><![CDATA[MAX7219]]></category>
		<category><![CDATA[SPI]]></category>
		<guid isPermaLink="false">http://blog.squix.org/2015/04/16/esp8266arduino-max7219-8x8-led-matrix/</guid>

					<description><![CDATA[Twice a year the company I work for (Netcetera) organizes a retreat for programmers, usually in the mountains. In the Spring issue this year we went to a resort in a beautiful mountain region. Inspired by the wonderful landscape I managed to write a library ... <p><a class="read-more btn btn-secondary" href="https://blog.squix.org/2015/04/esp8266arduino-max7219-8x8-led-matrix.html">Read More</a></p>]]></description>
										<content:encoded><![CDATA[<div dir="ltr" style="text-align: left;">
<div dir="ltr" style="text-align: left;">Twice a year the company I work for (<a href="http://netcetera.com/" target="_blank" rel="noopener">Netcetera</a>) organizes a retreat for programmers, usually in the mountains. In the Spring issue this year we went to a resort in a beautiful mountain region. Inspired by the wonderful landscape I managed to write a library for the recently published Arduino IDE for ESP8266 which allows you to manipulate pixels and write animated text on 8&#215;8 led matrices with a MAX7219 driver.<a href="http://www.banggood.com/2Pcs-MAX7219-Dot-Matrix-MCU-LED-Display-Control-Module-Kit-For-Arduino-p-945280.html?p=0P21061109440201501M" target="_blank" rel="noopener">These boards</a> (affiliate link) only cost a bit more than $2/piece and you can connect several of them by daisy chaining one with the next. This allows you to create wonderful led bar on the cheap: lets say you buy 10 of them plus an ESP8266 and mount them on a piece of card board you&#8217;ll have a wonderful remote programmable eye catcher for shop display for less than $30!</p>
<p>Not being fluent anymore in C/C++ I had to get used again to the hard work of managing memory, dealing with a weird String object (yes, even weirder than the String object in Java;-)) and some other pitfalls for a 10+ years Java programmer.</p>
<p>But I finally managed it and here you can see the result:</p>
</div>
<p><iframe loading="lazy" src="https://www.youtube.com/embed/SyQ0gtkVfAc" width="560" height="315" frameborder="0" allowfullscreen="allowfullscreen"></iframe></p>
<p>Connect the Modules like this:</p>
<table>
<thead>
<tr>
<th>Led Matrix</th>
<th>ESP8266</th>
</tr>
</thead>
<tbody>
<tr>
<td>VCC</td>
<td>+3.3V</td>
</tr>
<tr>
<td>GND</td>
<td>GND</td>
</tr>
<tr>
<td>DIN</td>
<td>GPIO13 (HSPID)</td>
</tr>
<tr>
<td>CS</td>
<td>Choose free GPIO, e.g. GPIO2</td>
</tr>
<tr>
<td>CLK</td>
<td>GPIO14 (HSPICLK)</td>
</tr>
</tbody>
</table>
<p>Here you&#8217;ll find the library:<br />
<a href="https://github.com/squix78/MAX7219LedMatrix">https://github.com/squix78/MAX7219LedMatrix</a></p>
<p>Please note:</p>
<ul style="text-align: left;">
<li>this library is made for the ESP8266 and might or might not work for &#8220;normal&#8221; Arduino boards.</li>
<li>I had to patch the Mac OS X release with the SPI folder from Github. In other words there wasn&#8217;t an up-to-date release for Mac OS X (and maybe for the other platforms as well) and the SPI.h/SPI.cpp wouldn&#8217;t compile</li>
</ul>
<p>&nbsp;</p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.squix.org/2015/04/esp8266arduino-max7219-8x8-led-matrix.html/feed</wfw:commentRss>
			<slash:comments>14</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">58</post-id>	</item>
	</channel>
</rss>
