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

<channel>
	<title>IoT Archives &#8211; Make Some Stuff</title>
	<atom:link href="https://makesomestuff.org/tag/iot/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>Build Cool Electronics Projects!</description>
	<lastBuildDate>Tue, 24 Mar 2026 19:18:12 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.2</generator>

<image>
	<url>https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/11/cropped-icon2.png?fit=32%2C32&#038;ssl=1</url>
	<title>IoT Archives &#8211; Make Some Stuff</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">165766821</site>	<item>
		<title>Cairo Mini Desk Gadget 01</title>
		<link>https://makesomestuff.org/the-cairo-mini-desk-gadget-01/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-cairo-mini-desk-gadget-01</link>
		
		<dc:creator><![CDATA[Ahmed Ibrahim]]></dc:creator>
		<pubDate>Mon, 16 Mar 2026 18:14:51 +0000</pubDate>
				<category><![CDATA[Desk Gadgets]]></category>
		<category><![CDATA[ESP32]]></category>
		<category><![CDATA[Google API]]></category>
		<category><![CDATA[IoT]]></category>
		<category><![CDATA[Youtube]]></category>
		<guid isPermaLink="false">https://makesomestuff.org/?page_id=2956</guid>

					<description><![CDATA[<p><a href="https://makesomestuff.org">Make Some Stuff</a><br />
<a href="https://makesomestuff.org/the-cairo-mini-desk-gadget-01/">Cairo Mini Desk Gadget 01</a></p>
<p>The Cairo Mini Desk Gadget 01 An open-source, ESP32-based YouTube stats monitor that utilizes the Google API to provide creators with a dedicated hardware dashboard for their channel&#8217;s growth. The gadget features a custom GUI developed in EEZ Studio and LVGL and is fully documented for anyone looking to tinker with digital fabrication and embedded [...]</p>
<p>The post <a href="https://makesomestuff.org/the-cairo-mini-desk-gadget-01/">Cairo Mini Desk Gadget 01</a> appeared first on <a href="https://makesomestuff.org">Make Some Stuff</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><a href="https://makesomestuff.org">Make Some Stuff</a><br />
<a href="https://makesomestuff.org/the-cairo-mini-desk-gadget-01/">Cairo Mini Desk Gadget 01</a></p>

<h1 class="wp-block-heading alignwide has-text-align-center has-white-color has-text-color has-background has-link-color has-larger-font-size wp-elements-2a5f295728565eeb49a76810beb20dc7" style="background-color:#00a99d"><strong>The Cairo Mini Desk Gadget 01</strong></h1>



<p class="has-text-align-center wp-block-paragraph">An open-source, ESP32-based YouTube stats monitor that utilizes the Google API to provide creators with a dedicated hardware dashboard for their channel&#8217;s growth. The gadget features a custom GUI developed in EEZ Studio and LVGL and is fully documented for anyone looking to tinker with digital fabrication and embedded systems.</p>


<div class="wp-block-image is-style-default">
<figure class="aligncenter size-full"><img data-recalc-dims="1" fetchpriority="high" decoding="async" width="770" height="770" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-1.jpg?resize=770%2C770&#038;ssl=1" alt="" class="wp-image-2952" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-1.jpg?w=3468&amp;ssl=1 3468w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-1.jpg?resize=300%2C300&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-1.jpg?resize=1024%2C1024&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-1.jpg?resize=150%2C150&amp;ssl=1 150w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-1.jpg?resize=1536%2C1536&amp;ssl=1 1536w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-1.jpg?resize=2048%2C2048&amp;ssl=1 2048w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-1.jpg?resize=370%2C370&amp;ssl=1 370w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-1.jpg?resize=100%2C100&amp;ssl=1 100w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-1.jpg?w=2310&amp;ssl=1 2310w" sizes="(max-width: 770px) 100vw, 770px" /></figure>
</div>


<div class="wp-block-columns alignwide are-vertically-aligned-center is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow">
<h2 class="wp-block-heading has-white-color has-text-color has-background has-link-color wp-elements-1d51d336ea0128b007296d7fc4db89b5" style="background-color:#00a99d">Meet The Cairo Mini Desk Gadget 01</h2>



<p style="padding-right:10px;padding-left:10px" class="wp-block-paragraph"><strong>The YouTube Stats Desk Gadget 01</strong> is a 3D-printable ESP32-powered dashboard designed and fabricated entirely from scratch. It merges embedded systems with refined UI design, utilizing a 1.3-inch IPS SPI display, a custom interface built with EEZ Studio, TFT_eSPI library, and LVGL. Integrated WiFi to track live channel analytics via the Google YouTube API. From the internal electronics to the visual layout, every component was thoughtfully developed to balance technical performance with a clean, expressive desk presence.</p>



<p style="padding-right:10px;padding-left:10px" class="wp-block-paragraph"><strong>Open Hardware for Creators.</strong> Staying true to open-source values, all code, design files, and project resources are shared openly for anyone to edit, customize, or rebuild. Whether you’re a developer, maker, or fellow content creator, this project invites you to explore the intersection of IoT and digital fabrication while experiencing the satisfaction of building a fully functional connected device from the ground up.</p>
</div>



<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow">
<figure class="is-style-default wp-block-image alignwide size-full"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="1027" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-4.jpg?resize=770%2C1027&#038;ssl=1" alt="" class="wp-image-2961" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-4.jpg?w=3468&amp;ssl=1 3468w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-4.jpg?resize=225%2C300&amp;ssl=1 225w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-4.jpg?resize=768%2C1024&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-4.jpg?resize=1152%2C1536&amp;ssl=1 1152w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-4.jpg?resize=1536%2C2048&amp;ssl=1 1536w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-4.jpg?w=2310&amp;ssl=1 2310w" sizes="auto, (max-width: 770px) 100vw, 770px" /></figure>
</div>
</div>



<hr class="is-style-wide wp-block-separator has-css-opacity"/>



<h2 class="wp-block-heading" style="font-size:48px">Parts List</h2>



<p class="has-text-align-justify wp-block-paragraph" style="font-size:18px;font-style:normal;font-weight:400">Below you can find all the parts that I used to build the <strong>Cairo Mini Desk Gadget 01</strong>. You can easily print, export, or open on your computer!</p>



<div class="wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-fe48e5de wp-block-buttons-is-layout-flex">
<div class="wp-block-button"><a class="wp-block-button__link has-vivid-green-cyan-background-color has-background wp-element-button" href="https://docs.google.com/spreadsheets/d/1Ct0z5y6NRr8w1uVrVg8g9gajz5L3t9QEq9acB6V6MUA/edit?usp=sharing" style="border-radius:50px" target="_blank" rel="noreferrer noopener">Parts List</a></div>
</div>



<p class="wp-block-paragraph"></p>



<p class="has-text-align-justify wp-block-paragraph" style="font-size:18px;font-style:normal;font-weight:400">We are editing this file frequently to make sure that it&#8217;s always up-to-date and to make it easier for you to build the Cairo Mini Desk Gadget 01 on your own. Don&#8217;t worry, we made a full build guide for you to follow. Find it at the end of this page <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<hr class="is-style-wide wp-block-separator has-css-opacity"/>



<h2 class="wp-block-heading" style="font-size:48px">Source Files</h2>



<p class="wp-block-paragraph"></p>



<p class="has-text-align-justify wp-block-paragraph" style="font-size:18px;font-style:normal;font-weight:400">Below you can download the STL files. You can use those files to 3D print the Cairo Mini Desk Gadget 01 parts. The material/settings I use to print them: PLA+ / 20% Infill / 0.2mm layer height.<br>If you are going to order or manufacture them on your own, just simply send those files to any makerspace or a fab lab with an FDM 3D printer machine. All STL files are in mm.</p>



<div class="wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-fe48e5de wp-block-buttons-is-layout-flex">
<div class="wp-block-button"><a class="wp-block-button__link has-vivid-green-cyan-background-color has-background wp-element-button" href="https://makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-01-STLs.zip" style="border-radius:50px" target="_blank" rel="noreferrer noopener">DOWNLOAD STL Files</a></div>
</div>



<p class="wp-block-paragraph"></p>


<div class="wp-block-wptb-table-block"><div class="wptb-container-legacy" data-table-id="2966">
    <table class="wptb-preview-table wptb-element-main-table_setting-2966" style="border-spacing: 3px 3px; border-collapse: collapse !important; min-width: 100%; border: 1px solid rgb(0, 0, 0); " data-border-spacing-columns="3" data-border-spacing-rows="3" data-reconstraction="1" data-wptb-table-directives="eyJpbm5lckJvcmRlcnMiOnsiYWN0aXZlIjoiYWxsIiwiYm9yZGVyV2lkdGgiOjEsImJvcmRlclJhZGl1c2VzIjp7ImFsbCI6MCwicm93IjowLCJjb2x1bW4iOjB9fX0=" data-wptb-responsive-directives="eyJyZXNwb25zaXZlRW5hYmxlZCI6dHJ1ZSwicmVzcG9uc2l2ZU1vZGUiOiJhdXRvIiwicmVsYXRpdmVXaWR0aCI6IndpbmRvdyIsInByZXNlcnZlUm93Q29sb3IiOmZhbHNlLCJoZWFkZXJGdWxseU1lcmdlZCI6ZmFsc2UsImJyZWFrcG9pbnRzIjp7ImRlc2t0b3AiOnsibmFtZSI6ImRlc2t0b3AiLCJ3aWR0aCI6MTAyNH0sInRhYmxldCI6eyJuYW1lIjoidGFibGV0Iiwid2lkdGgiOjcwMH0sIm1vYmlsZSI6eyJuYW1lIjoibW9iaWxlIiwid2lkdGgiOjM3NX19LCJtb2RlT3B0aW9ucyI6eyJhdXRvIjp7ImRpc2FibGVkIjp7ImRlc2t0b3AiOmZhbHNlLCJ0YWJsZXQiOmZhbHNlLCJtb2JpbGUiOmZhbHNlfSwidG9wUm93QXNIZWFkZXIiOnsiZGVza3RvcCI6ZmFsc2UsInRhYmxldCI6dHJ1ZSwibW9iaWxlIjp0cnVlfSwicmVwZWF0TWVyZ2VkSGVhZGVyIjp7ImRlc2t0b3AiOnRydWUsInRhYmxldCI6dHJ1ZSwibW9iaWxlIjp0cnVlfSwic3RhdGljVG9wUm93Ijp7ImRlc2t0b3AiOmZhbHNlLCJ0YWJsZXQiOmZhbHNlLCJtb2JpbGUiOmZhbHNlfSwiY2VsbFN0YWNrRGlyZWN0aW9uIjp7ImRlc2t0b3AiOiJyb3ciLCJ0YWJsZXQiOiJjb2x1bW4iLCJtb2JpbGUiOiJjb2x1bW4ifSwiY2VsbHNQZXJSb3ciOnsiZGVza3RvcCI6MSwidGFibGV0IjoyLCJtb2JpbGUiOjJ9fX19" data-wptb-cells-width-auto-count="2" data-wptb-extra-styles="" data-wptb-pro-pagination-top-row-header="false" data-wptb-rows-per-page="10" data-wptb-pro-search-top-row-header="false" data-wptb-searchbar-position="left" role="table" data-table-columns="2" data-wptb-table-alignment="center" data-wptb-td-width-auto="120" data-wptb-table-tds-sum-max-width="285" ><tbody data-global-font-size="15" ><tr  class="wptb-row " style=""><td class="wptb-cell " colspan="1" rowspan="1" style="padding: 10px; border-width: 1px; border-color: rgb(0, 0, 0); border-style: solid; border-radius: 0px; " data-y-index="0" data-x-index="0" data-wptb-css-td-auto-width="true" data-wptb-css-td-auto-height="true" data-wptb-cell-vertical-alignment="center" ><div class="wptb-text-container wptb-ph-element wptb-element-text-597" style="font-size: 15px; "><div style="position: relative;"><p style="text-align:center;"><strong>Part Name</strong></p></div></div></td><td class="wptb-cell " colspan="1" rowspan="1" style="padding: 10px; border-width: 1px; border-color: rgb(0, 0, 0); border-style: solid; border-radius: 0px; " data-y-index="0" data-x-index="1" data-wptb-css-td-auto-width="true" data-wptb-css-td-auto-height="true" data-wptb-cell-vertical-alignment="center" ><div class="wptb-text-container wptb-ph-element wptb-element-text-598" style="font-size: 15px; "><div style="position: relative;"><p style="text-align:center;"><strong>Quantity</strong></p></div></div></td></tr><tr  class="wptb-row " style=""><td class="wptb-cell " colspan="1" rowspan="1" style="padding: 10px; border-width: 1px; border-color: rgb(0, 0, 0); border-style: solid; border-radius: 0px; " data-y-index="1" data-x-index="0" data-wptb-css-td-auto-width="true" data-wptb-css-td-auto-height="true" data-wptb-cell-vertical-alignment="center" ><div class="wptb-text-container wptb-ph-element wptb-element-text-599" style="font-size: 15px; "><div style="position: relative;"><p>Front Lid.stl</p></div></div></td><td class="wptb-cell " colspan="1" rowspan="1" style="padding: 10px; border-width: 1px; border-color: rgb(0, 0, 0); border-style: solid; border-radius: 0px; " data-y-index="1" data-x-index="1" data-wptb-css-td-auto-width="true" data-wptb-css-td-auto-height="true" data-wptb-cell-vertical-alignment="center" ><div class="wptb-text-container wptb-ph-element wptb-element-text-600" style="font-size: 15px; "><div style="position: relative;"><p>1</p></div></div></td></tr><tr  class="wptb-row " style=""><td class="wptb-cell " colspan="1" rowspan="1" style="padding: 10px; border-width: 1px; border-color: rgb(0, 0, 0); border-style: solid; border-radius: 0px; " data-y-index="2" data-x-index="0" data-wptb-css-td-auto-width="true" data-wptb-css-td-auto-height="true" data-wptb-cell-vertical-alignment="center" ><div class="wptb-text-container wptb-ph-element wptb-element-text-601" style="font-size: 15px; "><div style="position: relative;"><p>Main Enclosure.stl</p></div></div></td><td class="wptb-cell " colspan="1" rowspan="1" style="padding: 10px; border-width: 1px; border-color: rgb(0, 0, 0); border-style: solid; border-radius: 0px; " data-y-index="2" data-x-index="1" data-wptb-css-td-auto-width="true" data-wptb-css-td-auto-height="true" data-wptb-cell-vertical-alignment="center" ><div class="wptb-text-container wptb-ph-element wptb-element-text-602" style="font-size: 15px; "><div style="position: relative;"><p>1</p></div></div></td></tr><tr  class="wptb-row " style=""><td class="wptb-cell " colspan="1" rowspan="1" style="padding: 10px; border-width: 1px; border-color: rgb(0, 0, 0); border-style: solid; border-radius: 0px; " data-y-index="3" data-x-index="0" data-wptb-css-td-auto-width="true" data-wptb-css-td-auto-height="true" data-wptb-cell-vertical-alignment="center" ><div class="wptb-text-container wptb-ph-element wptb-element-text-603" style="font-size: 15px; "><div style="position: relative;"><p>Leg Right X2.stl</p></div></div></td><td class="wptb-cell " colspan="1" rowspan="1" style="padding: 10px; border-width: 1px; border-color: rgb(0, 0, 0); border-style: solid; border-radius: 0px; " data-y-index="3" data-x-index="1" data-wptb-css-td-auto-width="true" data-wptb-css-td-auto-height="true" data-wptb-cell-vertical-alignment="center" ><div class="wptb-text-container wptb-ph-element wptb-element-text-604" style="font-size: 15px; "><div style="position: relative;"><p>2</p></div></div></td></tr><tr  class="wptb-row " style=""><td class="wptb-cell " colspan="1" rowspan="1" style="padding: 10px; border-width: 1px; border-color: rgb(0, 0, 0); border-style: solid; border-radius: 0px; " data-y-index="4" data-x-index="0" data-wptb-css-td-auto-width="true" data-wptb-css-td-auto-height="true" data-wptb-cell-vertical-alignment="center" ><div class="wptb-text-container wptb-ph-element wptb-element-text-605" style="font-size: 15px; "><div style="position: relative;"><p>Legs Left X2.stl</p></div></div></td><td class="wptb-cell " colspan="1" rowspan="1" style="padding: 10px; border-width: 1px; border-color: rgb(0, 0, 0); border-style: solid; border-radius: 0px; " data-y-index="4" data-x-index="1" data-wptb-css-td-auto-width="true" data-wptb-css-td-auto-height="true" data-wptb-cell-vertical-alignment="center" ><div class="wptb-text-container wptb-ph-element wptb-element-text-606" style="font-size: 15px; "><div style="position: relative;"><p>2</p></div></div></td></tr><tr  class="wptb-row " style=""><td class="wptb-cell " colspan="1" rowspan="1" style="padding: 10px; border-width: 1px; border-color: rgb(0, 0, 0); border-style: solid; border-radius: 0px; " data-y-index="5" data-x-index="0" data-wptb-css-td-auto-width="true" data-wptb-css-td-auto-height="true" data-wptb-cell-vertical-alignment="center" ><div class="wptb-text-container wptb-ph-element wptb-element-text-607" style="font-size: 15px; "><div style="position: relative;"><p>Right Side Arm_Empty.stl <strong><u>OR</u></strong> Right Side Arm_Hungry.stl <strong><u>OR</u></strong> Right Side Arm_Busy.stl</p></div></div></td><td class="wptb-cell " colspan="1" rowspan="1" style="padding: 10px; border-width: 1px; border-color: rgb(0, 0, 0); border-style: solid; border-radius: 0px; " data-y-index="5" data-x-index="1" data-wptb-css-td-auto-width="true" data-wptb-css-td-auto-height="true" data-wptb-cell-vertical-alignment="center" ><div class="wptb-text-container wptb-ph-element wptb-element-text-608" style="font-size: 15px; "><div style="position: relative;"><p>1</p></div></div></td></tr><tr  class="wptb-row " style=""><td class="wptb-cell " colspan="1" rowspan="1" style="padding: 10px; border-width: 1px; border-color: #000000; border-style: solid; border-radius: 0px; " data-y-index="6" data-x-index="0" data-wptb-css-td-auto-width="true" data-wptb-css-td-auto-height="true" data-wptb-cell-vertical-alignment="center" ><div class="wptb-text-container wptb-ph-element wptb-element-text-609" style="font-size: 1em; "><div style="position: relative;"><p>Left Side Arm_Empty.stl <strong><u>OR</u></strong> Left Side Arm_Iam.stl</p></div></div></td><td class="wptb-cell " colspan="1" rowspan="1" style="padding: 10px; border-width: 1px; border-color: #000000; border-style: solid; border-radius: 0px; " data-y-index="6" data-x-index="1" data-wptb-css-td-auto-width="true" data-wptb-css-td-auto-height="true" data-wptb-cell-vertical-alignment="center" ><div class="wptb-text-container wptb-ph-element wptb-element-text-610" style="font-size: 1em; "><div style="position: relative;"><p>1</p></div></div></td></tr></tbody></table>
</div>
</div>


<p class="wp-block-paragraph"></p>



<p class="has-text-align-justify wp-block-paragraph" style="font-size:18px;font-style:normal;font-weight:400">We are always amazed by the community builds! We are encouraging You to make edits and fork our design. Here you can download the STEP file of the Cairo Mini Desk Gadget 01.</p>



<div class="wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-fe48e5de wp-block-buttons-is-layout-flex">
<div class="wp-block-button"><a class="wp-block-button__link has-vivid-green-cyan-background-color has-background wp-element-button" href="https://grabcad.com/library/cairo-mini-desk-gadget-01-1" style="border-radius:50px" target="_blank" rel="noreferrer noopener">Download STEP File</a></div>
</div>



<p class="wp-block-paragraph"></p>



<p class="has-text-align-justify wp-block-paragraph" style="font-size:18px;font-style:normal;font-weight:400">Here is an Arduino code ino file for the ESP32 dev board that you can upload to your Cairo Mini Desk Gadget to get it working. This Arduino program utilizes the built-in WiFi on the board to communicate with the Google YouTube API to retrieve your channel stats and display them on the OLED Display.</p>



<p class="wp-block-paragraph">It&#8217;s just a base code. Feel free to customize it if you need. The possibilities are endless!</p>



<div class="wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-fe48e5de wp-block-buttons-is-layout-flex">
<div class="wp-block-button"><a class="wp-block-button__link has-vivid-green-cyan-background-color has-background wp-element-button" href="https://makesomestuff.org/wp-content/uploads/2026/03/YoutubeSubsCounterProgram.zip" style="border-radius:50px" target="_blank" rel="noreferrer noopener">Download the Arduino C program</a></div>
</div>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Inside the Arduino C program, you have to add this information:</p>



<ul class="wp-block-list">
<li class=""><strong>SSID:</strong> the name of your WiFi network.</li>



<li class=""><strong>Password:</strong> the password of your WiFi network.</li>



<li class=""><strong>API_KEY:</strong> Your <a href="https://console.cloud.google.com/apis/dashboard" target="_blank" rel="noreferrer noopener">Google Cloud</a> API key token. It&#8217;s a unique key. Don&#8217;t share it with anyone. You will have to create a new project on Google Cloud, then go to &#8220;Enable API &amp; Services&#8221;, search for &#8220;YouTube API&#8221;, select YouTube Data API v3, enable it, then create an API key credentials, copy the created key, and put it in your Arduino program.</li>



<li class=""><strong>CHANNEL_ID:</strong> It&#8217;s your unique YouTube channel ID. To get it, go to your YouTube channel from your browser, open YouTube Studio, open settings, open the channel tab, then select the advanced settings tab, then select &#8220;Manage YouTube account&#8221; under the other settings section, then select advanced settings, lastly copy your channel ID and paste it in your Arduino program.</li>
</ul>



<p class="wp-block-paragraph">To be able to upload the Arduino code to your Cairo Mini Desk Gadget. You have to install some libraries: the <a href="https://github.com/Bodmer/TFT_eSPI" target="_blank" rel="noreferrer noopener">TFT_eSPI library</a>, the <a href="https://github.com/lvgl/lvgl" target="_blank" rel="noreferrer noopener">LVGL library</a>, the <a href="https://github.com/witnessmenow/arduino-youtube-api?tab=readme-ov-file" type="link" id="https://github.com/witnessmenow/arduino-youtube-api?tab=readme-ov-file" target="_blank" rel="noreferrer noopener">YoutubeApi library</a>, the <a href="https://github.com/bblanchon/ArduinoJson" target="_blank" rel="noreferrer noopener">ArduinoJson library</a>, and any other libraries you asked to install when you upload your code.</p>



<p class="wp-block-paragraph">Here you can download the TFT_eSPI config file for the OLED display ST7789 SPI 1.3 inch 240px*240px and the wiring diagram for the device.</p>



<div class="wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-fe48e5de wp-block-buttons-is-layout-flex">
<div class="wp-block-button"><a class="wp-block-button__link has-vivid-green-cyan-background-color has-background wp-element-button" href="https://makesomestuff.org/wp-content/uploads/2026/03/TFT_eSPI-User-Config-File-and-Wiring-Diagram.zip" style="border-radius:50px" target="_blank" rel="noreferrer noopener">Download the Wiring Diagram and the TFT_eSPI config file</a></div>
</div>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">To design the GUI for the ESP32 dev board, I used the <a href="https://www.envox.eu/" target="_blank" rel="noreferrer noopener">EEZ Studio</a>. It&#8217;s an open-source software that you can freely download and use to tinker with the Cairo Mini Gadget GUI!</p>



<div class="wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-fe48e5de wp-block-buttons-is-layout-flex">
<div class="wp-block-button"><a class="wp-block-button__link has-vivid-green-cyan-background-color has-background wp-element-button" href="https://makesomestuff.org/wp-content/uploads/2026/03/youtubesubscounterGUI.zip" style="border-radius:50px" target="_blank" rel="noreferrer noopener">Download the EEZ Studio Project</a></div>
</div>



<hr class="is-style-wide wp-block-separator has-css-opacity"/>



<h2 class="wp-block-heading" style="font-size:48px">Donations</h2>



<p class="has-text-align-justify wp-block-paragraph" style="font-size:18px;font-style:normal;font-weight:400">Donations are totally optional and not necessary, but greatly appreciated!</p>



<div class="is-style-default wp-block-group alignwide is-vertical is-content-justification-center is-layout-flex wp-container-core-group-is-layout-20d0575b wp-block-group-is-layout-flex">
<figure class="wp-block-image size-medium wp-container-content-69bc4bdf"><img data-recalc-dims="1" loading="lazy" decoding="async" width="229" height="300" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/01/qr.png?resize=229%2C300&#038;ssl=1" alt="" class="wp-image-2935" style="object-fit:cover" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/01/qr.png?resize=229%2C300&amp;ssl=1 229w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/01/qr.png?w=745&amp;ssl=1 745w" sizes="auto, (max-width: 229px) 100vw, 229px" /></figure>



<script 
  src="https://www.paypal.com/sdk/js?client-id=BAAtWMzk__5mRq4mHZCP1z_0Zy5BywBQTttvVlef0w0mjhQfnC_B6Z57x_0ZTegvwjwq_iN202q7YOlTGM&#038;components=hosted-buttons&#038;disable-funding=venmo&#038;currency=USD">
</script>

<div style="width: 300px; margin: 0 auto; padding: 20px;" id="paypal-container-6YYX3TE8PGSD4"></div>
<script>
  paypal.HostedButtons({
    hostedButtonId: "6YYX3TE8PGSD4",
  }).render("#paypal-container-6YYX3TE8PGSD4")
</script>
</div>



<hr class="is-style-wide wp-block-separator has-css-opacity"/>



<h2 class="wp-block-heading" style="font-size:48px">Build Guide</h2>



<figure class="wp-embed-aspect-16-9 wp-has-aspect-ratio wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="عملت جهاز أتابع بيه إحصائيات قناة اليوتيوب بتاعتي ومش هتصدق ايه اللي حصل في أخر الفيديو!" width="770" height="433" src="https://www.youtube.com/embed/a6ODuo6hc3g?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<hr class="is-style-wide wp-block-separator has-css-opacity"/>



<h2 class="wp-block-heading" style="font-size:48px">Gallery</h2>



<figure class="wp-block-gallery has-nested-images columns-2 wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex">
<figure class="wp-block-image size-full"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="770" data-id="2952" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-1.jpg?resize=770%2C770&#038;ssl=1" alt="" class="wp-image-2952" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-1.jpg?w=3468&amp;ssl=1 3468w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-1.jpg?resize=300%2C300&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-1.jpg?resize=1024%2C1024&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-1.jpg?resize=150%2C150&amp;ssl=1 150w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-1.jpg?resize=1536%2C1536&amp;ssl=1 1536w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-1.jpg?resize=2048%2C2048&amp;ssl=1 2048w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-1.jpg?resize=370%2C370&amp;ssl=1 370w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-1.jpg?resize=100%2C100&amp;ssl=1 100w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-1.jpg?w=2310&amp;ssl=1 2310w" sizes="auto, (max-width: 770px) 100vw, 770px" /></figure>



<figure class="wp-block-image size-full"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="770" data-id="2953" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-2.jpg?resize=770%2C770&#038;ssl=1" alt="" class="wp-image-2953" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-2.jpg?w=3468&amp;ssl=1 3468w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-2.jpg?resize=300%2C300&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-2.jpg?resize=1024%2C1024&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-2.jpg?resize=150%2C150&amp;ssl=1 150w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-2.jpg?resize=1536%2C1536&amp;ssl=1 1536w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-2.jpg?resize=2048%2C2048&amp;ssl=1 2048w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-2.jpg?resize=370%2C370&amp;ssl=1 370w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-2.jpg?resize=100%2C100&amp;ssl=1 100w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-2.jpg?w=2310&amp;ssl=1 2310w" sizes="auto, (max-width: 770px) 100vw, 770px" /></figure>



<figure class="wp-block-image size-full"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="770" data-id="2955" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-Main-Photo.jpg?resize=770%2C770&#038;ssl=1" alt="" class="wp-image-2955" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-Main-Photo.jpg?w=3468&amp;ssl=1 3468w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-Main-Photo.jpg?resize=300%2C300&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-Main-Photo.jpg?resize=1024%2C1024&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-Main-Photo.jpg?resize=150%2C150&amp;ssl=1 150w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-Main-Photo.jpg?resize=1536%2C1536&amp;ssl=1 1536w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-Main-Photo.jpg?resize=2048%2C2048&amp;ssl=1 2048w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-Main-Photo.jpg?resize=370%2C370&amp;ssl=1 370w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-Main-Photo.jpg?resize=100%2C100&amp;ssl=1 100w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-Main-Photo.jpg?w=2310&amp;ssl=1 2310w" sizes="auto, (max-width: 770px) 100vw, 770px" /></figure>



<figure class="wp-block-image size-full"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="770" data-id="2954" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-3.jpg?resize=770%2C770&#038;ssl=1" alt="" class="wp-image-2954" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-3.jpg?w=3468&amp;ssl=1 3468w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-3.jpg?resize=300%2C300&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-3.jpg?resize=1024%2C1024&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-3.jpg?resize=150%2C150&amp;ssl=1 150w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-3.jpg?resize=1536%2C1536&amp;ssl=1 1536w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-3.jpg?resize=2048%2C2048&amp;ssl=1 2048w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-3.jpg?resize=370%2C370&amp;ssl=1 370w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-3.jpg?resize=100%2C100&amp;ssl=1 100w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2026/03/Cairo-Mini-Desk-Gadget-3.jpg?w=2310&amp;ssl=1 2310w" sizes="auto, (max-width: 770px) 100vw, 770px" /></figure>
</figure>
<p>The post <a href="https://makesomestuff.org/the-cairo-mini-desk-gadget-01/">Cairo Mini Desk Gadget 01</a> appeared first on <a href="https://makesomestuff.org">Make Some Stuff</a>.</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2956</post-id>	</item>
		<item>
		<title>IoT Using Raspberry Pi and Firebase and Android</title>
		<link>https://makesomestuff.org/iot-using-raspberry-pi-and-firebase-and-android/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=iot-using-raspberry-pi-and-firebase-and-android</link>
					<comments>https://makesomestuff.org/iot-using-raspberry-pi-and-firebase-and-android/#respond</comments>
		
		<dc:creator><![CDATA[Ahmed Ibrahim]]></dc:creator>
		<pubDate>Thu, 03 Oct 2019 11:32:17 +0000</pubDate>
				<category><![CDATA[Raspberry Pi Projects]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Firebase]]></category>
		<category><![CDATA[IoT]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<guid isPermaLink="false">https://makesomestuff.org/?p=448</guid>

					<description><![CDATA[<p><a href="https://makesomestuff.org">Make Some Stuff</a><br />
<a href="https://makesomestuff.org/iot-using-raspberry-pi-and-firebase-and-android/">IoT Using Raspberry Pi and Firebase and Android</a></p>
<p>Ever asked how to control your home light system wirelessly over the Internet from any place in the world?! in this step-by-step tutorial we will learn how to do that. Used Components Component Name Quantity Raspberry Pi 3 Model B 1 Darlington Transistor TIP 122 3 2-screws Terminal Block 3 1K ohm Resistors 3 3-pins [...]</p>
<p>The post <a href="https://makesomestuff.org/iot-using-raspberry-pi-and-firebase-and-android/">IoT Using Raspberry Pi and Firebase and Android</a> appeared first on <a href="https://makesomestuff.org">Make Some Stuff</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><a href="https://makesomestuff.org">Make Some Stuff</a><br />
<a href="https://makesomestuff.org/iot-using-raspberry-pi-and-firebase-and-android/">IoT Using Raspberry Pi and Firebase and Android</a></p>

<p class="has-regular-font-size wp-block-paragraph">Ever asked how to control your home light system wirelessly over the Internet from any place in the world?! in this step-by-step tutorial we will learn how to do that.</p>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4043148098486780" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-4043148098486780" data-ad-slot="5056799298"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<figure class="aligncenter wp-embed-aspect-16-9 wp-has-aspect-ratio wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="IoT using Raspberry Pi and firebase and android" width="770" height="433" src="https://www.youtube.com/embed/LoanD1NIfGA?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div><figcaption class="wp-element-caption">Final Project</figcaption></figure>



<h2 class="wp-block-heading">Used Components</h2>



<hr class="wp-block-separator has-css-opacity"/>



<figure class="is-style-regular wp-block-table"><table><tbody><tr><td><strong><span style="text-decoration: underline;">Component Name</span></strong></td><td><strong><span style="text-decoration: underline;">Quantity </span></strong></td></tr><tr><td><a href="https://www.raspberrypi.org/products/raspberry-pi-3-model-b/">Raspberry Pi 3 Model B</a></td><td>1</td></tr><tr><td><a href="https://www.ebay.com/itm/10PCS-TIP122-5A-100V-NPN-TO-220-Darlington-transistor/232424590421?hash=item361d95cc55:g:CI8AAOSwM8ZZeCJC">Darlington Transistor TIP 122 </a></td><td>3</td></tr><tr><td><a href="https://www.sparkfun.com/products/10571">2-screws Terminal Block</a></td><td>3</td></tr><tr><td><a href="https://www.sparkfun.com/products/14492">1K ohm Resistors</a></td><td>3</td></tr><tr><td><a href="https://www.sparkfun.com/products/9609">3-pins slide switch</a></td><td>1</td></tr><tr><td><a href="https://www.sparkfun.com/products/14017">20&#215;2 Female Pin Header </a></td><td>1</td></tr><tr><td><a href="https://www.pcbway.com/project/shareproject/IoT_Using_Raspberry_Pi_and_Firebase_and_Android.html">PCBWay Custom PCB Manufacturing</a></td><td>1</td></tr><tr><td><a href="https://www.ebay.com/itm/5V-12V24V-Lighting-Transformer-5A-10A-Switching-Power-Supply-60W-120W-150W-360W/233343017898?hash=item365453e3aa:m:m5ReQeegdY0R0CweUFJL9RQ">12V 5A Power Supply</a></td><td>1</td></tr><tr><td><a href="https://www.sparkfun.com/products/8431">Male-male Jumper wires</a></td><td>10</td></tr></tbody></table></figure>



<h2 class="wp-block-heading">Used Software</h2>



<hr class="wp-block-separator has-css-opacity"/>



<ul class="wp-block-list">
<li class=""><a href="https://www.autodesk.com/products/eagle/overview">Autodesk Eaglecad</a> (Optional).</li>



<li class=""><a href="https://firebase.google.com/docs/database">Firebase Database</a>.</li>



<li class="">Python Editor (Any Editor will work fine).</li>
</ul>



<h2 class="wp-block-heading">Introduction</h2>



<hr class="wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph">Today, we will learn how to control any RGB LED Strip ambient light wirelessly over Wifi using a custom-built Andoird application connected with the awesome Raspberry Pi board through the Firebase database.</p>



<p class="has-regular-font-size wp-block-paragraph">To build this project we need to deal with some stuff like how to build an android mobile app, how to build a firebase database server, how to connect the raspberry pi and the android app together through firebase, how to take different actions based on the incoming data, some power management, electronics Wiring, &#8230; <br>But yo hold on! Don&#8217;t worry we will cover all these topics in detail in today&#8217;s tutorial. So, bear with me and I promise it will be worth it.</p>



<h2 class="wp-block-heading">Project Overview/Features</h2>



<hr class="wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph">Simply, today we will build a smart device that allows the user to control his/her home ambient lighting system wirelessly over Wifi using any android smartphone, our project is divided into four main parts</p>



<ul class="wp-block-list">
<li class=""><strong>Android mobile application.<br></strong>the mobile app is the control panel which the user will interact with to send his/her commands to the lighting system.</li>



<li class=""><strong>Database.</strong><br>is the global server which acts as a postman who takes mails from one person to deliver it to someone else. Firebase database will receive some data from the mobile app and send it to the raspberry pi to take some actions like changing the LED strip light intensity or light color, and other many stuff.</li>



<li class=""><strong>Electronic and control circuit.</strong><br>the control circuit will be based on the raspberry pi board which running a python script reading the incoming data from the firebase database and according to these data will take some different actions.</li>



<li class=""><strong>Power management.</strong><br>it&#8217;s the most crucial part, it&#8217;s the part which responsible for providing the device with the necessary power to operate properly without damages.</li>
</ul>



<h2 class="wp-block-heading">How does the project work?</h2>



<hr class="wp-block-separator has-css-opacity"/>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="433" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/project-working-logic.png?resize=770%2C433&#038;ssl=1" alt="Project Working Logic" class="wp-image-461" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/project-working-logic.png?w=1920&amp;ssl=1 1920w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/project-working-logic.png?resize=800%2C450&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/project-working-logic.png?resize=300%2C169&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/project-working-logic.png?resize=768%2C432&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/project-working-logic.png?resize=1024%2C576&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/project-working-logic.png?resize=1026%2C577&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/project-working-logic.png?resize=675%2C380&amp;ssl=1 675w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/project-working-logic.png?w=1540&amp;ssl=1 1540w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">Project Working Logic</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">Simply, the mobile app and the raspberry pi board are connected to the same firebase database. this database saves the data which comes from the mobile app and syncs it with the raspberry pi board in milliseconds, according to these data the raspberry pi board will take some specific actions like turning on the light, changing its brightness, and so on.</p>



<h2 class="wp-block-heading">Control Three LEDs brightness using GPIO PWM</h2>



<hr class="wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph">To control the RGB LED Strip light brightness you need to be familiar with the PWM technique in the raspberry pi world and how to use it. So, let&#8217;s start by a simple one and start controlling some normal 5mm LEDs brightness to get familiar with the PWM technique. As I promised you at the beginning of the tutorial, we will start it from scratch to understand every part of the project.</p>



<p class="has-regular-font-size wp-block-paragraph">PWM stands for &#8220;Pulse Width Modulation&#8221; which is used to generate analog values using a digital technique. PWM is usually used to control LEDs brightness, DC Motor speed control, Servo motor rotation angle and that happens by outputting some variable voltage level.<br><br>But as we all know that the RPi and any computer is entirely digital system. But at the same time, we need to generate some analog signals from it. So, we need to find a way to convert that digital output signal to an analog output signal. Here comes the PWM technique!</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="214" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/pwm-signal.png?resize=770%2C214&#038;ssl=1" alt="PWM signal Chart" class="wp-image-466" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/pwm-signal.png?w=815&amp;ssl=1 815w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/pwm-signal.png?resize=800%2C223&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/pwm-signal.png?resize=300%2C84&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/pwm-signal.png?resize=768%2C214&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/pwm-signal.png?resize=675%2C188&amp;ssl=1 675w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">PWM signal Chart</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">Most of the devices around us are responding relatively in the world of electronics slowly to the signal that they are getting. So, let&#8217;s take a normal DC motor as an example, let&#8217;s say that we need to run this DC motor at its half speed. So, we need to give it half of its voltage to run at half of its speed. Basically, we are only capable of giving a 3.3V(logic 1) or 0V (logic 0) we can&#8217;t give value in between because it&#8217;s a digital system as we said before. But here comes the PWM role to modulate the signal up(3.3V) for half the time and down(0V) for half the time with a square wave which is called the <strong>duty cycle</strong>. that process happens very very rapidly and the motor can&#8217;t respond instantaneously to the change of the voltage so it takes some time to accelerate and decelerate which results, the motor averaging the voltage to something near 1.6V and will run at half of its speed. And you can change the motor speed by changing the duty cycle value.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="542" height="342" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Duty_Cycle_Examples.png?resize=542%2C342&#038;ssl=1" alt="Duty cycle value change" class="wp-image-469" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Duty_Cycle_Examples.png?w=542&amp;ssl=1 542w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Duty_Cycle_Examples.png?resize=300%2C189&amp;ssl=1 300w" sizes="auto, (max-width: 542px) 100vw, 542px" /><figcaption class="wp-element-caption">Duty cycle value change</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">If we take a normal LED as an example we will do the same previous process applying PWM, but because the LED is a simple diode it responds fairly quickly (faster than the motor) to the change of the signal, so your eyes as a human will make the averaging thing. As a result, you will see the LED changing its brightness.</p>



<ul class="wp-block-list">
<li class=""><strong>Period:</strong> It&#8217;s the sum of the HIGH(3.3V) time and the LOW(0V) time.</li>



<li class=""><strong>Duty Cycle: </strong>Its the percentage of time where the signal was HIGH(3.3V) during the time of period.</li>
</ul>



<p class="has-regular-font-size wp-block-paragraph">Enough Theory! Let&#8217;s make some stuff. Let&#8217;s take a look at the wiring diagram.</p>



<h4 class="wp-block-heading">Wiring Diagram</h4>



<hr class="wp-block-separator has-css-opacity"/>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="923" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/three_LED_PWM.png?resize=770%2C923&#038;ssl=1" alt="Wiring Diagram" class="wp-image-473" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/three_LED_PWM.png?w=1116&amp;ssl=1 1116w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/three_LED_PWM.png?resize=800%2C959&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/three_LED_PWM.png?resize=250%2C300&amp;ssl=1 250w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/three_LED_PWM.png?resize=768%2C921&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/three_LED_PWM.png?resize=854%2C1024&amp;ssl=1 854w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/three_LED_PWM.png?resize=1026%2C1230&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/three_LED_PWM.png?resize=675%2C809&amp;ssl=1 675w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">Wiring Diagram</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">The wiring diagram is very simple, connect each LED on a different PWM pin</p>



<figure class="is-style-stripes wp-block-table"><table><tbody><tr><td>Red LED</td><td>GPIO 12(PWM0)</td></tr><tr><td>Green LED</td><td>GPIO 18(PWM0)</td></tr><tr><td>Blue LED</td><td>GPIO 19(PWM1)</td></tr></tbody></table></figure>



<p class="has-regular-font-size wp-block-paragraph">The raspberry pi has two different schemes in numbering its GPIO pins. you can use either pin numbers<strong>(BOARD)</strong> or the Broadcom GPIO pin numbers<strong>(BCM)</strong>. <strong>You can only use one numbering scheme in each program</strong>.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="803" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/pi3_gpio_z4Rfmm2PRu.png?resize=770%2C803&#038;ssl=1" alt="RPi GPIO Pinout" class="wp-image-475" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/pi3_gpio_z4Rfmm2PRu.png?w=920&amp;ssl=1 920w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/pi3_gpio_z4Rfmm2PRu.png?resize=800%2C835&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/pi3_gpio_z4Rfmm2PRu.png?resize=288%2C300&amp;ssl=1 288w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/pi3_gpio_z4Rfmm2PRu.png?resize=768%2C801&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/pi3_gpio_z4Rfmm2PRu.png?resize=675%2C704&amp;ssl=1 675w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">RPi GPIO Pinout</figcaption></figure>
</div>


<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4043148098486780" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-4043148098486780" data-ad-slot="5056799298"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="wp-block-paragraph">GPIO Board: Referring to the pin by its number of the plug, the pin number on the physical board which printed on it. Example: PIN#1, PIN#2, …..<br>GPIO BCM: Referring to the pin by its &#8220;Broadcom SOC Channel&#8221; number, these are the numbers after the GPIO word. Example: GPIO12, GPIO19, ….</p>



<p class="wp-block-paragraph">Neither way is wrong, both ways are good and work well without any differences. You have to pick the one which you feel comfortable more with.</p>



<p class="has-regular-font-size wp-block-paragraph">The <strong>Raspberry Pi 3 Model B</strong> has two PWM channels (PWM0, PWM1) each channel has two different GPIO PWM pins available for use. </p>



<figure class="wp-block-table"><table><tbody><tr><td><strong>GPIO BCM</strong></td><td><strong>GPIO BOARD</strong></td><td><strong>PWM channel</strong></td></tr><tr><td>GPIO12</td><td>Pin#32</td><td>PWM0</td></tr><tr><td>GPIO18</td><td>Pin#12</td><td>PWM0</td></tr><tr><td>GPIO19</td><td>Pin#35</td><td>PWM1</td></tr><tr><td>GPIO13</td><td>pin#33</td><td>PWM1</td></tr></tbody></table></figure>



<p class="has-regular-font-size wp-block-paragraph">These three PWM pins <strong>GPIO12, GPIO 13, GPIO19</strong> are used by the <strong>A/V output audio jack</strong>. So, if you don&#8217;t need to use the A/V audio jack in your project, these three GPIO PWM pins will be free and available to get used. But you can&#8217;t use the A/V output Audio jack and these PWM pins at the same time. In today&#8217;s project, we don&#8217;t need to use the A/V audio jack so all the PWM pins will be free and available for us to use.</p>



<h4 class="wp-block-heading">Code </h4>



<hr class="wp-block-separator has-css-opacity"/>



<pre class="EnlighterJSRAW" data-enlighter-language="python" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import RPi.GPIO as GPIO             #import the raspberry pi GPIO library, to be able to use them.
from time import sleep              #import the sleep library, which responsible to do the timing stuff.


redLED = 18				#red LED connected on PWM pin GPIO18
blueLED = 12            #blue LED connected on PWM pin GPIO12
greenLED = 19           #green LED connected on PWM pin GPIO19

GPIO.setwarnings(False)			#disable warnings
GPIO.setmode(GPIO.BCM)	        #set pin numbering system to the (Broadcom chip channel numbering).

GPIO.setup(redLED,GPIO.OUT)     #set the red LED pin(GPIO18) to an output pin.
GPIO.setup(blueLED,GPIO.OUT)    #set the blue LED pin(GPIO12) to an output pin.
GPIO.setup(greenLED,GPIO.OUT)   #set the green LED pin(GPIO19) to an output pin.

red_pwm = GPIO.PWM(redLED,1000)	       	      #create PWM instance with 1000Hz frequency.
blue_pwm = GPIO.PWM(blueLED,1000)             #create PWM instance with 1000Hz frequency.
green_pwm = GPIO.PWM(greenLED,1000)           #create PWM instance with 1000Hz frequency.

red_pwm.start(0)				              #start red LED PWM pin with 0% initial Duty Cycle (OFF).
blue_pwm.start(0)                             #start blue LED PWM pin with 0% initial Duty Cycle (OFF).
green_pwm.start(0)                            #start green LED PWM pin with 0% initial Duty Cycle (OFF).

print("AH Shit! Here we go again! Press CTRL+C to exit")    #Take Care, Meme LORD.

try:
    while True:                                         #the start of the actual program.
        for duty in range(0,101,1):                     #imolement a "for loop" responsible for increasing the red LED light brightness.
            red_pwm.ChangeDutyCycle(duty)               #provide duty cycle in the range 0-100.
            sleep(0.01)                                 #wait 0.01 sec. between each iteration.
        sleep(0.5)                                      #wait 0.5 sec. after the "for loop" is done.

        for duty in range(100,-1,-1):                   #implement a "for loop" responsible for decreasing the red LED light brightness.
            red_pwm.ChangeDutyCycle(duty)               #provide duty cycle in the range 100-0.
            sleep(0.01)                                 #wait 0.01 sec. between each iteration.
        sleep(0.5)                                      #wait 0.5 sec. after the "for loop" is done.
		
        for duty in range (0, 101, 1):                  #repeat the previous logic but this time with the blue LED.
            blue_pwm.ChangeDutyCycle(duty)
            sleep(0.01)
        sleep(0.5)

        for duty in range (100, -1, -1):                #repeat the previous logic but this time with the blue LED.
            blue_pwm.ChangeDutyCycle(duty)
            sleep(0.01)
        sleep(0.5)

        for duty in range(0,101,1):                     #repeat the previous logic but this time with the green LED.
            green_pwm.ChangeDutyCycle(duty)
            sleep(0.01)
        sleep(0.5)

        for duty in range(100,-1,-1):                   #repeat the previous logic but this time with the green LED.
            green_pwm.ChangeDutyCycle(duty)
            sleep(0.01)
        sleep(0.5)

except KeyboardInterrupt: 		# If CTRL+C is pressed, exit cleanly:
    red_pwm.stop() 			    # stop red PWM
    blue_pwm.stop()             # stop blue PWM
    green_pwm.stop()            # stop green  PWM
    GPIO.cleanup() 	            # cleanup all GPIO</pre>



<h4 class="wp-block-heading">Code Explanation</h4>



<hr class="wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph">The code is pretty simple and straightforward, first, we need to import two important modules to allow us to use the raspberry pi GPIO pins. Also, import the <strong>time</strong> module that will make the timing work for us. without importing this module you will not be able to use the <code>sleep()</code> method.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="python" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import RPi.GPIO as GPIO
from time import sleep</pre>



<p class="has-regular-font-size wp-block-paragraph">then we need to initialize three variables called <code>redLED</code>, <code>blueLED</code>, <code>greenLED</code> referring to the three PWM pins that we will use to control our LEDs. Yeah as you noticed we are using the <strong>GPIO BCM</strong> <strong>numbering scheme</strong>.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="python" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">redLED = 18
blueLED = 12
greenLED = 19</pre>



<p class="has-regular-font-size wp-block-paragraph">Then we need to set the numbering scheme of raspberry pi pins to &#8220;GPIO BCM&#8221;, then set all the three pins as output pins.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="python" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">GPIO.setmode(GPIO.BCM)

GPIO.setup(redLED,GPIO.OUT)
GPIO.setup(blueLED,GPIO.OUT)
GPIO.setup(greenLED,GPIO.OUT)</pre>



<p class="has-regular-font-size wp-block-paragraph">create three PWM instances(instance for each pin) <code>red_pwm</code>, <code>blue_pwm</code>, <code>green_pwm </code>with 1000Hz frequency that will help us to generate the PWM signal. After that, we need to set the initial state of these pins to 0% duty cycle which means that the three pins will be OFF at the beginning of the program.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="python" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">red_pwm = GPIO.PWM(redLED,1000)
blue_pwm = GPIO.PWM(blueLED,1000)
green_pwm = GPIO.PWM(greenLED,1000)

red_pwm.start(0)
blue_pwm.start(0)
green_pwm.start(0)</pre>



<p class="has-regular-font-size wp-block-paragraph">Here is the fun part! inside the <code>while loop</code> we write the set of commands(program) that we need to keep executing forever until we force-stop it.<br><br>inside the <code>while loop</code> implement a &#8220;for loop&#8221; it&#8217;s initial value 0, at every iteration it will increment by 1 until it reaches 100. This <code>for loop</code> responsible for increasing the red LED light brightness.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="python" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">while True:                                       
    for duty in range(0,101,1):
        red_pwm.ChangeDutyCycle(duty)
        sleep(0.01)
    sleep(0.5)</pre>



<p class="has-regular-font-size wp-block-paragraph">The second <code>for loop</code> it&#8217;s initial value 100, at every iteration will decrease by 1 until it reaches 0. this <code>for loop</code> is responsible for decreasing the red LED light brightness.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="python" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">    for duty in range(100,-1,-1):
        red_pwm.ChangeDutyCycle(duty)
        sleep(0.01)
    sleep(0.5)</pre>



<p class="has-regular-font-size wp-block-paragraph">then repeat the previous logic with the remaining two LEDs. After finishing your code, close and save it, run it by writing <code>python fileName.py</code> in the terminal. </p>



<p class="has-regular-font-size wp-block-paragraph">After running it, It&#8217;s expected to see this sentence got printed on the terminal <code>AH Shit! Here we go again! Press CTRL+C to exit</code> then the three LEDs light brightness will start to increase and decrease. </p>



<p class="has-regular-font-size wp-block-paragraph">I will assume that you did that and it&#8217;s working fine with you. VOILA! Officially you are now promoted to the next level. Let&#8217;s make it more interesting and control the beefy RGB LED Strip.</p>



<h2 class="wp-block-heading">Control RGB LED Strip Lighting  </h2>



<hr class="wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph">Actually, controlling an RGB LED it&#8217;s not very different from controlling a normal LED. RGB LED means red, green and blue LED which combines all these three LEDs in one combo. with these three different colors, you can produce almost any color by mixing them with different intensities. To adjust LED intensity we use the PWM technique.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="192" height="192" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/RGB.png?resize=192%2C192&#038;ssl=1" alt="single RGB LED" class="wp-image-496" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/RGB.png?w=192&amp;ssl=1 192w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/RGB.png?resize=100%2C100&amp;ssl=1 100w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/RGB.png?resize=150%2C150&amp;ssl=1 150w" sizes="auto, (max-width: 192px) 100vw, 192px" /><figcaption class="wp-element-caption">single RGB LED</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">For example, to generate a pure red color, we need to set the red LED to the highest intensity and the green, blue to the lowest intensity. To generate a white color we have to set all the three LEDs to the highest intensity. And By adjusting the intensity of each LED you will generate a new color.</p>



<h4 class="wp-block-heading">RGB LED Strip pinout</h4>



<hr class="wp-block-separator has-css-opacity"/>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="500" height="203" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/led_strips_astripend_t.jpg?resize=500%2C203&#038;ssl=1" alt="RGB LED Strip pinout" class="wp-image-501" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/led_strips_astripend_t.jpg?w=500&amp;ssl=1 500w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/led_strips_astripend_t.jpg?resize=300%2C122&amp;ssl=1 300w" sizes="auto, (max-width: 500px) 100vw, 500px" /><figcaption class="wp-element-caption">RGB LED Strip pinout</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">There are two main types of RGB LED strips. The common anode, and the common cathode. In the common anode RGB LED strip, the three LEDs share the same positive lead <strong>(Anode)</strong>, and in the common cathode RGB LED strip, the three LEDs share the same negative lead <strong>(Cathode)</strong>. As a result of that, the RGB LED strip has four leads, one for each LED (red, green, blue) and one common anode or common cathode.</p>



<p class="has-regular-font-size wp-block-paragraph">The RGB LED strip that we will use today is Common Anode.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="433" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/common-anode-and-common-cathode.png?resize=770%2C433&#038;ssl=1" alt="Difference between the common anode and common cathode" class="wp-image-503" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/common-anode-and-common-cathode.png?w=1920&amp;ssl=1 1920w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/common-anode-and-common-cathode.png?resize=800%2C450&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/common-anode-and-common-cathode.png?resize=300%2C169&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/common-anode-and-common-cathode.png?resize=768%2C432&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/common-anode-and-common-cathode.png?resize=1024%2C576&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/common-anode-and-common-cathode.png?resize=1026%2C577&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/common-anode-and-common-cathode.png?resize=675%2C380&amp;ssl=1 675w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/common-anode-and-common-cathode.png?w=1540&amp;ssl=1 1540w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">Difference between the common anode and common cathode</figcaption></figure>
</div>


<h4 class="wp-block-heading">Power Management</h4>



<hr class="wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph">Before we connect the RGB LED strip with raspberry pi we need to ask ourselves, Does the raspberry pi board able to provide the beefy RGB LED strip with the needed power to operate properly? The short answer is, of course not. </p>



<p class="has-regular-font-size wp-block-paragraph">If you are a math nerd let&#8217;s do some calculations. we need to know how much current our RGB LED Strip is going to draw. each RGB cell contains three LEDs<strong>(red, green, blue)</strong> each LED in the cell draws <strong>20mA</strong> at full intensity. So, each RGB cell will draw a current of total <strong>60mA</strong> at full intensity, the RGB LED Strip that we are using today contains <strong>20 cells/one meter</strong>, and we have a <strong>4-meter long strip</strong>. So, Which means that the total drawn current at maximum intensity is equal to:<br><strong><em>4(Meter)*20(cell/meter)*60(mA) = 4800MA.</em></strong></p>



<p class="has-regular-font-size wp-block-paragraph">this amount of drawn current will vary depending on the intensity of the LED brightness that you are working with, but we made the calculations at the highest values to work freely and be on the safe side. Now we need a power source that can provide us with those <strong>4.8A</strong> at <strong>12V</strong>.</p>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4043148098486780" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-4043148098486780" data-ad-slot="5056799298"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="has-regular-font-size wp-block-paragraph">The best option I found for that job, is a power supply/converter that converts an AC power to DC, the power supply/converter that we will use today offers 5A at 12VDC which is exactly what we need.</p>



<h4 class="wp-block-heading">The Power Supply Connections</h4>



<hr class="wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph">A power supply is an electrical device that converts one type of electrical type to another. In our case, we will convert a 220VAC to 12VDC.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="578" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/IMG_1686.jpg?resize=770%2C578&#038;ssl=1" alt="The power supply pinout" class="wp-image-511" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/IMG_1686.jpg?w=2048&amp;ssl=1 2048w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/IMG_1686.jpg?resize=600%2C450&amp;ssl=1 600w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/IMG_1686.jpg?resize=800%2C600&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/IMG_1686.jpg?resize=300%2C225&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/IMG_1686.jpg?resize=768%2C576&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/IMG_1686.jpg?resize=1024%2C768&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/IMG_1686.jpg?resize=1026%2C770&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/IMG_1686.jpg?resize=675%2C506&amp;ssl=1 675w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/IMG_1686.jpg?resize=480%2C360&amp;ssl=1 480w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/IMG_1686.jpg?w=1540&amp;ssl=1 1540w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">The power supply pinout</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">From the left side, the first three terminals are the input from the AC power source:</p>



<ul class="wp-block-list">
<li class=""><strong>L:</strong> life.</li>



<li class=""><strong>N:</strong> neutral.</li>



<li class=""><strong>GND:</strong> earth.</li>
</ul>



<p class="has-regular-font-size wp-block-paragraph">The last four terminals are the 12VDC output, the first two terminals are the <strong>GND</strong> and the second two terminals are <strong>positive</strong>.</p>



<ul class="wp-block-list">
<li class=""><strong>V-:</strong> GND.</li>



<li class=""><strong>V+:</strong> positive.</li>
</ul>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="578" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/IMG_1681.jpg?resize=770%2C578&#038;ssl=1" alt="Power Supply Connections" class="wp-image-508" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/IMG_1681.jpg?w=1170&amp;ssl=1 1170w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/IMG_1681.jpg?resize=600%2C450&amp;ssl=1 600w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/IMG_1681.jpg?resize=800%2C600&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/IMG_1681.jpg?resize=300%2C225&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/IMG_1681.jpg?resize=768%2C576&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/IMG_1681.jpg?resize=1024%2C768&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/IMG_1681.jpg?resize=1026%2C770&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/IMG_1681.jpg?resize=675%2C506&amp;ssl=1 675w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/IMG_1681.jpg?resize=480%2C360&amp;ssl=1 480w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">Power Supply Connections</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">And we connect them as follow:</p>



<ul class="wp-block-list">
<li class=""><strong>Brown wire (AC Power source):</strong> L (Power supply).</li>



<li class=""><strong>Blue wire (AC Power source):</strong> N (Power supply).</li>



<li class=""><strong>Green wire (AC Power source):</strong> Earth (Power supply).</li>
</ul>



<p class="has-regular-font-size wp-block-paragraph">And the red, and the black wire are the 12VDC output:</p>



<ul class="wp-block-list">
<li class=""><strong>Red Wire: </strong>12VDC Output (V+).</li>



<li class=""><strong>Black Wire:</strong> GND Output (V-).</li>
</ul>



<h4 class="wp-block-heading">Wiring Diagram</h4>



<hr class="wp-block-separator has-css-opacity"/>



<figure class="wp-block-image"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="568" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/LED-Strip.png?resize=770%2C568&#038;ssl=1" alt="RGB LED Strip wiring diagram" class="wp-image-505" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/LED-Strip.png?w=2048&amp;ssl=1 2048w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/LED-Strip.png?resize=800%2C590&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/LED-Strip.png?resize=300%2C221&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/LED-Strip.png?resize=768%2C566&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/LED-Strip.png?resize=1024%2C755&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/LED-Strip.png?resize=1026%2C756&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/LED-Strip.png?resize=675%2C498&amp;ssl=1 675w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/LED-Strip.png?w=1540&amp;ssl=1 1540w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">RGB LED Strip wiring diagram</figcaption></figure>



<p class="has-regular-font-size wp-block-paragraph">As we stated before, the RGB LED strip needs 4.8A at 12VDC to operate properly. But at the same time, the Raspberry pi board can&#8217;t provide all that power to the RGB LED strip. So, we need a component that can take orders from the Raspberry pi board but provide power from the external 12VDC power supply.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="770" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Tip_122-800x800.jpg?resize=770%2C770&#038;ssl=1" alt="TIP122 NPN Transistor" class="wp-image-517" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Tip_122-800x800.jpg?resize=800%2C800&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Tip_122-800x800.jpg?resize=100%2C100&amp;ssl=1 100w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Tip_122-800x800.jpg?resize=150%2C150&amp;ssl=1 150w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Tip_122-800x800.jpg?resize=300%2C300&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Tip_122-800x800.jpg?resize=768%2C768&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Tip_122-800x800.jpg?resize=675%2C675&amp;ssl=1 675w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">TIP122 NPN Transistor</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">Here comes the TIP122 Darlington transistor, this transistor can drive high power loads by using a small amount of current and voltage.</p>



<p class="has-regular-font-size wp-block-paragraph">The TIP122 transistor can handle current up to 5A<strong>(Continous)</strong> and 8A<strong>(Peak)</strong> which satisfies our needs.</p>



<h4 class="wp-block-heading">TIP122 Transistor Pinout</h4>



<hr class="wp-block-separator has-css-opacity"/>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="450" height="461" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/TIP122-Darlington-NPN-Transistor.jpg?resize=450%2C461&#038;ssl=1" alt="TIP122 pinout" class="wp-image-516" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/TIP122-Darlington-NPN-Transistor.jpg?w=450&amp;ssl=1 450w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/TIP122-Darlington-NPN-Transistor.jpg?resize=293%2C300&amp;ssl=1 293w" sizes="auto, (max-width: 450px) 100vw, 450px" /><figcaption class="wp-element-caption">TIP122 pinout</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">TIP122 Transistor acts like a switch that can drive loads with higher electrical requirements, so by a small amount of current and voltage can drive a high power load, at this example we gonna use the TIP122 which completes the LED strip circuit with the 12-volt power supply, the TIP122 has three legs(base, collector, emitter). The collector will get connected to the load(LED strip), and the emitter will get connected to the ground. And by a small amount of current on the base pin, will close the circuit between the collector and the emitter.</p>



<h2 class="wp-block-heading">Make it More Professional</h2>



<hr class="wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph">What about transferring our breadboard circuit to a professional <strong>printed circuit board&nbsp;(PCB)</strong>&nbsp;to make our project more rigid and solid.</p>



<h4 class="wp-block-heading">Raspberry Pi HAT files (PCB)</h4>



<hr class="wp-block-separator has-css-opacity"/>



<p class="wp-block-paragraph">I designed the project circuit using Autodesk Eagle software. all the PCB files are open-source you can access it from that link. We love open source <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<div class="aligncenter wp-block-button"><a class="wp-block-button__link wp-element-button" href="https://www.pcbway.com/project/shareproject/IoT_Using_Raspberry_Pi_and_Firebase_and_Android.html">pcb files</a></div>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="337" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/two-layers.png?resize=770%2C337&#038;ssl=1" alt="PCB bottom and top layer" class="wp-image-645" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/two-layers.png?w=1170&amp;ssl=1 1170w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/two-layers.png?resize=800%2C350&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/two-layers.png?resize=300%2C131&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/two-layers.png?resize=768%2C336&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/two-layers.png?resize=1024%2C448&amp;ssl=1 1024w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">PCB bottom and the top layer</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph"><strong>You can order your own PCB From&nbsp;<a href="https://www.pcbway.com/">PCBWay</a>&nbsp;company these guys have a very good reputation in this field and they ship to more than 170 countries around the world with reasonable prices. all you have to do is to open the project&nbsp;PCB files link&nbsp;and click “Add to cart”. That’s it!</strong></p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="357" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-03-at-3.52.38-AM.png?resize=770%2C357&#038;ssl=1" alt="PCB Files" class="wp-image-648" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-03-at-3.52.38-AM.png?w=1170&amp;ssl=1 1170w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-03-at-3.52.38-AM.png?resize=800%2C371&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-03-at-3.52.38-AM.png?resize=300%2C139&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-03-at-3.52.38-AM.png?resize=768%2C356&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-03-at-3.52.38-AM.png?resize=1024%2C475&amp;ssl=1 1024w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">PCB Files</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">This PCB can get mounted over the Raspberry pi board easily as a normal raspberry pi HAT, it will organize your wiring and will make your project easier to debug.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="578" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/IMG_5100.jpg?resize=770%2C578&#038;ssl=1" alt="Custom PCB Raspberry Pi HAT" class="wp-image-678" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/IMG_5100.jpg?w=1170&amp;ssl=1 1170w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/IMG_5100.jpg?resize=600%2C450&amp;ssl=1 600w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/IMG_5100.jpg?resize=800%2C600&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/IMG_5100.jpg?resize=300%2C225&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/IMG_5100.jpg?resize=768%2C576&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/IMG_5100.jpg?resize=1024%2C768&amp;ssl=1 1024w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">Custom PCB Raspberry Pi HAT</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">With that slide switch, you can turn on and off the RGB LED Strip power.</p>



<h4 class="wp-block-heading">Raspberry Pi Enclosure</h4>



<hr class="wp-block-separator has-css-opacity"/>



<p class="wp-block-paragraph">I designed a laser cutting enclosure using Autodesk fusion 360, feel free to download the DXF files from that link.</p>



<div class="aligncenter wp-block-button"><a class="wp-block-button__link has-background wp-element-button" href="https://drive.google.com/open?id=1QmRRjlBHuWzjAIe_6h9ZnT-xhDQ9o_yR" style="border-radius:100px;background-color:#00a99d">enclosure files</a></div>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="578" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Raspberry-Pi-Enclosure.jpg?resize=770%2C578&#038;ssl=1" alt="Raspberry Pi Enclosure" class="wp-image-663" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Raspberry-Pi-Enclosure.jpg?w=1170&amp;ssl=1 1170w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Raspberry-Pi-Enclosure.jpg?resize=600%2C450&amp;ssl=1 600w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Raspberry-Pi-Enclosure.jpg?resize=800%2C600&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Raspberry-Pi-Enclosure.jpg?resize=300%2C225&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Raspberry-Pi-Enclosure.jpg?resize=768%2C576&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Raspberry-Pi-Enclosure.jpg?resize=1024%2C768&amp;ssl=1 1024w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">Raspberry Pi Enclosure</figcaption></figure>
</div>


<h4 class="wp-block-heading">Code</h4>



<hr class="wp-block-separator has-css-opacity"/>



<pre class="EnlighterJSRAW" data-enlighter-language="python" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#We will use the same previous Code without any changes.</pre>



<h4 class="wp-block-heading">Code Explanation</h4>



<hr class="wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph">The same previous explanation since we are using the same code with the same logic.</p>



<p class="has-regular-font-size wp-block-paragraph">After finishing the wiring and your code, close and save it, Run your program by writing <code>python fileName.py</code> in your terminal. Like the last example, After running your program, It&#8217;s expected to see this sentence got printed on the terminal <code>AH Shit! Here we go again! Press CTRL+C to exit</code> then the three LEDs light brightness will start to increase and decrease.</p>



<p class="has-regular-font-size wp-block-paragraph">After getting sure that everything is working as expected, let&#8217;s level it up and build our firebase database.</p>



<h2 class="wp-block-heading">Building The Firebase Database</h2>



<hr class="wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph">The Firebase Realtime Database is a cloud-hosted database. Data is stored as JSON and synchronized in realtime to every connected client. If you want to know more check out <a href="https://firebase.google.com/docs/database">this link</a>. </p>



<p class="has-regular-font-size wp-block-paragraph">As we stated before, the realtime database will receive some data from the mobile app based on the user interaction and will sync it with the raspberry pi in milliseconds. So, to be able to use firebase you need to sign in using your normal Gmail account. then go to your project console to create a new project.</p>



<p class="has-regular-font-size wp-block-paragraph">First things first, you need to create a new project in your console.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="393" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-26-at-6.30.39-PM.png?resize=770%2C393&#038;ssl=1" alt="your console" class="wp-image-523" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-26-at-6.30.39-PM.png?w=2048&amp;ssl=1 2048w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-26-at-6.30.39-PM.png?resize=800%2C409&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-26-at-6.30.39-PM.png?resize=300%2C153&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-26-at-6.30.39-PM.png?resize=768%2C392&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-26-at-6.30.39-PM.png?resize=1024%2C523&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-26-at-6.30.39-PM.png?resize=1026%2C524&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-26-at-6.30.39-PM.png?resize=675%2C345&amp;ssl=1 675w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-26-at-6.30.39-PM.png?w=1540&amp;ssl=1 1540w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">your console</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">Then, give a name to your project</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="388" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/unnamed-file.png?resize=770%2C388&#038;ssl=1" alt="Name Your Project" class="wp-image-524" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/unnamed-file.png?w=2048&amp;ssl=1 2048w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/unnamed-file.png?resize=800%2C404&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/unnamed-file.png?resize=300%2C151&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/unnamed-file.png?resize=768%2C387&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/unnamed-file.png?resize=1024%2C516&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/unnamed-file.png?resize=1026%2C517&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/unnamed-file.png?resize=675%2C340&amp;ssl=1 675w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/unnamed-file.png?w=1540&amp;ssl=1 1540w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">Name Your Project</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">We don&#8217;t need to set up google analytics now</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="427" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/firebase-analytics-setup.png?resize=770%2C427&#038;ssl=1" alt="Creating the project" class="wp-image-525" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/firebase-analytics-setup.png?w=2048&amp;ssl=1 2048w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/firebase-analytics-setup.png?resize=800%2C443&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/firebase-analytics-setup.png?resize=300%2C166&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/firebase-analytics-setup.png?resize=768%2C426&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/firebase-analytics-setup.png?resize=1024%2C567&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/firebase-analytics-setup.png?resize=1026%2C569&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/firebase-analytics-setup.png?resize=675%2C374&amp;ssl=1 675w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/firebase-analytics-setup.png?w=1540&amp;ssl=1 1540w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">Creating the project</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">After creating your project successfully, your project overview page should look something like this. From the left menu, We need to select &#8220;Database&#8221;</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="387" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-14-at-7.05.15-AM.png?resize=770%2C387&#038;ssl=1" alt="Project overview page" class="wp-image-526" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-14-at-7.05.15-AM.png?w=2048&amp;ssl=1 2048w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-14-at-7.05.15-AM.png?resize=800%2C402&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-14-at-7.05.15-AM.png?resize=300%2C151&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-14-at-7.05.15-AM.png?resize=768%2C386&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-14-at-7.05.15-AM.png?resize=1024%2C515&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-14-at-7.05.15-AM.png?resize=1026%2C516&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-14-at-7.05.15-AM.png?resize=675%2C339&amp;ssl=1 675w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-14-at-7.05.15-AM.png?w=1540&amp;ssl=1 1540w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">Project overview page</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">We will choose &#8220;Realtime database&#8221; and click the &#8220;Create Database&#8221; button</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="388" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-14-at-7.05.59-AM.png?resize=770%2C388&#038;ssl=1" alt="Create a Realtime Database" class="wp-image-529" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-14-at-7.05.59-AM.png?w=1170&amp;ssl=1 1170w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-14-at-7.05.59-AM.png?resize=800%2C403&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-14-at-7.05.59-AM.png?resize=300%2C151&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-14-at-7.05.59-AM.png?resize=768%2C387&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-14-at-7.05.59-AM.png?resize=1024%2C516&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-14-at-7.05.59-AM.png?resize=1026%2C517&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-14-at-7.05.59-AM.png?resize=675%2C340&amp;ssl=1 675w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">Create a Realtime Database</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">After that, select &#8220;Test Mode&#8221; and click &#8220;Enable&#8221;</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="490" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-14-at-7.06.20-AM.png?resize=770%2C490&#038;ssl=1" alt="Test Mode" class="wp-image-527" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-14-at-7.06.20-AM.png?w=1170&amp;ssl=1 1170w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-14-at-7.06.20-AM.png?resize=800%2C509&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-14-at-7.06.20-AM.png?resize=300%2C191&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-14-at-7.06.20-AM.png?resize=768%2C489&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-14-at-7.06.20-AM.png?resize=1024%2C652&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-14-at-7.06.20-AM.png?resize=1026%2C653&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-14-at-7.06.20-AM.png?resize=675%2C430&amp;ssl=1 675w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">Test Mode</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">Now, your Realtime database should look something like this.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="387" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-dfShot-2019-09-14-at-7.06.40-AM.png?resize=770%2C387&#038;ssl=1" alt="Your Database dashboard" class="wp-image-667" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-dfShot-2019-09-14-at-7.06.40-AM.png?w=1170&amp;ssl=1 1170w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-dfShot-2019-09-14-at-7.06.40-AM.png?resize=800%2C402&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-dfShot-2019-09-14-at-7.06.40-AM.png?resize=300%2C151&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-dfShot-2019-09-14-at-7.06.40-AM.png?resize=768%2C386&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-dfShot-2019-09-14-at-7.06.40-AM.png?resize=1024%2C515&amp;ssl=1 1024w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption"><em>Your Database dashboard</em></figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">After building the Realtime Database, we need to build the mobile app that will send the data to the firebase database.</p>



<h2 class="wp-block-heading"> Building The Android Mobile APP</h2>



<hr class="wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph">Now we need to build the mobile app that the user will use to control the RGB LED Strip from, we used the amazing tool the &#8220;MIT APP Inventor&#8221; to build it. It&#8217;s fast and very easy to use.</p>



<p class="has-regular-font-size wp-block-paragraph">App inventor lets you develop android mobile applications using a web browser and a physical mobile phone or just the emulator, the MIT app inventor saves your projects in their clouds to keep tracking your work</p>



<p class="has-regular-font-size wp-block-paragraph">First, you need to go to the MIT app inventor <a href="http://appinventor.mit.edu/explore/">official website</a> and login with your Gmail account, then press on the “create apps” button, then start building your mobile app. Easy HA!</p>



<p class="has-regular-font-size wp-block-paragraph">To build your mobile app using the app inventor tool, you should deal with two main parts</p>



<ul class="wp-block-list">
<li class="">The design of the app.</li>



<li class="">The programming of the app.</li>
</ul>



<h4 class="wp-block-heading">The App Design</h4>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="320" height="480" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/SC20190923-190644.png?resize=320%2C480&#038;ssl=1" alt="The app design" class="wp-image-593" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/SC20190923-190644.png?w=320&amp;ssl=1 320w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/SC20190923-190644.png?resize=200%2C300&amp;ssl=1 200w" sizes="auto, (max-width: 320px) 100vw, 320px" /><figcaption class="wp-element-caption">The app design</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">The mobile application consists of <strong>Six buttons</strong> to control the lighting mode(Mode One, Mode Two, &#8230;), <strong>three sliders</strong> to control each LED color lighting intensity, and a <strong>button</strong> named<strong> &#8220;power button&#8221; </strong>to control the state of the LEDs(turning it ON or OFF). The most important part here is to add the &#8220;firebaseDB&#8221; client components to the app to allow us sending data to our firebase database project that we created before.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="283" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.42.44-PM.png?resize=770%2C283&#038;ssl=1" alt="Adding the FirebaseDB component to the app" class="wp-image-598" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.42.44-PM.png?w=1066&amp;ssl=1 1066w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.42.44-PM.png?resize=800%2C294&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.42.44-PM.png?resize=300%2C110&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.42.44-PM.png?resize=768%2C282&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.42.44-PM.png?resize=1024%2C377&amp;ssl=1 1024w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">Adding the FirebaseDB component to the app</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">After adding the &#8220;FirebaseDB&#8221; component to the app, we need to put our created Firebase database URL to the mobile application &#8220;FirebaseDB&#8221; component to specify where does the data will get saved, the Firebase database URL can be found here.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="200" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.45.42-PM-1.png?resize=770%2C200&#038;ssl=1" alt="Firebase database URL" class="wp-image-601" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.45.42-PM-1.png?w=1170&amp;ssl=1 1170w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.45.42-PM-1.png?resize=800%2C208&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.45.42-PM-1.png?resize=300%2C78&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.45.42-PM-1.png?resize=768%2C200&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.45.42-PM-1.png?resize=1024%2C266&amp;ssl=1 1024w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">Firebase database URL</figcaption></figure>
</div>

<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="512" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.49.31-PM.png?resize=770%2C512&#038;ssl=1" alt="Connecting the app with the firebase" class="wp-image-600" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.49.31-PM.png?w=1038&amp;ssl=1 1038w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.49.31-PM.png?resize=800%2C532&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.49.31-PM.png?resize=300%2C199&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.49.31-PM.png?resize=768%2C511&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.49.31-PM.png?resize=1024%2C681&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.49.31-PM.png?resize=270%2C180&amp;ssl=1 270w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.49.31-PM.png?resize=370%2C245&amp;ssl=1 370w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">Connecting the app with the firebase</figcaption></figure>
</div>


<h4 class="wp-block-heading">The Programming Of The App</h4>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="746" height="1066" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-09-26-at-7.13.08-PM.png?resize=746%2C1066&#038;ssl=1" alt="The App Code" class="wp-image-596" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-09-26-at-7.13.08-PM.png?w=746&amp;ssl=1 746w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-09-26-at-7.13.08-PM.png?resize=210%2C300&amp;ssl=1 210w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-09-26-at-7.13.08-PM.png?resize=717%2C1024&amp;ssl=1 717w" sizes="auto, (max-width: 746px) 100vw, 746px" /><figcaption class="wp-element-caption">The App Code</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">After designing the interface of our app we need to give it life, adding some functionality to each button and slider.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="215" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.39.02-PM.png?resize=770%2C215&#038;ssl=1" alt="sending data to the database" class="wp-image-597" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.39.02-PM.png?w=1062&amp;ssl=1 1062w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.39.02-PM.png?resize=800%2C223&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.39.02-PM.png?resize=300%2C84&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.39.02-PM.png?resize=768%2C214&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.39.02-PM.png?resize=1024%2C285&amp;ssl=1 1024w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">sending data to the database</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">Let&#8217;s take the <strong>&#8220;Mode One&#8221;</strong> button as an example to see how the logic works. When the user clicks on the &#8220;Mode One&#8221; button it will send the value <strong>&#8220;mode1&#8221;</strong> with the tag <strong>&#8220;lightMode&#8221;</strong> to the firebase database project that we created before. and if we opened the firebase database dashboard page we will see that new entry got added to our database. <strong>Congrats!</strong></p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="142" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-7.01.37-PM-1.png?resize=770%2C142&#038;ssl=1" alt="" class="wp-image-606" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-7.01.37-PM-1.png?w=1170&amp;ssl=1 1170w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-7.01.37-PM-1.png?resize=800%2C148&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-7.01.37-PM-1.png?resize=300%2C55&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-7.01.37-PM-1.png?resize=768%2C142&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-7.01.37-PM-1.png?resize=1024%2C189&amp;ssl=1 1024w" sizes="auto, (max-width: 770px) 100vw, 770px" /></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">But, when the user clicks the <strong>&#8220;Mode Two&#8221;</strong> button the &#8220;lightMode&#8221; tag value will get updated to the new value which in this case will be <strong>&#8220;mode2&#8221;</strong>.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="199" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-7.04.40-PM.png?resize=770%2C199&#038;ssl=1" alt="Mode Two button" class="wp-image-607" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-7.04.40-PM.png?w=1104&amp;ssl=1 1104w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-7.04.40-PM.png?resize=800%2C207&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-7.04.40-PM.png?resize=300%2C78&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-7.04.40-PM.png?resize=768%2C199&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-7.04.40-PM.png?resize=1024%2C265&amp;ssl=1 1024w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">Mode Two button</figcaption></figure>
</div>

<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="161" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-7.05.45-PM.png?resize=770%2C161&#038;ssl=1" alt="Updated data" class="wp-image-605" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-7.05.45-PM.png?w=1170&amp;ssl=1 1170w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-7.05.45-PM.png?resize=800%2C168&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-7.05.45-PM.png?resize=300%2C63&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-7.05.45-PM.png?resize=768%2C161&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-7.05.45-PM.png?resize=1024%2C214&amp;ssl=1 1024w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">Updated data</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">The same logic applies to the remaining buttons, when the user clicks on a button, a specific piece of data will get sent to the database depending on what button the user clicked.</p>



<h4 class="wp-block-heading">Building the app APK file</h4>



<hr class="wp-block-separator has-css-opacity"/>



<p class="wp-block-paragraph">download the following <strong>.aia</strong> file and import it to your &#8220;MIT app inventor&#8221; account projects dashboard, it will open up the project source, <strong>don&#8217;t forget to update the &#8220;FirebaseURL&#8221; to your firebase project database URL.</strong></p>



<p class="wp-block-paragraph">You can download the .aia source file from that link.</p>



<div class="aligncenter wp-block-button"><a class="wp-block-button__link has-background wp-element-button" href="https://drive.google.com/open?id=1uGUct6ddtGVaS_aYOXB2k6JPw_WVf7_M" style="border-radius:100px;background-color:#00a99d">mobile app .aia file</a></div>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="512" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.49.31-PM.png?resize=770%2C512&#038;ssl=1" alt="updating the firebase URL" class="wp-image-600" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.49.31-PM.png?w=1038&amp;ssl=1 1038w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.49.31-PM.png?resize=800%2C532&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.49.31-PM.png?resize=300%2C199&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.49.31-PM.png?resize=768%2C511&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.49.31-PM.png?resize=1024%2C681&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.49.31-PM.png?resize=270%2C180&amp;ssl=1 270w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.49.31-PM.png?resize=370%2C245&amp;ssl=1 370w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">updating the firebase URL</figcaption></figure>
</div>


<p class="wp-block-paragraph">Then <strong>build the app APK file</strong> and download it to your computer, then send the APK file to your mobile and install it.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="118" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-03-at-4.13.20-AM.png?resize=770%2C118&#038;ssl=1" alt="save the APK file to your computer" class="wp-image-652" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-03-at-4.13.20-AM.png?w=1170&amp;ssl=1 1170w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-03-at-4.13.20-AM.png?resize=800%2C123&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-03-at-4.13.20-AM.png?resize=300%2C46&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-03-at-4.13.20-AM.png?resize=768%2C118&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-03-at-4.13.20-AM.png?resize=1024%2C157&amp;ssl=1 1024w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">save the APK file to your computer</figcaption></figure>
</div>


<h2 class="wp-block-heading">Programming The Raspberry Pi</h2>



<hr class="wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph">After building the mobile app and sending data successfully from it to the database, the raspberry pi will read that data from the <strong>&#8220;firebase database&#8221;</strong> and according to the read data, it will take different actions like changing the lighting mode or increasing the brightness and so on.</p>



<h4 class="wp-block-heading">Installing The Pyrebase Module</h4>



<hr class="is-style-default wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph">Before we start writing any code, we need to install the <strong>&#8220;Pyrebase&#8221;</strong> python module on the raspberry pi board to allow us to communicate with the &#8220;Firebase Database&#8221; servers. Because by default the &#8220;Firebase&#8221; doesn&#8217;t support the &#8220;Python Programming Language&#8221; So, some cool guys wrote a python module to allow the python developers to use &#8220;Firebase&#8221; easily. If you are a Python NERD you can check out the module documentation on their <a href="https://github.com/thisbejim/Pyrebase#database"><strong>Github page</strong></a>.</p>



<p class="has-regular-font-size wp-block-paragraph">We will use &#8220;pip&#8221; to install the &#8220;Pyrebase&#8221; module. So, check to see if you currently have pip installed by running the command in the terminal.</p>



<pre class="wp-block-code"><code>pip --version</code></pre>



<p class="has-regular-font-size wp-block-paragraph">If it is not currently installed, you can install pip by running the following command</p>



<pre class="wp-block-code"><code>curl https://bootstrap.pypa.io/get-pip.py | python</code></pre>



<p class="has-regular-font-size wp-block-paragraph">After getting sure that we have &#8220;pip&#8221; on our raspberry pi board, we will start installing <strong>&#8220;Pyrebase&#8221;</strong> by running this command, and don&#8217;t worry if it takes some time.</p>



<pre class="wp-block-code"><code>sudo pip3 install Pyrebase</code></pre>



<p class="has-regular-font-size wp-block-paragraph">After finishing installing the &#8220;Pyrebase&#8221; module, we are now ready to write the final python script that will read data from the &#8220;Firebase database&#8221; to take some different actions according to that data.</p>



<h4 class="wp-block-heading">Code</h4>



<hr class="wp-block-separator has-css-opacity"/>



<pre class="EnlighterJSRAW" data-enlighter-language="python" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#OK!
#Author: Ahmed Ibrahim
#Date: 2/10/2019
#Website: makesomestuff.org

import RPi.GPIO as GPIO                                                                         #import the RPi.GPIO module to allow us use the board GPIO pins.
import pyrebase                                                                                 #import the pyrebase module which allows us to communicate with the firebase servers.
from time import sleep                                                                          #import the time modulde to allow us do the delay stuff.

config = {                                                              #define a dictionary named config with several key-value pairs that configure the connection to the database.
  "apiKey": "ENTER YOUR API KEY",
  "authDomain": "ENTER YOUR AUTH DOMAIN URL",
  "databaseURL": "ENTER YOUR DATABASE URL",
  "storageBucket": "ENTER YOUR STORAGE BUGET URL"
}

firebase = pyrebase.initialize_app(config)                              #initialize the communication with the "firebase" servers using the previous config data.

redLED = 12                                                                                    #the "redLED" variable refers to the GPIO pin 12 which the red LED is connected on.
blueLED = 19                                                                                   #the "blueLED" variable refers to the GPIO pin 19 which the blue LED is connected on.
greenLED = 18                                                                                  #the "greenLED" variable refers to the GPIO pin 18 which the green LED is connected on.

GPIO.setmode(GPIO.BCM)                                                                         #Set the GPIO Scheme numbering system to the BCM mode.
GPIO.setwarnings(False)                                                                        #disable warnings

GPIO.setup(redLED,GPIO.OUT)                                                                    #set the "redLED" variable pin (12) as an output pin.
GPIO.setup(blueLED,GPIO.OUT)                                                                   #set the "blueLED" variable pin (19) as an output pin.
GPIO.setup(greenLED,GPIO.OUT)                                                                  #set the "greenLED" variable pin (18) as an output pin.

red_pwm = GPIO.PWM(redLED,1000)                                                                #create PWM instance named "red_pwm" with frequency 1000.
blue_pwm = GPIO.PWM(blueLED,1000)                                                              #create PWM instance named "blue_pwm" with frequency 1000.
green_pwm = GPIO.PWM(greenLED,1000)                                                            #create PWM instance named "green_pwm" with frequency 1000.

red_pwm.start(0)                                                                               #start the program with 0% duty cycle (red LED will be OFF).
blue_pwm.start(0)                                                                              #start the program with 0% duty cycle (blue LED will be OFF).
green_pwm.start(0)                                                                             #start the program with 0% duty cycle (green LED will be OFF).

print("AH Shit! Here we go again! Press CTRL+C to exit")                                       #print "AH Shit! Here we go again! Press CTRL+C to exit" at the beginning of the program.

# function name: mode6
# arguments:
#   redIntensity: the brightness intensity of the red LED.
#   greenIntensity: the brightness intensity of the green LED.
#   blueIntensity: the brightness intensity of the blue LED.
# return: this funtion return nothing.
# this function is responsible for the pattern of the lighting mode. Feel free to change the lighting pattern as you want.
def mode6 (redIntensity, greenIntensity, blueIntensity):
    for duty in range (0, redIntensity, 1):
        red_pwm.ChangeDutyCycle(duty)
        sleep(0.01)
    sleep(0.3)
    for duty in range (redIntensity - 1, -1, -1):
        red_pwm.ChangeDutyCycle(duty)
        sleep(0.01)
    sleep(0.3)
    for duty in range (0, blueIntensity, 1):
        blue_pwm.ChangeDutyCycle(duty)
        sleep(0.01)
    sleep(0.3)
    for duty in range (blueIntensity - 1, -1, -1):
        blue_pwm.ChangeDutyCycle(duty)
        sleep(0.01)
    sleep(0.3)
    for duty in range (0, greenIntensity, 1):
        green_pwm.ChangeDutyCycle(duty)              #provide duty cycle in the range 0-100.
        sleep(0.01)
    sleep(0.3)
    for duty in range (greenIntensity - 1, -1 ,-1):
       green_pwm.ChangeDutyCycle(duty)               #provide duty cycle in the range 0-100
       sleep(0.01)
    sleep(0.3)

# function name: mode5
# arguments:
#   redIntensity: the brightness intensity of the red LED.
#   greenIntensity: the brightness intensity of the green LED.
#   blueIntensity: the brightness intensity of the blue LED.
# return: this funtion return nothing.
# this function is responsible for the pattern of the lighting mode. Feel free to change the lighting pattern as you want.
def mode5(redIntensity, greenIntensity, blueIntensity):
    for duty in range (0, redIntensity, 1):
        red_pwm.ChangeDutyCycle(duty)
        sleep(0.001)
    sleep(0.3)
    for duty in range (redIntensity - 1, -1, -1):
        red_pwm.ChangeDutyCycle(duty)
        sleep(0.001)
    sleep(0.3)
    for duty in range (0, blueIntensity, 1):
        blue_pwm.ChangeDutyCycle(duty)
        sleep(0.001)
    sleep(0.3)
    for duty in range (blueIntensity - 1 , -1, -1):
        blue_pwm.ChangeDutyCycle(duty)
        sleep(0.001)
    sleep(0.3)
    for duty in range (0, greenIntensity, 1):
        green_pwm.ChangeDutyCycle(duty)              #provide duty cycle in the range 0-100.
        sleep(0.001)
    sleep(0.3)
    for duty in range (greenIntensity - 1 , -1, -1):
       green_pwm.ChangeDutyCycle(duty)               #provide duty cycle in the range 0-100
       sleep(0.001)
    sleep(0.3)

# function name: mode4
# arguments:
#   redIntensity: the brightness intensity of the red LED.
#   greenIntensity: the brightness intensity of the green LED.
#   blueIntensity: the brightness intensity of the blue LED.
# return: this funtion return nothing.
# this function is responsible for the pattern of the lighting mode. Feel free to change the lighting pattern as you want.
def mode4(redIntensity, greenIntensity, blueIntensity):
    for duty in range (0, redIntensity, 1):
        red_pwm.ChangeDutyCycle(duty)
        sleep(0.01)
    sleep(0.5)
    green_pwm.ChangeDutyCycle(0)
    sleep(0.2)
    green_pwm.ChangeDutyCycle(greenIntensity - 1)

    for duty in range (0, blueIntensity, 1):
        blue_pwm.ChangeDutyCycle(duty)
        sleep(0.01)
    sleep(0.5)
    blue_pwm.ChangeDutyCycle(0)
    sleep(0.2)
    blue_pwm.ChangeDutyCycle(blueIntensity - 1)

    for duty in range (0,greenIntensity,1):
        green_pwm.ChangeDutyCycle(duty)
        sleep(0.01)
    sleep(0.5)
    red_pwm.ChangeDutyCycle(0)
    sleep(0.2)
    red_pwm.ChangeDutyCycle(redIntensity - 1)

    red_pwm.ChangeDutyCycle(0)
    green_pwm.ChangeDutyCycle(0)
    blue_pwm.ChangeDutyCycle(0)

# function name: mode3
# arguments:
#   redIntensity: the brightness intensity of the red LED.
#   greenIntensity: the brightness intensity of the green LED.
#   blueIntensity: the brightness intensity of the blue LED.
# return: this funtion return nothing.
# this function is responsible for the pattern of the lighting mode. Feel free to change the lighting pattern as you want.
def mode3(redIntensity, greenIntensity, blueIntensity):
    red_pwm.ChangeDutyCycle(0)
    green_pwm.ChangeDutyCycle(0)
    blue_pwm.ChangeDutyCycle(0)

    red_pwm.ChangeDutyCycle(redIntensity - 1)
    blue_pwm.ChangeDutyCycle(blueIntensity - 1)
    green_pwm.ChangeDutyCycle(greenIntensity - 1)

# function name: mode2
# arguments:
#   redIntensity: the brightness intensity of the red LED.
#   greenIntensity: the brightness intensity of the green LED.
#   blueIntensity: the brightness intensity of the blue LED.
# return: this funtion return nothing.
# this function is responsible for the pattern of the lighting mode. Feel free to change the lighting pattern as you want.
def mode2(redIntensity, greenIntensity, blueIntensity):
    red_pwm.ChangeDutyCycle(0)
    green_pwm.ChangeDutyCycle(0)
    blue_pwm.ChangeDutyCycle(0)

    blue_pwm.ChangeDutyCycle(blueIntensity - 1)
    sleep(0.1)
    blue_pwm.ChangeDutyCycle(0)
    sleep(0.1)
    green_pwm.ChangeDutyCycle(greenIntensity - 1)
    sleep(0.1)
    green_pwm.ChangeDutyCycle(0)
    sleep(0.1)
    red_pwm.ChangeDutyCycle(redIntensity - 1)
    sleep(0.1)
    red_pwm.ChangeDutyCycle(0)
    sleep(0.1)

# function name: mode1
# arguments:
#   redIntensity: the brightness intensity of the red LED.
#   greenIntensity: the brightness intensity of the green LED.
#   blueIntensity: the brightness intensity of the blue LED.
# return: this funtion return nothing.
# this function is responsible for the pattern of the lighting mode. Feel free to change the lighting pattern as you want.
def mode1(redIntensity, greenIntensity, blueIntensity):
    red_pwm.ChangeDutyCycle(redIntensity - 1)
    sleep(0.02)
    red_pwm.ChangeDutyCycle(0)
    sleep(0.02)
    red_pwm.ChangeDutyCycle(redIntensity - 1)
    sleep(0.02)
    red_pwm.ChangeDutyCycle(0)
    sleep(0.02)

    green_pwm.ChangeDutyCycle(greenIntensity - 1)
    sleep(0.02)
    green_pwm.ChangeDutyCycle(0)
    sleep(0.02)
    green_pwm.ChangeDutyCycle(greenIntensity - 1)
    sleep(0.02)
    green_pwm.ChangeDutyCycle(0)
    sleep(0.02)

    blue_pwm.ChangeDutyCycle(blueIntensity - 1)
    sleep(0.02)
    blue_pwm.ChangeDutyCycle(0)
    sleep(0.02)
    blue_pwm.ChangeDutyCycle(blueIntensity - 1)
    sleep(0.02)
    blue_pwm.ChangeDutyCycle(0)
    sleep(0.02)

try:
    while True:                                                                              #the beginning of the main program.

        database = firebase.database()                                             #take an instance from the firebase database which is pointing to the root directory of your database.
        RGBControlBucket = database.child("RGBControl")                            #get the child "RGBControl" path in your database and store it inside the "RGBControlBucket" variable.
        powerState = RGBControlBucket.child("powerState").get().val()                        #read the power state value from the tag "powerState" which is a node inside the database.
#        print("power state is: " + str(powerState))

                                                                                             # if the "powerState" variable value is equal to "true"
        if "true" in powerState.lower():
            database = firebase.database()                                         #take an instance from the firebase database which is pointing to the root directory of your database.
            RGBControlBucket = database.child("RGBControl")                        #get the child "RGBControl" path in your database and store it inside the "RGBControlBucket" variable.
            redLightIntensity = RGBControlBucket.child("redLightIntensity").get().val()  #read the red LED intensity value from the tag "redLightIntensity" which is a node inside the database then store that value inside the "redLightIntensity" variable.
            
#            print("red Light Intensity is: " + str(redLightIntensity))

            database = firebase.database()                                         #take an instance from the firebase database which is pointing to the root directory of your database.
            RGBControlBucket = database.child("RGBControl")                        #get the child "RGBControl" path in your database and store it inside the "RGBControlBucket" variable.
            blueLightIntensity = RGBControlBucket.child("blueLightIntensity").get().val()  #read the blue LED intensity value from the tag "blueLightIntensity" which is a node inside the database then store that value inside the "blueLightIntensity" variable.
            
#            print("blue Light Intensity is: " + str(blueLightIntensity))

            database = firebase.database()                                         #take an instance from the firebase database which is pointing to the root directory of your database.
            RGBControlBucket = database.child("RGBControl")                        #get the child "RGBControl" path in your database and store it inside the "RGBControlBucket" variable.
            greenLightIntensity = RGBControlBucket.child("greenLightIntensity").get().val()  #read the green LED intensity value from the tag "greenLightIntensity" which is a node inside the database then store that value inside the "greenLightIntensity" variable.
            
#            print("green Light Intensity is: " + str(greenLightIntensity))

            database = firebase.database()                                         #take an instance from the firebase database which is pointing to the root directory of your database.
            RGBControlBucket = database.child("RGBControl")                        #get the child "RGBControl" path in your database and store it inside the "RGBControlBucket" variable.
            lightPresetMode = RGBControlBucket.child("lightMode").get().val()  #read the light preset mode value from the tag "lightMode" which is a node inside the database then store that value inside the "lightPresetMode" variable.
            
#            print("light preset mode is: " + str(lightPresetMode))
            #           if the variable "lightPresetMode" value is equal to "mode6", call the mode6 function.
            if "mode6" in lightPresetMode.lower():
                mode6(int(redLightIntensity), int(greenLightIntensity), int(blueLightIntensity))
            #           if the variable "lightPresetMode" value is equal to "mode5", call the mode5 function.
            elif "mode5" in lightPresetMode.lower():
                mode5(int(redLightIntensity), int(greenLightIntensity), int(blueLightIntensity))
            #           if the variable "lightPresetMode" value is equal to "mode4", call the mode4 function.
            elif "mode4" in lightPresetMode.lower():
                mode4(int(redLightIntensity), int(greenLightIntensity), int(blueLightIntensity))
            #           if the variable "lightPresetMode" value is equal to "mode3", call the mode3 function.
            elif "mode3" in lightPresetMode.lower():
                mode3(int(redLightIntensity), int(greenLightIntensity), int(blueLightIntensity))
            #           if the variable "lightPresetMode" value is equal to "mode2", call the mode2 function.
            elif "mode2" in lightPresetMode.lower():
                mode2(int(redLightIntensity), int(greenLightIntensity), int(blueLightIntensity))
            #           if the variable "lightPresetMode" value is equal to "mode1", call the mode1 function.
            elif "mode1" in lightPresetMode.lower():
                mode1(int(redLightIntensity), int(greenLightIntensity), int(blueLightIntensity))
    #                   if the variable "lightPresetMode" value is not equal to any of the above values, print "DAMN, the power state is: false" on the terminal for debugging purposes.
        else:
            print("DAMN, the power state is: " + powerState)


except KeyboardInterrupt: # If CTRL+C is pressed, exit cleanly:
    red_pwm.stop() # stop red PWM
    blue_pwm.stop() # stop blue PWM
    green_pwm.stop() # stop green PWM
    GPIO.cleanup() # cleanup all GPIO</pre>



<h4 class="wp-block-heading">Code Explanation</h4>



<hr class="wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph">the most important part here is to connect your python script to the &#8220;Firebase database&#8221; servers to be able to read the data from it. We define a dictionary named <code>config</code> with several key-value pairs that configure the connection to the database. The apiKey, authDomain, databaseUrl, and storageBucket values needed to connect to your database can be found in the Firebase console.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="python" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">config = {                                                              #define a dictionary named config with several key-value pairs that configure the connection to the database.
  "apiKey": "ENTER YOUR PROJECT API KEY",
  "authDomain": "ENTER YOUR AUTH DOMAIN URL",       # "projectId.firebaseapp.com"
  "databaseURL": "ENTER YOUR DATABASE URL",         # "https://databaseName.firebaseio.com"
  "storageBucket": "ENTER YOUR STORAGE BUGET URL"   # "projectId.appspot.com"
}</pre>



<p class="has-regular-font-size wp-block-paragraph">To find the <strong>&#8220;API Key&#8221;</strong>, <strong>&#8220;authDomain&#8221;</strong>, <strong>&#8220;databaseURL&#8221;</strong>, <strong>&#8220;storageBucket&#8221;</strong> values, go to your database dashboard click on the gear icon, then &#8220;Project settings&#8221;.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="129" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-9.39.15-PM.png?resize=770%2C129&#038;ssl=1" alt="Getting the API key" class="wp-image-616" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-9.39.15-PM.png?w=1170&amp;ssl=1 1170w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-9.39.15-PM.png?resize=800%2C134&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-9.39.15-PM.png?resize=300%2C50&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-9.39.15-PM.png?resize=768%2C129&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-9.39.15-PM.png?resize=1024%2C172&amp;ssl=1 1024w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">Getting the API key</figcaption></figure>
</div>


<figure class="wp-block-image"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="465" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-9.41.29-PM.png?resize=770%2C465&#038;ssl=1" alt="getting the project ID" class="wp-image-619" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-9.41.29-PM.png?resize=1024%2C618&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-9.41.29-PM.png?resize=800%2C483&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-9.41.29-PM.png?resize=300%2C181&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-9.41.29-PM.png?resize=768%2C463&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-9.41.29-PM.png?w=1170&amp;ssl=1 1170w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">getting the project ID</figcaption></figure>



<p class="has-regular-font-size wp-block-paragraph">Then you will find your project <strong>API key</strong>. Copy and paste it inside your python script. To find the <strong>&#8220;authDomain&#8221;</strong> you need to get the <strong>project ID</strong>, after getting your <strong>Project ID</strong> your <strong>&#8220;authDomain&#8221;</strong> will be like this <strong>&#8220;projectId.firebaseapp.com&#8221;</strong>.<br>your <strong>&#8220;storageBucket&#8221;</strong> will be like this <strong>&#8220;projectId.appspot.com&#8221;</strong>.</p>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4043148098486780" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-4043148098486780" data-ad-slot="5056799298"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="wp-block-paragraph">and to get your <strong>&#8220;databaseURL&#8221;</strong> go to your project <strong>database dashboard</strong> and copy that URL. That&#8217;s It!</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="200" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.45.42-PM-1.png?resize=770%2C200&#038;ssl=1" alt="Database URL" class="wp-image-601" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.45.42-PM-1.png?w=1170&amp;ssl=1 1170w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.45.42-PM-1.png?resize=800%2C208&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.45.42-PM-1.png?resize=300%2C78&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.45.42-PM-1.png?resize=768%2C200&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/Screen-Shot-2019-10-02-at-6.45.42-PM-1.png?resize=1024%2C266&amp;ssl=1 1024w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">Database URL</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">If you want more code explanation, please read the code comments it&#8217;s well documented.</p>



<h4 class="wp-block-heading">How does It Work?</h4>



<hr class="wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph">After finishing the wiring and your code, close and save it, Run your program by writing <code>python3 fileName.py</code> in your terminal. <br>Like the last example, After running your program, It&#8217;s expected to see this sentence got printed on the terminal <code>AH Shit! Here we go again! Press CTRL+C to exit</code> then you will be able to control the LED Strip from your mobile app, Voila!</p>



<p class="wp-block-paragraph"><strong>Note: You must run your program using python3, because the &#8220;pyrebase&#8221; module only works with python3 any other python version will not work.</strong></p>



<h4 class="wp-block-heading">Troubleshooting</h4>



<hr class="wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph">If you see that error message when you run your program</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="512" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/erScreen-Shot-2019-09-14-at-8.24.03-AM.png?resize=770%2C512&#038;ssl=1" alt="program running error" class="wp-image-632" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/erScreen-Shot-2019-09-14-at-8.24.03-AM.png?w=1170&amp;ssl=1 1170w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/erScreen-Shot-2019-09-14-at-8.24.03-AM.png?resize=800%2C532&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/erScreen-Shot-2019-09-14-at-8.24.03-AM.png?resize=300%2C199&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/erScreen-Shot-2019-09-14-at-8.24.03-AM.png?resize=768%2C511&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/erScreen-Shot-2019-09-14-at-8.24.03-AM.png?resize=1024%2C681&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/erScreen-Shot-2019-09-14-at-8.24.03-AM.png?resize=270%2C180&amp;ssl=1 270w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/erScreen-Shot-2019-09-14-at-8.24.03-AM.png?resize=370%2C245&amp;ssl=1 370w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">program running error</figcaption></figure>
</div>


<p class="wp-block-paragraph">don&#8217;t worry open your terminal and execute that commands </p>



<pre class="wp-block-code"><code>pip install --upgrade pyasn1-modules
</code></pre>



<p class="wp-block-paragraph"> this command will install your missing modules.</p>



<h2 class="wp-block-heading">Running The Program Automatically On Startup</h2>



<hr class="wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph">We don&#8217;t need to run the program manually by ourselves every time we boot up our raspberry pi board, it will be a good idea if we get our program to run automatically whenever the raspberry pi boots.</p>



<p class="has-regular-font-size wp-block-paragraph">After the desktop environment starts (LXDE-pi, in this case), it runs whatever commands it finds in the profile&#8217;s&nbsp;<em>autostart</em>&nbsp;script, which is located at&nbsp;<em>/home/pi/.config/lxsession/LXDE-pi/autostart</em>&nbsp;for our Raspberry Pi.</p>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4043148098486780" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-4043148098486780" data-ad-slot="5056799298"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="wp-block-paragraph">First, we need to create a .desktop File, Open a terminal, and execute the following commands to create an&nbsp;<em>autostart</em>&nbsp;directory (if one does not already exist) and edit a .desktop file for our project code</p>



<pre class="wp-block-code"><code>mkdir /home/pi/.config/autostart
nano /home/pi/.config/autostart/IoTUsingRaspberryPi.desktop
</code></pre>



<p class="has-regular-font-size wp-block-paragraph">Copy in the following text into the&nbsp;&#8220;IoTUsingRaspberryPi.desktop&#8221;&nbsp;file. Feel free to change the&nbsp;<em>Name</em>&nbsp;and&nbsp;<em>Exec</em>&nbsp;variables to your particular application.</p>



<pre class="wp-block-code"><code>&#91;Desktop Entry]
Type=Application
Name=IoTUsingRaspberryPiAndFirebase
Exec=/usr/bin/python3 /your program absolute path/programName.py
</code></pre>



<p class="has-regular-font-size wp-block-paragraph">That&#8217;s it! Now, at every time you boot up your raspberry pi, the program will start running automatically.</p>



<h4 class="wp-block-heading">Troubleshooting </h4>



<hr class="wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph"><strong>&nbsp;your script does not run as soon as you see the desktop?!  </strong></p>



<p class="wp-block-paragraph">there could be several issues. First, make sure that you have logged in (autostart does not start until you have logged in). You could also try enabling auto-login in&nbsp;<code>raspi-config</code>. Second, make sure you are using the absolute directory path (e.g.&nbsp;<code>/home/pi/IoTUsingRaspberryPi.py</code>). Third, make sure that you are using the python version 3 not anything else.</p>



<h2 class="wp-block-heading">My Setup</h2>



<hr class="wp-block-separator has-css-opacity"/>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="578" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/IMG_5105.jpg?resize=770%2C578&#038;ssl=1" alt="Project Setup" class="wp-image-679" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/IMG_5105.jpg?w=1170&amp;ssl=1 1170w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/IMG_5105.jpg?resize=600%2C450&amp;ssl=1 600w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/IMG_5105.jpg?resize=800%2C600&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/IMG_5105.jpg?resize=300%2C225&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/IMG_5105.jpg?resize=768%2C576&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/10/IMG_5105.jpg?resize=1024%2C768&amp;ssl=1 1024w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">Project Setup</figcaption></figure>
</div>


<h2 class="wp-block-heading">Final</h2>



<hr class="wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph">We are done! in today’s tutorial, we learned how to build a simple mobile app using MIT App inventor. Also, we learned how to control RGD LED strips using the raspberry pi board, and how to communicate with the firebase database servers through a python script. Lastly, how to control an RGB LED strip wirelessly from anywhere in the world.</p>



<p class="has-regular-font-size wp-block-paragraph"><strong>Lastly, if you have any questions drop it in the comments section below, I will be more than happy to hear from you</strong></p>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4043148098486780" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-4043148098486780" data-ad-slot="5056799298"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<p>The post <a href="https://makesomestuff.org/iot-using-raspberry-pi-and-firebase-and-android/">IoT Using Raspberry Pi and Firebase and Android</a> appeared first on <a href="https://makesomestuff.org">Make Some Stuff</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://makesomestuff.org/iot-using-raspberry-pi-and-firebase-and-android/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">448</post-id>	</item>
		<item>
		<title>IoT Using ESP8266-01 and Arduino</title>
		<link>https://makesomestuff.org/iot-using-esp8266-01-and-arduino/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=iot-using-esp8266-01-and-arduino</link>
					<comments>https://makesomestuff.org/iot-using-esp8266-01-and-arduino/#comments</comments>
		
		<dc:creator><![CDATA[Ahmed Ibrahim]]></dc:creator>
		<pubDate>Fri, 06 Sep 2019 05:24:03 +0000</pubDate>
				<category><![CDATA[Arduino Projects]]></category>
		<category><![CDATA[ESP-01]]></category>
		<category><![CDATA[IoT]]></category>
		<guid isPermaLink="false">https://makesomestuff.org/?p=207</guid>

					<description><![CDATA[<p><a href="https://makesomestuff.org">Make Some Stuff</a><br />
<a href="https://makesomestuff.org/iot-using-esp8266-01-and-arduino/">IoT Using ESP8266-01 and Arduino</a></p>
<p>Ever asked how to control your home appliances from any place in the world? In this step by step tutorial, we will learn how to control things wirelessly through the internet using our Awesome Arduino board. Hardware Used Software Introduction Today, we will build a device that connects to the internet and allow the user [...]</p>
<p>The post <a href="https://makesomestuff.org/iot-using-esp8266-01-and-arduino/">IoT Using ESP8266-01 and Arduino</a> appeared first on <a href="https://makesomestuff.org">Make Some Stuff</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><a href="https://makesomestuff.org">Make Some Stuff</a><br />
<a href="https://makesomestuff.org/iot-using-esp8266-01-and-arduino/">IoT Using ESP8266-01 and Arduino</a></p>

<p class="has-text-align-left has-regular-font-size wp-block-paragraph">Ever asked how to control your home appliances from any place in the world? In this step by step tutorial, we will learn how to control things wirelessly through the internet using our Awesome Arduino board.</p>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube aligncenter wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="IoT Using Arduino And ESP8266-01 Module" width="770" height="433" src="https://www.youtube.com/embed/eKL7U6VFYIw?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div><figcaption class="wp-element-caption">Cool, Ha!</figcaption></figure>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4043148098486780" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-4043148098486780" data-ad-slot="9966560791"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<h2 class="wp-block-heading">Hardware</h2>



<hr class="wp-block-separator has-css-opacity is-style-wide"/>



<ol class="wp-block-list">
<li><a href="https://www.ebay.com/itm/Nano-V3-0-Mini-USB-ATmega328-5V-16MHz-Micro-Controller-CH340G-Driver-For-Arduino/273743114225?hash=item3fbc5c6ff1:g:Hw4AAOSw5LZcfJzv">Arduino Nano</a></li>



<li><a href="https://www.ebay.com/itm/ESP8266-01-Serial-WIFI-Wireless-Transceiver-Module-Send-Receive-LWIP-AP-STA/112016580768?epid=2278627962&amp;hash=item1a14b560a0:g:hXUAAOSwkvFae8Mq">ESP8266-01</a></li>



<li><a href="https://www.ebay.com/itm/5V-Two-2-Channel-Relay-Module-With-optocoupler-For-PIC-AVR-DSP-ARM-Arduino/181026509345?hash=item2a26055221:g:e1IAAOSw2QxcfybT">Two-channel Relay</a></li>



<li>any AC load.</li>



<li><a href="https://www.ebay.com/itm/New-200Pcs-3mm-5mm-LED-Light-White-Yellow-Red-Blue-Green-Assortment-Diodes-Kit/222785956373?epid=2133731918&amp;hash=item33df13ea15:g:KDsAAOSwEVZaUaux">Two LEDs.</a></li>



<li><a href="https://www.ebay.com/itm/MB-102-MB102-Solderless-Breadboard-830-Points-PCB-BreadBoard/322666932715?hash=item4b2072a9eb:g:6H8AAOSwoA9ZhEk0">Breadboard.</a></li>



<li><a href="https://www.ebay.com/itm/100Pcs-1-4W-0-25W-Carbon-Film-Resistor-5-1K-910K-Ohm-1-K-910-K/192128181191?hash=item2cbbbb63c7:m:mb9RImDVMDlqhR8yC4ITlsA">Bunch of resistors</a> (1K, 2.2K).</li>



<li><a href="https://www.ebay.com/itm/65Pcs-Solderless-Flexible-Breadboard-Male-to-Male-Jumper-Cable-Wires-For-Arduino/122354484494?hash=item1c7ce5450e:g:x9cAAOSwBnZbFjO1">Bunch of jumpers</a> (Male-female, male-male).</li>
</ol>



<h2 class="wp-block-heading">Used Software</h2>



<hr class="wp-block-separator has-css-opacity is-style-wide"/>



<ol class="wp-block-list">
<li><a href="https://www.arduino.cc/en/main/software">Arduino IDE</a>.</li>



<li><a href="https://code.visualstudio.com/download">Visual Studio Code</a> (optional).</li>



<li><a href="https://www.autodesk.com/products/eagle/free-download">Autodesk Eagle</a> (Optional).</li>



<li>Any web Browser.</li>
</ol>



<h2 class="wp-block-heading">Introduction</h2>



<hr class="wp-block-separator has-css-opacity is-style-wide"/>



<p class="has-regular-font-size wp-block-paragraph">Today, we will build a device that connects to the internet and allow the user to control his/her home remotely over wifi. we will use the Arduino board(any model will do the job well) with the ESP8266-01 wifi module to make this device. Let&#8217;s get started!</p>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4043148098486780" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-4043148098486780" data-ad-slot="9966560791"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<h4 class="wp-block-heading">What&#8217;s a smart home?</h4>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">Smart home technology uses devices such as linking sensors, features and other appliances connected to the internet of things (IoT) that can be remotely monitored, controlled or accessed and provide services that respond to the needs of the users.</p>
<cite>Wikipedia</cite></blockquote>



<h2 class="wp-block-heading">Working Scenario</h2>



<hr class="wp-block-separator has-css-opacity is-style-wide"/>



<h4 class="wp-block-heading">The Control Panel</h4>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="418" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/finla-web-app.jpg?resize=770%2C418&#038;ssl=1" alt="the final web page" class="wp-image-214" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/finla-web-app.jpg?w=1366&amp;ssl=1 1366w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/finla-web-app.jpg?resize=800%2C434&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/finla-web-app.jpg?resize=300%2C163&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/finla-web-app.jpg?resize=768%2C417&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/finla-web-app.jpg?resize=1024%2C555&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/finla-web-app.jpg?resize=1026%2C557&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/finla-web-app.jpg?resize=675%2C366&amp;ssl=1 675w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">the final web page</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">We will build a simple web page that will work as a control panel for the user allows him to control any home appliance connected to our system. To build the web page we will use:</p>



<ul class="wp-block-list">
<li>HTML</li>



<li>CSS</li>



<li>Jquery</li>
</ul>



<h4 class="wp-block-heading">The Embedded Hardware</h4>



<p class="has-regular-font-size wp-block-paragraph">the web page sends some orders to the ESP8266-01 which is working as a web server connected to the Arduino board. And according to the incoming data, the Arduino board will take some actions like turning on the bulb, turning off the TV and in this part, we will use:</p>



<ul class="wp-block-list">
<li>Arduino</li>



<li>ESP8266-01</li>
</ul>



<h2 class="wp-block-heading">Getting Started with the ESP8266-01</h2>



<hr class="wp-block-separator has-css-opacity is-style-wide"/>



<p class="has-regular-font-size wp-block-paragraph">As we stated before, we need our Arduino board to get connected to the Internet but the Arduino Nano the version which we are using today doesn&#8217;t have that feature. So, we will use the ESP8266-01 wifi module to add the wifi feature to our tiny Arduino board.</p>



<p class="has-regular-font-size wp-block-paragraph">there are a lot of ESP wifi modules models out there, which one should I choose?! Well, almost all the ESP family wifi modules out there will do the job well but each one has its own features and specifications. I encourage you to look at each one specifications and features to choose the most suitable one for your needs.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="433" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/ESP8266_Versions.png?resize=770%2C433&#038;ssl=1" alt="the ESP Family" class="wp-image-219" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/ESP8266_Versions.png?w=1024&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/ESP8266_Versions.png?resize=800%2C450&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/ESP8266_Versions.png?resize=300%2C169&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/ESP8266_Versions.png?resize=768%2C432&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/ESP8266_Versions.png?resize=675%2C380&amp;ssl=1 675w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">the ESP Family</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">According to my needs, I found the ESP8266-01 is the most suitable one and that&#8217;s for many reasons. It&#8217;s very famous in the makers community. As a result, it got a very solid online community that you can find an answer to almost any question or problem you face with this awesome small module. Also, its price is very cheap(around 1.5$). Also, it&#8217;s very easy to use with the Arduino board since its a Serial wifi module it can communicate with the Arduino board over the serial communication. It has a built-in Microcontroller which means that you can use it as a standalone microcontroller and wifi module in one combo which is super cool. It has built-in two GPIOs. Only with 1.5$, you will get all of these features which is super cool, actually.<br> let&#8217;s get a closer look at this module.</p>



<h2 class="wp-block-heading">ESP8266-01 Pinout</h2>



<hr class="wp-block-separator has-css-opacity is-style-wide"/>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="499" height="368" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/ESP8266-PINOUT.png?resize=499%2C368&#038;ssl=1" alt="ESP8266-01 module" class="wp-image-228" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/ESP8266-PINOUT.png?w=499&amp;ssl=1 499w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/ESP8266-PINOUT.png?resize=300%2C221&amp;ssl=1 300w" sizes="auto, (max-width: 499px) 100vw, 499px" /><figcaption class="wp-element-caption">ESP8266-01 module</figcaption></figure>
</div>


<ul class="wp-block-list">
<li><strong>VCC</strong>: connect to +3.3V power source. <em>don&#8217;t connect it with a 5V source it will get damaged</em>.</li>



<li><strong>GND:</strong> -ve pin, connect it to the ground of your circuit.</li>



<li><strong>CH_PD: </strong>chip enables pin &#8211; Active HIGH. connect it to a logic value HIGH to allow the module to boot up.</li>



<li><strong>RST:</strong> Chip Reset pin &#8211; Active LOW, when it pulled LOW it Resets the module.</li>



<li><strong>GPIO0, GPIO2: </strong>General purpose input/output pins.</li>



<li><strong>Tx: </strong>connect to the Rx of the microcontroller(Arduino) to establish serial communication.</li>



<li><strong>Rx: </strong>connect to the Tx of the microcontroller(Arduino) to establish serial communication.</li>
</ul>



<h2 class="wp-block-heading">ESP8266-01 Configuration</h2>



<hr class="wp-block-separator has-css-opacity is-style-wide"/>



<p class="has-regular-font-size wp-block-paragraph">As we stated before the ESP8266-01 module communicates with the Arduino board over the Serial communication, which means that we need to connect it with the Arduino&#8217;s Serial pins 0, 1(Tx, Rx). But the problem here is that these pins will be busy because we will use the Arduino Serial monitor alongside the ESP8266-01 for debugging purposes. So, we need to find another two Serial communication pins to use them with the ESP8266-01. <br><br>Fortunately, Arduino made this easy. There&#8217;s a library called &#8220;SoftwareSerial&#8221; which was developed to allow serial communication on other digital pins of the Arduino, using software to replicate the functionality. For example, by using this library I can set the pins 2, 3(SoftwareSerial) as Rx and Tx alongside the pins 0, 1(Hardware Serial).</p>



<p class="has-regular-font-size wp-block-paragraph">&#8220;SoftwareSerial&#8221; library works great as long as the transmission speed is less than 19,200 baud. But, there&#8217;s a small problem here! the ESP8266-01 wifi module comes from the factory programmed to communicate at speed 115,200 baud which is somehow hard at the &#8220;SoftwareSerial&#8221; library to communicate at. So, we need to reprogram our wifi module to set the communication speed to 9600 baud which works pretty good with the &#8220;SoftwareSerial&#8221; library. To do that we will use some &#8220;AT Commands&#8221;.</p>



<h2 class="wp-block-heading">Changing the ESP8266-01 communication speed</h2>



<hr class="wp-block-separator has-css-opacity"/>



<h4 class="wp-block-heading">First step: Upload an empty program to the Arduino board</h4>



<figure class="wp-block-image"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="417" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/bareMinimun.jpg?resize=770%2C417&#038;ssl=1" alt="Upload an Empty program" class="wp-image-244" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/bareMinimun.jpg?w=1366&amp;ssl=1 1366w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/bareMinimun.jpg?resize=800%2C433&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/bareMinimun.jpg?resize=300%2C162&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/bareMinimun.jpg?resize=768%2C415&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/bareMinimun.jpg?resize=1024%2C554&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/bareMinimun.jpg?resize=1026%2C555&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/bareMinimun.jpg?resize=675%2C365&amp;ssl=1 675w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">Upload an Empty program</figcaption></figure>



<p class="has-regular-font-size wp-block-paragraph">At this step, we are uploading an empty code to the Arduino board. Just to be sure that there&#8217;s nothing is Executing in the background by the Arduino board.</p>



<h4 class="wp-block-heading">Second Step: Wiring the ESP8266-01 with the Arduino board</h4>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="786" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/ReprogramModuleNano.png?resize=770%2C786&#038;ssl=1" alt="Reconfigurations Wiring" class="wp-image-249" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/ReprogramModuleNano.png?w=1029&amp;ssl=1 1029w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/ReprogramModuleNano.png?resize=800%2C816&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/ReprogramModuleNano.png?resize=294%2C300&amp;ssl=1 294w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/ReprogramModuleNano.png?resize=768%2C784&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/ReprogramModuleNano.png?resize=1004%2C1024&amp;ssl=1 1004w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/ReprogramModuleNano.png?resize=1026%2C1047&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/ReprogramModuleNano.png?resize=675%2C689&amp;ssl=1 675w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">Reconfigurations Wiring</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">To Reconfigure the ESP8266-01 and change the communication speed(baud rate) we use the AT-commands. Simply, AT commands are some instructions used to control modems, mobile phones, Bluetooth modules, wifi modules, GSM Modules, &#8230; with these commands we can get basic information about our mobile phone or GSM Modules like the name of the manufacturer, model number, IMEI and so on.</p>



<p class="has-regular-font-size wp-block-paragraph">&#8220;AT&#8221; is an abbreviation for &#8220;ATtention&#8221; and it&#8217;s called AT-commands because every command starts with &#8220;AT&#8221;. the &#8220;AT&#8221; prefix is not a part of the commands itself it just tells the module the start of the commands.</p>



<h2 class="wp-block-heading">Some Important AT Commands</h2>



<hr class="wp-block-separator has-css-opacity"/>



<figure class="wp-block-table aligncenter is-style-regular"><table><tbody><tr><td>N<strong>o.</strong></td><td><strong>Command</strong></td><td><strong>Example</strong></td><td><strong>Parameters</strong></td><td><strong>Description</strong></td><td><strong>returns</strong></td></tr><tr><td>1</td><td>AT</td><td>AT</td><td>Nothing</td><td>Check if the module <br>is working properly.</td><td>OK</td></tr><tr><td>2</td><td>AT+RST</td><td>AT+RST</td><td>Nothing</td><td>Resets the Module.</td><td>OK</td></tr><tr><td>3</td><td>AT+CWMODE=&lt;MODE&gt;</td><td>AT+CWMODE=1</td><td>1 = Station<br>2 = AP<br>3 = Both</td><td>sets the Wifi mode</td><td>OK</td></tr><tr><td>4</td><td>AT+CIOBAUD=&lt;baud&gt;<br><strong>OR</strong><br>AT+UART_DEF=&lt;baud&gt;,8,1,0,0</td><td>AT+CIOBAUD=9600<br><strong>OR</strong><br>AT+UART_DEF=9600,8,1,0,0</td><td>baud rate</td><td>changes the module<br>communication <br>speed.</td><td>OK</td></tr><tr><td>5</td><td>AT+CWJAP=<br>&lt;SSID&gt;,&lt;PASS&gt;</td><td>AT+CWJAP=&#8221;meme&#8221;, &#8220;69696969696&#8221;</td><td>SSID = Wifi Network name<br>PASS = Wifi <br>Password</td><td>Connects<br>to a Wifi Network</td><td>WIFI CONNECTED<br>WIFI GOT IP</td></tr><tr><td>6</td><td>AT+CIFSR</td><td>AT+CIFSR</td><td>Nothing</td><td>Tells you the <br>module IP address<br>and the MAC Address</td><td>IP Address<br>Mac Address</td></tr><tr><td>7</td><td>AT+CIPSERVER=&lt;MODE&gt;,&lt;PORT&gt;</td><td>AT+CIPSERVER=1,80</td><td>MODE = 0 to close the server, <br>1 to open the server.<br>PORT = port number</td><td>Sets the module as a server.</td><td>OK</td></tr></tbody></table></figure>



<p class="has-regular-font-size wp-block-paragraph">Command number &#8220;4&#8221; depends on your ESP8266-01 firmware version, if this command doesn&#8217;t work with you <code>AT+CIOBAUD=&lt;baud&gt;</code> Try this one <code>AT+UART_DEF=&lt;baud&gt;,8,1,0,0</code> </p>



<h4 class="wp-block-heading">Step 1: Open the Serial Monitor</h4>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="740" height="185" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/SM.png?resize=740%2C185&#038;ssl=1" alt="Arduino IDE Serial monitor" class="wp-image-132" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/SM.png?w=740&amp;ssl=1 740w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/SM.png?resize=300%2C75&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/SM.png?resize=675%2C169&amp;ssl=1 675w" sizes="auto, (max-width: 740px) 100vw, 740px" /><figcaption class="wp-element-caption">Arduino IDE Serial monitor</figcaption></figure>
</div>


<h4 class="wp-block-heading">Step 2: Set the Communication speed to 115,200 baud</h4>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="682" height="41" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/115200.jpg?resize=682%2C41&#038;ssl=1" alt="Communication Speed" class="wp-image-274" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/115200.jpg?w=682&amp;ssl=1 682w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/115200.jpg?resize=300%2C18&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/115200.jpg?resize=675%2C41&amp;ssl=1 675w" sizes="auto, (max-width: 682px) 100vw, 682px" /><figcaption class="wp-element-caption">Communication Speed</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">As we stated before, the ESP comes from the manufacturer programmed to communicate at speed 115,200 baud. So we need to set the Arduino communication speed to <strong>115,200</strong> too for the first time only then we will change that later.<br><br>Also, you should select <strong>&#8220;Both NL &amp; CR&#8221;</strong>.</p>



<h4 class="wp-block-heading">Step 3: Send &#8220;AT&#8221; and wait for the response to be sure that the ESP module is hearing you.</h4>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="680" height="225" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/AT-OK.jpg?resize=680%2C225&#038;ssl=1" alt="send just AT" class="wp-image-275" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/AT-OK.jpg?w=680&amp;ssl=1 680w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/AT-OK.jpg?resize=300%2C99&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/AT-OK.jpg?resize=675%2C223&amp;ssl=1 675w" sizes="auto, (max-width: 680px) 100vw, 680px" /><figcaption class="wp-element-caption">send just AT</figcaption></figure>
</div>


<h4 class="wp-block-heading">Step 4: Now, change the ESP8266-01 communication speed</h4>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="99" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/Screen-Shot-2019-08-27-at-10.28.11-PM.png?resize=770%2C99&#038;ssl=1" alt="AT Response" class="wp-image-280" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/Screen-Shot-2019-08-27-at-10.28.11-PM.png?w=2048&amp;ssl=1 2048w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/Screen-Shot-2019-08-27-at-10.28.11-PM.png?resize=800%2C102&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/Screen-Shot-2019-08-27-at-10.28.11-PM.png?resize=300%2C38&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/Screen-Shot-2019-08-27-at-10.28.11-PM.png?resize=768%2C98&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/Screen-Shot-2019-08-27-at-10.28.11-PM.png?resize=1024%2C131&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/Screen-Shot-2019-08-27-at-10.28.11-PM.png?resize=1026%2C131&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/Screen-Shot-2019-08-27-at-10.28.11-PM.png?resize=675%2C86&amp;ssl=1 675w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/Screen-Shot-2019-08-27-at-10.28.11-PM.png?w=1540&amp;ssl=1 1540w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">AT Response</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">My ESP8266-01 module loaded firmware is 1.6. and this command <code>AT+UART_DEF=&lt;baud&gt;,8,1,0,0</code>  works well for me. If it doesn&#8217;t work with you, try this <code>AT+CIOBAUD=&lt;baud&gt;</code> .<br><br>If it responds with &#8220;OK&#8221; now your ESP module communication baud rate changed from 115,200 baud to 9600 baud. CONGRATS! </p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="155" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/Screen-Shot-2019-08-27-at-10.28.18-PM.png?resize=770%2C155&#038;ssl=1" alt="Responds with &quot;OK&quot;" class="wp-image-284" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/Screen-Shot-2019-08-27-at-10.28.18-PM.png?w=2048&amp;ssl=1 2048w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/Screen-Shot-2019-08-27-at-10.28.18-PM.png?resize=800%2C161&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/Screen-Shot-2019-08-27-at-10.28.18-PM.png?resize=300%2C60&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/Screen-Shot-2019-08-27-at-10.28.18-PM.png?resize=768%2C154&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/Screen-Shot-2019-08-27-at-10.28.18-PM.png?resize=1024%2C206&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/Screen-Shot-2019-08-27-at-10.28.18-PM.png?resize=1026%2C206&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/Screen-Shot-2019-08-27-at-10.28.18-PM.png?resize=675%2C136&amp;ssl=1 675w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/Screen-Shot-2019-08-27-at-10.28.18-PM.png?w=1540&amp;ssl=1 1540w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">Responds with &#8220;OK&#8221;</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">Let&#8217;s change the Serial monitor communication speed back to 9600 and send &#8220;AT&#8221; again to see if the ESP module can hear us at the new Speed(9600) or not.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="300" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/Screen-Shot-2019-08-27-at-10.40.43-PM.png?resize=770%2C300&#038;ssl=1" alt="Change comm. speed" class="wp-image-286" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/Screen-Shot-2019-08-27-at-10.40.43-PM.png?w=2048&amp;ssl=1 2048w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/Screen-Shot-2019-08-27-at-10.40.43-PM.png?resize=800%2C311&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/Screen-Shot-2019-08-27-at-10.40.43-PM.png?resize=300%2C117&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/Screen-Shot-2019-08-27-at-10.40.43-PM.png?resize=768%2C299&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/Screen-Shot-2019-08-27-at-10.40.43-PM.png?resize=1024%2C398&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/Screen-Shot-2019-08-27-at-10.40.43-PM.png?resize=1026%2C399&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/Screen-Shot-2019-08-27-at-10.40.43-PM.png?resize=675%2C263&amp;ssl=1 675w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/Screen-Shot-2019-08-27-at-10.40.43-PM.png?w=1540&amp;ssl=1 1540w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">Change comm. speed</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">LOOK! it&#8217;s working. the ESP8266-01 now can communicate with the Arduino board at 9600 baud rate instead of 115,200 baud rate. <br><br><strong>Now, let&#8217;s try to connect with the Wifi network</strong></p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="673" height="75" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/AT-commands.jpg?resize=673%2C75&#038;ssl=1" alt="Connecting to the Wifi Network" class="wp-image-288" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/AT-commands.jpg?w=673&amp;ssl=1 673w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/AT-commands.jpg?resize=300%2C33&amp;ssl=1 300w" sizes="auto, (max-width: 673px) 100vw, 673px" /><figcaption class="wp-element-caption">Connecting to the Wifi Network</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">Once you press enter, the ESP8266-01 will search for this network and connect with it. If the process succeeds it will return this <br><code>WIFI CONNECTED</code><br><code>WIFI GOT IP</code><br><br>At this point, we successfully changed the ESP8266-01 communication speed from 115,200 baud to 9600 baud. Now, we need to build the control panel(Web Page) which the user will use to control his home appliances. So, let&#8217;s build it!</p>



<h2 class="wp-block-heading">What&#8217;s the Internet?</h2>



<hr class="wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph">Actually, the internet is a wire buried under the ground it can be fiber optics, copper, or even a satellite but the internet is simply a wire.<br>Any two computers connected to that wire can communicate. If the computer is connected directly to that wire it&#8217;s called a server and if it is not connected directly to that wire it&#8217;s called a <strong>client</strong>.</p>



<p class="has-regular-font-size wp-block-paragraph"><br><strong>Server:</strong> is a special computer that runs a specific Operating system like Apache, this special computer saves some web pages, files, databases on its disk drive. any server connected to the internet has a unique IP Address like  <strong>172.217.171.228</strong>, the IP address is just like a phone number that helps people to find each other easily. Since that IP Address is not very easy for humans to remember. So, we just gave it a name like: <strong>google.com</strong>(Domain name).</p>



<p class="has-regular-font-size wp-block-paragraph"><strong>Client:</strong> it&#8217;s a computer like what you and I are using every day, it&#8217;s connected indirectly to the internet through an internet service provider(ISP) and it also has a unique IP address. </p>



<h2 class="wp-block-heading">Working Scenario</h2>



<hr class="wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph">Simply, it starts with a request sent from a web browser(Client) like google chrome, firefox and ends with the response received from the webserver.<br><br>You entered the website URL makesomestuff.org in a browser from a computer(client), then this browser sends a request to the webserver that hosts the website, the webserver then returns a response containing HTML page or any other document format to the browser to display it.</p>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4043148098486780" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-4043148098486780" data-ad-slot="9966560791"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="has-regular-font-size wp-block-paragraph">Exactly, that&#8217;s what we need to do today in our project. We need to send a request from the web browser(Client) to the ESP8266-01(Webserver) which both of them are connected to the same local network. This request contains some data which tells the Arduino what to do turn on or off a light bulb. So, let&#8217;s build the web page!</p>



<h2 class="wp-block-heading">Building The Web Page</h2>



<hr class="wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph">To build our web page we have to deal with HTML, CSS, Javascript. if you never heard about these names before, don&#8217;t worry I got you.<br><br><strong>HTML:</strong> Stands for &#8220;HyperText markup language&#8221;  we use it to build any web page main structure. Like adding some buttons, images, paragraphs, headers, tables, and many more elements.  it consists of a series of elements that tell the browser how to display the web page content. these elements represent by something called tags.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="125" height="300" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-6.04.48-PM.png?resize=125%2C300&#038;ssl=1" alt="HTML" class="wp-image-391" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-6.04.48-PM.png?resize=125%2C300&amp;ssl=1 125w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-6.04.48-PM.png?w=270&amp;ssl=1 270w" sizes="auto, (max-width: 125px) 100vw, 125px" /><figcaption class="wp-element-caption">HTML</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph"><strong>CSS:</strong> It stands for cascading style sheet. After building the web page main structure, you need to make this structure looks nice here comes CSS to make some styling. it&#8217;s a language that describes the style of an HTML element. it consists of some selectors and deceleration blocks.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="105" height="300" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-6.04.53-PM.png?resize=105%2C300&#038;ssl=1" alt="CSS" class="wp-image-393" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-6.04.53-PM.png?resize=105%2C300&amp;ssl=1 105w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-6.04.53-PM.png?w=224&amp;ssl=1 224w" sizes="auto, (max-width: 105px) 100vw, 105px" /><figcaption class="wp-element-caption">CSS</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph"><strong>Javascript:</strong> it&#8217;s a programming language that we will use to make the web page more interactive like adding some animations, maps and it allows us to make some complex things on the web page. Mainly, we will use it today to send an HTTP request from the client(web browser) to the webserver(ESP8266-01) to take some actions like turning on or off a light bulb.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="109" height="300" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-6.04.58-PM.png?resize=109%2C300&#038;ssl=1" alt="JS" class="wp-image-394" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-6.04.58-PM.png?resize=109%2C300&amp;ssl=1 109w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-6.04.58-PM.png?w=234&amp;ssl=1 234w" sizes="auto, (max-width: 109px) 100vw, 109px" /><figcaption class="wp-element-caption">JS</figcaption></figure>
</div>


<h2 class="wp-block-heading">Build The Web Page Structure</h2>



<hr class="wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph"><strong><em>To easily understand the upcoming explanation, I recommend Reading this cool </em></strong><a href="https://www.w3schools.com/html/html_intro.asp"><strong><em>HTML intro</em></strong></a><strong><em>.</em></strong></p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="417" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/no-css.jpg?resize=770%2C417&#038;ssl=1" alt="HTML Web Page" class="wp-image-300" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/no-css.jpg?w=1366&amp;ssl=1 1366w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/no-css.jpg?resize=800%2C433&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/no-css.jpg?resize=300%2C162&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/no-css.jpg?resize=768%2C415&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/no-css.jpg?resize=1024%2C554&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/no-css.jpg?resize=1026%2C555&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/08/no-css.jpg?resize=675%2C365&amp;ssl=1 675w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">HTML Web Page</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">As we see our control panel is very simple, it contains two headers each one has a different size, one image, and two buttons one for turning on an LED and the second one for turning it off.</p>



<h4 class="wp-block-heading">Code</h4>



<pre class="EnlighterJSRAW" data-enlighter-language="html" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;!DOCTYPE html>
&lt;html>

&lt;head>
    &lt;title>Smart Home System&lt;/title>
&lt;/head>

&lt;body>

    &lt;h1> Smart Home Control Panel&lt;/h1>                               
    &lt;h4>Sorry But I'm a Meme Addict!&lt;/h4>
    &lt;img src="dogMeme.jpg" width="400px" height="400px">
    &lt;br>
    &lt;button id="111" class="button">LAMP ON&lt;/button>
    &lt;br>
    &lt;button id="110" class="button">LAMP OFF&lt;/button>
&lt;/body>

&lt;/html></pre>



<h4 class="wp-block-heading">Code Explanation</h4>



<ul class="wp-block-list">
<li><strong>&lt;!DOCTYPE html>:</strong> declaration defines that this document is an HMTL5 document.</li>



<li><strong>&lt;html>:</strong> the root element of an HTML page.</li>



<li><strong>&lt;head>:</strong> contains meta-information about the page.</li>



<li><strong>&lt;title>:</strong> specifies the title of the document. this title appears on the web page browser tab.</li>



<li><strong>&lt;body>:</strong> contains the visible web page content.</li>



<li><strong>&lt;h1>: </strong> defines a large element.</li>



<li><strong>&lt;h4>:</strong> defines a smaller header. when the header value decreases the font decreases.</li>



<li><strong>&lt;img>:</strong> adds an image to the web page. the image that you want to display should be in the same project folder.</li>



<li><strong>&lt;br>:</strong> advance the cursor to a new line.</li>



<li><strong>&lt;button>:</strong> adds a button to the page content.</li>
</ul>



<p class="has-regular-font-size wp-block-paragraph">Each button is our web page has very important two attributes the <code>id</code>, and the <code>class</code> attributes. we will talk about why we assigned these two values to the buttons in the Jquery code explanation.</p>



<h2 class="wp-block-heading">Styling The Web Page</h2>



<hr class="wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph"><strong><em>To easily understand the upcoming explanation, I recommend Reading this cool <a href="https://www.w3schools.com/css/css_intro.asp">CSS intro</a>.</em></strong></p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="401" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/web-app.jpg?resize=770%2C401&#038;ssl=1" alt="" class="wp-image-307" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/web-app.jpg?w=1366&amp;ssl=1 1366w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/web-app.jpg?resize=800%2C416&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/web-app.jpg?resize=300%2C156&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/web-app.jpg?resize=768%2C400&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/web-app.jpg?resize=1024%2C533&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/web-app.jpg?resize=1026%2C534&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/web-app.jpg?resize=675%2C351&amp;ssl=1 675w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">CSS Added</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">Now, the web page looks nicer (NOT TOO MUCH xD) we gave it a cool green background color, we make the page content centered aligned, and we change the headers font color and font family which made the web page more alive. We used CSS to do all of this styling stuff.</p>



<h4 class="wp-block-heading">Code</h4>



<pre class="EnlighterJSRAW" data-enlighter-language="html" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;!DOCTYPE html>
&lt;html>

&lt;head>
    &lt;title>Smart Home System&lt;/title>
&lt;/head>

&lt;body style="background-color: seagreen; color: seashell; text-align: center;">

    &lt;h1> Smart Home Control Panel&lt;/h1>                               
    &lt;h4>Sorry But I'm a Meme Addict!&lt;/h4>
    &lt;img src="dogMeme.jpg" width="400px" height="400px">
    &lt;br>
    &lt;button style="margin: 10px;" id="111" class="button">LAMP ON&lt;/button>
    &lt;br>
    &lt;button style="margin:10px;" id="110" class="button"> LAMP OFF&lt;/button>
&lt;/body>

&lt;/html></pre>



<h4 class="wp-block-heading">Code Explanation</h4>



<p class="has-regular-font-size wp-block-paragraph">We added some few lines of code to make our web page looks nicer. We added <code>style="background-color: seagreen; color: seashell; text-align: center;"</code> inside the <em><strong>body</strong></em><strong> tag </strong>to make all the web page content<strong> in the center of the page</strong> and to <strong>set the background color to seagreen</strong> also to <strong>set the font color to seashell</strong>.<br><br>Also, we added <code>style="margin: 10px;"</code> inside the two <strong>button tags</strong> to set a margin of 10 pixels around the four sides of each button.</p>



<h2 class="wp-block-heading">Sending a Request To The Webserver</h2>



<hr class="wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph"><strong><em>To easily understand the upcoming explanation, I recommend Reading this cool <a href="https://www.w3schools.com/jquery/default.asp">Jquery intro</a>.</em></strong></p>



<p class="has-regular-font-size wp-block-paragraph">Now, after building our web page structure and styling it we need to add some functionality to the two buttons which we added earlier in the web page. we need when the user clicks the &#8220;LAMP ON&#8221; button his/her browser sends a request contains some unique data to the server(ESP8266-01) this unique data tells the Arduino to turn on the lamp. The same thing with the second button &#8220;LAMP OFF&#8221; when the user clicks it, the browser will send a request contains some unique data to the server(ESP8266-01) this unique data tells the Arduino to turn off the lamp. Let&#8217;s take a look at the code.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="html" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;!DOCTYPE html>
&lt;html>

&lt;head>
    &lt;title>Smart Home System&lt;/title>
    &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">&lt;/script>
&lt;/head>

&lt;body style="background-color: seagreen; color: seashell; text-align: center;">

    &lt;h1> Smart Home Control Panel&lt;/h1>                               
    &lt;h4>Sorry But I'm a Meme Addict!&lt;/h4>
    &lt;img src="dogMeme.jpg" width="400px" height="400px">
    &lt;br>
    &lt;button style="margin: 10px;" id="111" class="button">LAMP ON&lt;/button>
    &lt;br>
    &lt;button style="margin:10px;" id="110" class="button"> LAMP OFF&lt;/button>
        &lt;script>                                                        //starting Javascript.
        $(".button").click(function () {                            //if any button from the ".button" class is clicked
            var p = $(this).attr('id');                             //get this button id and store it inside the "p" variable.
            pin: p                                                  //a dictionary contains the button id to get sent to the web server.
            $.get("http://192.168.1.4:80/", {                      //then send a get request to the web server"http://192.168.1.4:80/" (":80" means port number 80) with some data in a form of dictionary {pin: p} which is the butoon id. IMPORTANT NOTE: DON'T FORGET TO CHANGE THE IP ADDRESS WITH YOUR ESP8266 NEW IP ADDRESS.
            pin: p
            });
        });
    &lt;/script>
&lt;/body>

&lt;/html></pre>



<h4 class="wp-block-heading">Code Explanation</h4>



<p class="has-regular-font-size wp-block-paragraph">First Things First, we need to import the Jquery library in our code. So, we added this line in the <strong><em>head tag</em></strong>.<br><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;</code><br><br>All the magic happens in this interesting part.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="js" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">    &lt;script>                                                        //starting Javascript.
        $(".button").click(function () {                            //if any button from the ".button" class is clicked
            var p = $(this).attr('id');                             //get this button id and store it inside the "p" variable.
            pin: p                                                  //a dictionary contains the button id to get sent to the web server.
            $.get("http://192.168.1.4:80/", {                      //then send a get request to the web server"http://192.168.1.4:80/" (":80" means port number 80) with some data in a form of dictionary {pin: p} which is the butoon id. IMPORTANT NOTE: DON'T FORGET TO CHANGE THE IP ADDRESS WITH YOUR ESP8266 NEW IP ADDRESS.
            pin: p
            });
        });
    &lt;/script></pre>



<p class="has-regular-font-size wp-block-paragraph"><code>$(".button").click(function () {</code><br>When the user clicks on any button associated with the class <strong>&#8220;button&#8221;</strong>, trigger the following function.<br><br><code>var p = $(this).attr('id');</code><br>Get the value of the clicked button attribute <strong>&#8220;id&#8221;</strong>  and store it inside the <strong>&#8220;p&#8221;</strong> variable.<br><br><code>pin: p</code><br>Put the variable &#8220;p&#8221; value in a dictionary (key-value) it&#8217;s key is &#8220;pin&#8221; and the value is &#8220;p&#8221; variable value.<br><br><code>$.get("http://172.20.10.11:80/", { pin: p });});</code><br>Then, send a GET request to the webserver which it&#8217;s IP address is &#8220;172.20.10.11&#8221;. this <strong>GET</strong> request contains the value of the attribute <strong>id</strong> pressed button.</p>



<p class="has-regular-font-size wp-block-paragraph">In case the user pressed the &#8220;LAMP ON&#8221; button this id value will be 111, so the GET request header will contain some data like this <strong>pin=111</strong>. look at the next figure!</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="168" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/http-header.png?resize=770%2C168&#038;ssl=1" alt="HTTP request header" class="wp-image-319" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/http-header.png?w=1608&amp;ssl=1 1608w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/http-header.png?resize=800%2C174&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/http-header.png?resize=300%2C65&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/http-header.png?resize=768%2C167&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/http-header.png?resize=1024%2C223&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/http-header.png?resize=1026%2C223&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/http-header.png?resize=675%2C147&amp;ssl=1 675w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/http-header.png?w=1540&amp;ssl=1 1540w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">HTTP request header</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">At the opposite side, if the user pressed &#8220;LAMP OFF&#8221; button the request will contain this data <strong>pin=110</strong>.</p>



<h4 class="wp-block-heading">Code Logic</h4>



<p class="has-regular-font-size wp-block-paragraph">I know you asking now why the heck did he choose <strong>111</strong> and <strong>110</strong> specifically? Ok, Lemme answer you fam. Actually, the number <strong>111</strong> and <strong>110</strong> divides into two parts. </p>



<ul class="wp-block-list">
<li><strong> Part one:</strong> is the first two numbers which are in both cases will be &#8220;11&#8221;, it refers to the Arduino pin number which the load I need to control is connected on.</li>



<li><strong> Part two:</strong> is the third number which changes between 1 and 0 depending on the clicked button. And it refers to the pin state(ON or OFF).</li>
</ul>



<p class="has-regular-font-size wp-block-paragraph">In the Arduino code, we will receive this data and separate these two parts from each other and save each part in a different variable, part one in variable <code>pinNumber</code> and the second part in variable <code>pinState</code>, then we will write this simple line of code to control the connected load<br><code>digitalWrite(pinNumber, pinState);</code></p>



<h2 class="wp-block-heading">Connecting The Load</h2>



<hr class="wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph">Now,  we need to connect the load with the Arduino board to control it. Before connecting any high voltage device like the air conditioner or even the TV, we need to test our circuit and the code with some low voltage stuff like LEDs only to make sure that everything is working well. Here&#8217;s the wiring diagram</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="722" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/oneLED.png?resize=770%2C722&#038;ssl=1" alt="Connecting the load" class="wp-image-397" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/oneLED.png?w=1191&amp;ssl=1 1191w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/oneLED.png?resize=800%2C750&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/oneLED.png?resize=300%2C281&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/oneLED.png?resize=768%2C720&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/oneLED.png?resize=1024%2C960&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/oneLED.png?resize=1026%2C961&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/oneLED.png?resize=675%2C632&amp;ssl=1 675w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">Connecting the load</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">The wiring is pretty simple, we are connecting the LED positive leg to the Arduino digital pin 11, and the negative leg to the GND through a 1k ohm resistor.</p>



<h4 class="wp-block-heading">Arduino Code</h4>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;SoftwareSerial.h>                         //including the SoftwareSerial library will allow you to use the pin no. 2,3 as Rx, Tx.
SoftwareSerial esp8266(2,3);                        //set the Rx ==> Pin 2; TX ==> Pin3.

#define serialCommunicationSpeed 9600               // &lt;========= define a constant named "serialCommunicationSpeed" with a value 9600. it referes to the Software and hardware serial communication speed(baud rate).
#define DEBUG true                                  //make a constant named "DEBUG" and it's value true. we will use it later.

int redLED =12;                                     //assign a variable named "redLED" with an integer value 12, it refers to the pin which the red LED is connected on.
int blueLED =11;                                    //assign a variable named "blueLED" with an integer value 11, it refers to the pin which the blue LED is connected on.


void setup()

{
  pinMode(redLED,OUTPUT);                           //set the pin number 12 as an output pin.
  pinMode(blueLED,OUTPUT);                          //set the pin number 11 as an output pin.
  
  digitalWrite(redLED,LOW);                         //turn the red LED off at the beginning of the program.
  digitalWrite(blueLED,HIGH);                       //turn the blue LED on at the beginning of the program.

  Serial.begin(serialCommunicationSpeed);           //begin the Hardware serial communication (0, 1) at speed 9600.
  esp8266.begin(serialCommunicationSpeed);          //begin the software serial communication (2, 3) at speed 9600.

  InitWifiModule();                                 //call this user-defined function "InitWifiModule()" to initialize a communication between the ESP8266 and your access point (Home Router or even your mobile hotspot).

  digitalWrite(blueLED,LOW);                        //after finishing the initialization successfully, turn off the blue LED (just an indicator).
}

void loop()                                                         //our main program, some fun are about to start)
{

  if(esp8266.available())                                           //if there's any data received and stored in the serial receive buffer, go and excute the if-condition body. If not, dont excute the if-condition body at all.
  {
    if(esp8266.find("+IPD,"))                                       //search for the "+IPD," string in the incoming data. if it exists the ".find()" returns true and if not it returns false.
    {
      delay(1000);                                                  //wait 1 second to fill up the buffer with the data.
      int connectionId = esp8266.read()-48;                         //Subtract 48 because the read() function returns the ASCII decimal value. And 0 (the first decimal number) starts at 48. We use it to convert from ASCI decimal value to a character value.
      esp8266.find("pin=");                                         //Advance the cursor to the "pin=" part in the request header to read the incoming bytes after the "pin=" part which is the pinNumer and it's state.
      int pinNumber = (esp8266.read()-48)*10;                       //read the first Byte from the Arduino input buffer(i.e. if the pin 12 then the 1st number is 1) then multiply this number by 10. So, the final value of the "pinNumber" variable will be 10.
      pinNumber = pinNumber + (esp8266.read()-48);                  //read the second Byte from the Arduino input buffer(i.e. if the pin number is 12 then the 2nd number is 2) then add this number to the first number. So, the final value of the "pinNumber" variable will be 12.
      int statusLed =(esp8266.read()-48);                           //read the third byte from the Arduino input buffer. then save it inside the "statusLed" variable. At any case, it will be 1 or 0.

      digitalWrite(pinNumber, statusLed);                           //then turn the LED at "pinNumber" on or off depending on the "statusLed" variable value.

      Serial.println(connectionId);                                 //print the "connectionId" value on the serial monitor for debugging purposes.
      Serial.print(pinNumber);                                      //print the "pinNumber" value on the serial monitor for debugging purposes.
      Serial.print("      ");                                       //print some spaces on the serial monitor to make it more readable.
      Serial.println(statusLed);                                    //print the "statusLed" value on the serial monitor for debugging purposes.

      String closeCommand = "AT+CIPCLOSE=";                         //close the TCP/IP connection.
      closeCommand+=connectionId;                                   //append the "connectionId" value to the string.
      closeCommand+="\r\n";                                         //append the "\r\n" to the string. it simulates the keyboard enter press.
      sendData(closeCommand,1000,DEBUG);                            //then send this command to the ESP8266 module to excute it.
      
    }
  }
}

/******************************************************************************************************************************************************************************************
* Name: sendData
* Description: this Function regulates how the AT Commands will ge sent to the ESP8266.
* 
* Params: command - the AT Command to send 
*                 - timeout - the time to wait for a response 
*                 - debug - print to Serial window?(true = yes, false = no)
*                 
* Returns: The response from the esp8266 (if there is a reponse)
*/
String sendData(String command, const int timeout, boolean debug)
{
    String response = "";                                             //initialize a String variable named "response". we will use it later.
    
    esp8266.print(command);                                           //send the AT command to the esp8266 (from ARDUINO to ESP8266).
    long int time = millis();                                         //get the operating time at this specific moment and save it inside the "time" variable.
    while( (time+timeout) > millis())                                 //excute only whitin 1 second.
    {      
      while(esp8266.available())                                      //is there any response came from the ESP8266 and saved in the Arduino input buffer?
      {
        char c = esp8266.read();                                      //if yes, read the next character from the input buffer and save it in the "response" String variable.
        response+=c;                                                  //append the next character to the response variabl. at the end we will get a string(array of characters) contains the response.
      }  
    }    
    if(debug)                                                         //if the "debug" variable value is TRUE, print the response on the Serial monitor.
    {
      Serial.print(response);
    }    
    return response;                                                  //return the String response.
}



/******************************************************************************************************************************************************************************************
* Name: InitWifiModule
* Description: this Function gives the commands that we need to send to the sendData() function to send it.
* 
* Params: Nothing.
*                 
* Returns: Nothing (void).
*/
void InitWifiModule()
{
  sendData("AT+RST\r\n", 2000, DEBUG);                                                  //reset the ESP8266 module.
  //delay(1000);
  sendData("AT+CWJAP=\"PUT YOUR SSID\",\"PUT YOUR PASSWORD\"\r\n", 2000, DEBUG);        //connect to the WiFi network.
  delay (3000);
  sendData("AT+CWMODE=1\r\n", 1500, DEBUG);                                             //set the ESP8266 WiFi mode to station mode.
  delay (1000);
  sendData("AT+CIFSR\r\n", 1500, DEBUG);                                                //Show IP Address, and the MAC Address.
  delay (1000);
  sendData("AT+CIPMUX=1\r\n", 1500, DEBUG);                                             //Multiple conections.
  delay (1000);
  sendData("AT+CIPSERVER=1,80\r\n", 1500, DEBUG);                                       //start the communication at port 80, port 80 used to communicate with the web servers through the http requests.
}</pre>



<h4 class="wp-block-heading">code explanation</h4>



<p class="has-regular-font-size wp-block-paragraph">the code is pretty straightforward, we implemented two different functions <code>InitWifiModule()</code> and <code>sendData()</code> <br><br>the <code>sendData()</code> function job is regulating how the AT commands will get sent to the ESP8266-01 module.<br>the <code>InitWifiModule()</code> function job is to provide the <code>sendData()</code> function the AT commands that we need to send to the ESP8266-01.<br><br>in the <code>loop()</code> function we read the income HTTP request header and search for the <strong>&#8220;+IPD,&#8221;</strong> which means that the request has successfully arrived, then we read the pin value which it will be &#8220;111&#8221; if the user clicked the &#8220;LAMP ON&#8221; button and &#8220;110&#8221; if the user clicked &#8220;LAMP OFF&#8221; button. </p>



<p class="has-regular-font-size wp-block-paragraph">don&#8217;t forget to put your wifi <strong>SSID</strong> and <strong>Password</strong> in the Arduino code <strong>line no. 103</strong><br><code>sendData("AT+CWJAP=\"PUT YOUR SSID\",\"PUT YOUR PASSWORD\"\r\n", 2000, DEBUG);        //connect to the WiFi network.</code><br><br><strong><em>for more code explanayion please read the comments in the code, it&#8217;s well documented</em></strong></p>



<h2 class="wp-block-heading">How It Works</h2>



<hr class="wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph">After uploading the code to the Arduino board, open the Serial monitor and read the responses that the ESP module is sending.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="303" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-12.43.20-AM.png?resize=770%2C303&#038;ssl=1" alt="Arduino serial monitor" class="wp-image-354" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-12.43.20-AM.png?w=2048&amp;ssl=1 2048w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-12.43.20-AM.png?resize=800%2C314&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-12.43.20-AM.png?resize=300%2C118&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-12.43.20-AM.png?resize=768%2C302&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-12.43.20-AM.png?resize=1024%2C402&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-12.43.20-AM.png?resize=1026%2C403&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-12.43.20-AM.png?resize=675%2C265&amp;ssl=1 675w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-12.43.20-AM.png?w=1540&amp;ssl=1 1540w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">Arduino serial monitor</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">at the beginning of the program, if you see something like the previous figure with <strong>&#8220;OK&#8221;</strong> at the end of the page, it means that the ESP8266-01 module is successfully connected to your wifi (Access point) and got an IP  and MAC address . Now, you can open your fancy web page and try to control some stuff <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>


<div class="wp-block-image">
<figure class="aligncenter"><img loading="lazy" decoding="async" width="2048" height="934" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-12.47.14-AM.png?fit=1024%2C467&amp;ssl=1" alt="Arduino serial monitor" class="wp-image-355" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-12.47.14-AM.png?w=2048&amp;ssl=1 2048w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-12.47.14-AM.png?resize=800%2C365&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-12.47.14-AM.png?resize=300%2C137&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-12.47.14-AM.png?resize=768%2C350&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-12.47.14-AM.png?resize=1024%2C467&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-12.47.14-AM.png?resize=1026%2C468&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-12.47.14-AM.png?resize=675%2C308&amp;ssl=1 675w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-12.47.14-AM.png?w=1540&amp;ssl=1 1540w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption"><em>Arduino serial monitor</em></figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">But, if you see something like the previous figure with a <strong>&#8220;FAIL&#8221;</strong> or <strong>&#8220;ERROR&#8221;</strong> at the end of the page, it means that your ESP module cant connect to your wifi (Access point) for some reasons, try to check if entered the right SSID and password for your network.</p>



<h2 class="wp-block-heading">Adding a High Voltage Load</h2>



<hr class="wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph">After we tested our code and got sure that everything is working like a charm, we need to replace this boring LED with a High volage load like an air conditioner, TV or a light bulb. But to control all of these high voltage appliances we have to deal with relays.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="425" height="425" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/relay-module.jpg?resize=425%2C425&#038;ssl=1" alt="Two-channel relay module" class="wp-image-358" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/relay-module.jpg?w=425&amp;ssl=1 425w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/relay-module.jpg?resize=100%2C100&amp;ssl=1 100w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/relay-module.jpg?resize=150%2C150&amp;ssl=1 150w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/relay-module.jpg?resize=300%2C300&amp;ssl=1 300w" sizes="auto, (max-width: 425px) 100vw, 425px" /><figcaption class="wp-element-caption">Two-channel relay module</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">What&#8217;s and why relay? Ok, the relay is a mechanical switch, which is toggled on or off by energizing a coil. it’s mainly used to control a high powered circuit using a low power signal (5V or 0V). So we can control a high powered device like an air conditioner or an AC lamp turning it on or off only by a 5V or 0V signal. Which is amazing!</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="390" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/2-channel-relay.jpg?resize=770%2C390&#038;ssl=1" alt="Relay module pinout" class="wp-image-359" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/2-channel-relay.jpg?w=1449&amp;ssl=1 1449w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/2-channel-relay.jpg?resize=800%2C405&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/2-channel-relay.jpg?resize=300%2C152&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/2-channel-relay.jpg?resize=768%2C389&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/2-channel-relay.jpg?resize=1024%2C518&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/2-channel-relay.jpg?resize=1026%2C519&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/2-channel-relay.jpg?resize=675%2C341&amp;ssl=1 675w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">Relay module pinout</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">The Two-channel relay module has two control pins(IN1, IN2) these pins should get connected to two Arduino digital pins to control the state of the two coils, closes or opens the load circuit.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="536" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-1.19.32-AM.png?resize=770%2C536&#038;ssl=1" alt="AC Load relay wiring " class="wp-image-362" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-1.19.32-AM.png?w=994&amp;ssl=1 994w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-1.19.32-AM.png?resize=800%2C557&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-1.19.32-AM.png?resize=300%2C209&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-1.19.32-AM.png?resize=768%2C535&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-1.19.32-AM.png?resize=675%2C470&amp;ssl=1 675w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">AC Load relay wiring </figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">At the opposite side of the relay module, the COM(common) should get connected to one end of the load. the other end of the load is either connected to the <strong>NC(Normally Close)</strong> or <strong>NO(Normally open)</strong>, if connected to the NO the load remains Disconnected before trigger and vice versa.</p>



<h4 class="wp-block-heading">Wiring Diagram</h4>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="584" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/RelayModuleAdded.png?resize=770%2C584&#038;ssl=1" alt="Adding two-channel relay module" class="wp-image-398" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/RelayModuleAdded.png?w=1722&amp;ssl=1 1722w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/RelayModuleAdded.png?resize=800%2C606&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/RelayModuleAdded.png?resize=300%2C227&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/RelayModuleAdded.png?resize=768%2C582&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/RelayModuleAdded.png?resize=1024%2C776&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/RelayModuleAdded.png?resize=1026%2C778&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/RelayModuleAdded.png?resize=675%2C512&amp;ssl=1 675w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/RelayModuleAdded.png?w=1540&amp;ssl=1 1540w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">Adding two-channel relay module</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph">As you see, we are using a two-channel relay module that gives us the ability to control two different AC loads. We are connecting the <strong>first relay</strong> at <strong>digital output pin</strong> <strong>11(Arduino)</strong> and the <strong>second relay</strong> to <strong>digital output pin 12(Arduino)</strong><br><br>We will make a small modification to our web page, we will add another <strong>two buttons(ON and OFF)</strong> to control the second connected load.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="html" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;!DOCTYPE html>
&lt;html>

&lt;head>
    &lt;title>Smart Home System&lt;/title>
    &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">&lt;/script>
&lt;/head>

&lt;body style="background-color: seagreen; color: seashell; text-align: center;">

    &lt;h1> Smart Home Control Panel&lt;/h1>                               
    &lt;h4>Sorry But I'm a Meme Addict!&lt;/h4>
    &lt;img src="dogMeme.jpg" width="400px" height="400px">
    &lt;br>
    &lt;button style="margin: 10px;" id="111" class="button">Blue LED ON&lt;/button>
    &lt;button id="110" class="button">Blue LED OFF&lt;/button>
    &lt;br>
    &lt;button style="margin:10px;" id="121" class="button"> Red LED ON&lt;/button>
    &lt;button id="120" class="button">Red LED OFF&lt;/button>
    &lt;script>                                                        //starting Javascript.
        $(".button").click(function () {                            //if any button from the ".button" class is clicked
            var p = $(this).attr('id');                             //get this button id and store it inside the "p" variable.
            pin: p                                                  //a dictionary contains the button id to get sent to the web server.
            $.get("http://192.168.1.4:80/", {                       //then send a get request to the web server"http://192.168.1.4:80/" (":80" means port number 80) with some data in a form of dictionary {pin: p} which is the butoon id. IMPORTANT NOTE: DON'T FORGET TO CHANGE THE IP ADDRESS WITH YOUR ESP8266 NEW IP ADDRESS.
            pin: p
            });
        });
    &lt;/script>
&lt;/body>

&lt;/html></pre>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="357" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-1.35.11-AM.png?resize=770%2C357&#038;ssl=1" alt="the final web page" class="wp-image-366" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-1.35.11-AM.png?w=2048&amp;ssl=1 2048w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-1.35.11-AM.png?resize=800%2C371&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-1.35.11-AM.png?resize=300%2C139&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-1.35.11-AM.png?resize=768%2C356&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-1.35.11-AM.png?resize=1024%2C475&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-1.35.11-AM.png?resize=1026%2C476&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-1.35.11-AM.png?resize=675%2C313&amp;ssl=1 675w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-04-at-1.35.11-AM.png?w=1540&amp;ssl=1 1540w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">the final web page</figcaption></figure>
</div>


<h2 class="wp-block-heading">How It Works</h2>



<hr class="wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph">Just like the last trial, You upload the Arduino code to the board (if not uploaded yet) and open the serial monitor and make sure that your ESP module is connected successfully to your access point and got an IP and MAC address.<br><br>Then open your fancy web page and start controlling your stuff <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<h2 class="wp-block-heading">Make it more professional!</h2>



<p class="has-regular-font-size wp-block-paragraph">What about transferring our breadboard circuit to a professional printed circuit board<strong> (PCB)</strong> to make our project more rigid and solid, I designed the project circuit using Autodesk Eagle software. all the PCB files are open-source you can access it from the following link. we love open source <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<div class="wp-block-button aligncenter"><a class="wp-block-button__link has-background wp-element-button" href="https://www.pcbway.com/project/shareproject/IoT_Using_Arduino_and_ESP8266_01.html" style="border-radius:100px;background-color:#00a99d">PCB Files</a></div>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="358" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/ESP8266-01-PCB-schematic.png?resize=770%2C358&#038;ssl=1" alt="Schematic" class="wp-image-409" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/ESP8266-01-PCB-schematic.png?w=2048&amp;ssl=1 2048w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/ESP8266-01-PCB-schematic.png?resize=800%2C372&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/ESP8266-01-PCB-schematic.png?resize=300%2C139&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/ESP8266-01-PCB-schematic.png?resize=768%2C357&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/ESP8266-01-PCB-schematic.png?resize=1024%2C476&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/ESP8266-01-PCB-schematic.png?resize=1026%2C477&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/ESP8266-01-PCB-schematic.png?resize=675%2C314&amp;ssl=1 675w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/ESP8266-01-PCB-schematic.png?w=1540&amp;ssl=1 1540w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">Schematic</figcaption></figure>
</div>

<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="533" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/ESP8266-01-PCB-Merged.png?resize=770%2C533&#038;ssl=1" alt="Bottom and Top Layer PCB Image" class="wp-image-401" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/ESP8266-01-PCB-Merged.png?w=2048&amp;ssl=1 2048w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/ESP8266-01-PCB-Merged.png?resize=800%2C554&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/ESP8266-01-PCB-Merged.png?resize=300%2C208&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/ESP8266-01-PCB-Merged.png?resize=768%2C532&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/ESP8266-01-PCB-Merged.png?resize=1024%2C709&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/ESP8266-01-PCB-Merged.png?resize=1026%2C711&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/ESP8266-01-PCB-Merged.png?resize=675%2C467&amp;ssl=1 675w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/ESP8266-01-PCB-Merged.png?w=1540&amp;ssl=1 1540w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">Bottom and Top Layer PCB Image</figcaption></figure>
</div>


<p class="has-regular-font-size wp-block-paragraph"><strong>You can order your own PCB From <a href="https://www.pcbway.com/">PCBWay</a> company these guys have a very good reputation in this field and they ship to more than 170 countries around the world with reasonable prices. all you have to do is to open the project <a href="https://www.pcbway.com/project/shareproject/IoT_Using_Arduino_and_ESP8266_01.html">PCB files link</a> and press &#8220;Add to cart&#8221;. That&#8217;s it!</strong><br><a href="https://www.pcbway.com/project/shareproject/IoT_Using_Arduino_and_ESP8266_01.html"></a></p>


<div class="wp-block-image">
<figure class="aligncenter"><img data-recalc-dims="1" loading="lazy" decoding="async" width="770" height="467" src="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-06-at-7.30.04-AM.png?resize=770%2C467&#038;ssl=1" alt="How to add to cart" class="wp-image-403" srcset="https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-06-at-7.30.04-AM.png?w=2048&amp;ssl=1 2048w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-06-at-7.30.04-AM.png?resize=800%2C485&amp;ssl=1 800w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-06-at-7.30.04-AM.png?resize=300%2C182&amp;ssl=1 300w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-06-at-7.30.04-AM.png?resize=768%2C466&amp;ssl=1 768w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-06-at-7.30.04-AM.png?resize=1024%2C621&amp;ssl=1 1024w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-06-at-7.30.04-AM.png?resize=1026%2C622&amp;ssl=1 1026w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-06-at-7.30.04-AM.png?resize=675%2C409&amp;ssl=1 675w, https://i0.wp.com/makesomestuff.org/wp-content/uploads/2019/09/Screen-Shot-2019-09-06-at-7.30.04-AM.png?w=1540&amp;ssl=1 1540w" sizes="auto, (max-width: 770px) 100vw, 770px" /><figcaption class="wp-element-caption">How to add to cart</figcaption></figure>
</div>


<h2 class="wp-block-heading"> Troubleshooting</h2>



<hr class="wp-block-separator has-css-opacity"/>



<ul class="wp-block-list">
<li><strong>if your ESP Module is successfully connected to your access point but there is no action happens when you click the web page buttons</strong>
<ul class="wp-block-list">
<li>make sure that your PC or Laptop and the ESP module is connected to the same Access point.</li>



<li>In Jquery code, make sure that you wrote the right ESP module IP address.</li>



<li>make sure that you are sending the request from your web browser from port 80(HTTP). example: <code>$.get("http://192.168.1.4:80/"</code></li>



<li>Make sure that you are connecting the load at Arduino digital pins 11 and 12.</li>
</ul>
</li>
</ul>



<p class="has-regular-font-size wp-block-paragraph">Don&#8217;t forget to save the Web page code file after any change or modification, and reload the web page in the web browser after any code modification to take effect.</p>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4043148098486780" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-4043148098486780" data-ad-slot="9966560791"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<h2 class="wp-block-heading">Final</h2>



<hr class="wp-block-separator has-css-opacity"/>



<p class="has-regular-font-size wp-block-paragraph">We are done! in today&#8217;s tutorial, we learned how to build a simple web page using HTML, CSS, and jquery. Also, we learned how to control an AC load wirelessly from a web-based control panel, and how to use the awesome ESP8266-01 Wifi module with the Arduino board.</p>



<p class="has-regular-font-size wp-block-paragraph"><strong>Lastly, if you have any questions drop it in the comments section below, I will be more than happy to hear from you <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /></strong></p>
<p>The post <a href="https://makesomestuff.org/iot-using-esp8266-01-and-arduino/">IoT Using ESP8266-01 and Arduino</a> appeared first on <a href="https://makesomestuff.org">Make Some Stuff</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://makesomestuff.org/iot-using-esp8266-01-and-arduino/feed/</wfw:commentRss>
			<slash:comments>8</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">207</post-id>	</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Minified using Disk

Served from: makesomestuff.org @ 2026-07-27 13:18:16 by W3 Total Cache
-->