<?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>ESP-01 Archives &#8211; Make Some Stuff</title>
	<atom:link href="https://makesomestuff.org/tag/esp-01/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>Build Cool Electronics Projects!</description>
	<lastBuildDate>Sat, 27 Sep 2025 21:22:52 +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>ESP-01 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>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 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-08-01 20:10:27 by W3 Total Cache
-->