{"id":406,"date":"2020-09-01T21:25:18","date_gmt":"2020-09-01T14:25:18","guid":{"rendered":"https:\/\/www.makeriot2020.com\/?p=406"},"modified":"2020-09-01T21:25:23","modified_gmt":"2020-09-01T14:25:23","slug":"arduino-web-server-using-ajax-part-1","status":"publish","type":"post","link":"https:\/\/www.makeriot2020.com\/index.php\/2020\/09\/01\/arduino-web-server-using-ajax-part-1\/","title":{"rendered":"Arduino Web Server using AJAX &#8211; Part 1"},"content":{"rendered":"\n<p>There are many ways to use Arduino to create your own IoT device. One of the easiest is to configure your Arduino as a Web Server. This way, you can connect to it from any browser capable device on your home network. It is also quite a bit safer to do it this way, as you don&#8217;t have to expose your device to the internet, reducing the security implications of many of the other methods available. <br><br>It does, however, have the disadvantage of not being able to connect to your device from outside your home network. ( In a later part of this series, I will show you how to do this relatively safely, but take note that you still won&#8217;t have SSH encryption to the device, that is a huge security risk in today&#8217;s online world.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"iot\">What use will this kind of IoT device have?<br><\/h2>\n\n\n\n<p>You can use an Arduino based web server to monitor various devices in your home, as well as control them. Many of us have old Android tablets and other devices lying around, that may be to old to run the newest Android Operating System. Such a Tablet can however be mounted to a wall, to provide a permanent display and control device. You will only be limited by your imagination, as well as your skill with interfacing your devices with electronics and Arduino.<br><br>A few examples of this can be<br>&#8211; controlling lights<br>&#8211; controlling a fan<br>&#8211; measuring temperature and light levels using various sensors, and performing actions based on those values<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">But Arduino Web Servers are slow<\/h2>\n\n\n\n<p>The normal Arduino web servers that we have all seen in various projects on the internet are indeed slow and cumbersome. This is because they usually have to refresh and reload the entire page to display every single update of a switch or output. We can however take advantage of technology used on computer web servers, as well as the browser of the end user. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"ajax\">Ajax and Javascript<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">What is AJAX?<\/h3>\n\n\n\n<p>AJAX stands for Asynchronous JavaScript and XML.<\/p>\n\n\n\n<p>AJAX is basically the use of  JavaScript functions for getting information from the webserver (Your Arduino). This means that data on a web page can be updated without fetching the whole page each time.<\/p>\n\n\n\n<p>This means that only the relevant part of the web page will be updated, either automatically, or when the end user performs an action, like click on a button, or when an input on the actual Arduino changes state.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What is JavaScript?<\/h3>\n\n\n\n<p>JavaScript is a client-side scripting language. This means that the code will run on the web browser. Meaning on the end-user computer or mobile device.<\/p>\n\n\n\n<p>The JavaScript is included in the HTML page that will be served by the Arduino Webserver. When you load the web page hosted by the Arduino, the page and the JavaScript is loaded to your browser. Your browser then runs the JavaScript code (provided that you have not disabled JavaScript in your browser).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"whatneed\">What will we need to do this?<\/h2>\n\n\n\n<p>You will need the following hardware and software to do this project<\/p>\n\n\n\n<p>&#8211; Arduino UNO or Compatible<br>&#8211; Arduino Ethernet Shield with NO SD-Card Inserted<br>&#8211; Breadboard<br>&#8211; 1K resistor<br>&#8211; LED<br>&#8211; 10k OR 22k Resistor<br>&#8211; Hookup Wire (5 pieces)<br>&#8211; Push Button<br><br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"circuit\">The Circuit<\/h2>\n\n\n\n<p>Wire the following circuit on your breadboard<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"567\" data-src=\"http:\/\/144.126.248.244\/wp-content\/uploads\/2020\/09\/ArduinoAjax-Webserver-1024x567.png\" alt=\"\" class=\"wp-image-410 lazyload\" data-srcset=\"https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/ArduinoAjax-Webserver-1024x567.png 1024w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/ArduinoAjax-Webserver-600x332.png 600w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/ArduinoAjax-Webserver-300x166.png 300w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/ArduinoAjax-Webserver-768x425.png 768w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/ArduinoAjax-Webserver-1536x851.png 1536w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/ArduinoAjax-Webserver-2048x1135.png 2048w\" data-sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/567;\" \/><figcaption>Circuit Diagram for the Arduino AJAX Web Server &#8211; Part 1<\/figcaption><\/figure>\n\n\n\n<p>Connect your Ethernet Shield to the Arduino Uno.<br>Connect the Resistors, LED and push-button Switch as shown.<br>Connect +5v from Arduino to Red Line, Gnd From Arduino to Blue line<\/p>\n\n\n\n<p>Connect Orange Wire from Arduino Pin 2 to a hole BETWEEN the 10k resistor and the switch ( See Diagram).<br>Connect Green Wire from Arduino Pin 3 to a hole above the 1k resistor ( See Diagram)<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"code\">The Code<\/h2>\n\n\n\n<p>Copy the following code into your Arduino IDE, Or download the file below<\/p>\n\n\n\n<div class=\"wp-block-file\"><a href=\"http:\/\/144.126.248.244\/wp-content\/uploads\/2020\/09\/AjaxWebserver-part1.ino_.zip\">AjaxWebserver-part1.ino_<\/a><a href=\"http:\/\/144.126.248.244\/wp-content\/uploads\/2020\/09\/AjaxWebserver-part1.ino_.zip\" class=\"wp-block-file__button\" download>Download<\/a><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<pre class=\"wp-block-preformatted\">#include &lt;SPI.h>\n#include &lt;Ethernet.h>\n\/\/ MAC address from Ethernet shield sticker under board\nbyte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };\nIPAddress ip(192, 168, 100, 32); \/\/ IP address, may need to change depending on network\nEthernetServer server(80); \/\/ create a server at port 80\nString HTTP_req; \/\/ stores the HTTP request\n\nvoid setup()\n{\nEthernet.begin(mac, ip); \/\/ initialize Ethernet device\nserver.begin(); \/\/ start to listen for clients\nSerial.begin(9600); \/\/ for diagnostics\npinMode(2, INPUT_PULLUP); \/\/ switch is attached to Arduino pin 2\npinMode(3, OUTPUT);\ndigitalWrite(3,LOW);\n}\n\nvoid loop()\n{\nEthernetClient client = server.available(); \/\/ try to get client\n<code>if (client) { \/\/ got client? <\/code>\n<code>boolean currentLineIsBlank = true; <\/code>\n<code>while (client.connected()) <\/code>\n<code>{ if (client.available()) <\/code>\n<code>{ \/\/ client data available to read char c = client.read(); \/\/ read 1 byte (character) from client HTTP_req += c; \/\/ save the HTTP request 1 char at a time <\/code>\n<code>\/\/ last line of client request is blank and ends with \\n <\/code>\n<code>\/\/ respond to client only after last line received <\/code>\n<code>if (c == '\\n' &amp;&amp; currentLineIsBlank) { \/\/ send a standard http response header client.println(\"HTTP\/1.1 200 OK\"); <\/code>\n<code>client.println(\"Content-Type: text\/html\"); <\/code>\n<code>client.println(\"Connection: keep-alive\"); <\/code>\n<code>client.println(); \/\/ AJAX request for switch state <\/code>\n<code>if (HTTP_req.indexOf(\"ajax_switch\") > -1) <\/code>\n<code>{ <\/code>\n<code>\/\/ read switch state and send appropriate paragraph text <\/code>\n<code>GetSwitchState(client); <\/code>\n<code>} else <\/code>\n<code>{ <\/code>\n<code>\/\/ HTTP request for web page \/\/ send web page - contains JavaScript with AJAX calls <\/code>\n<code>client.println(\"&lt;!DOCTYPE html>\"); <\/code>\n<code>client.println(\"&lt;html>\"); <\/code>\n<code>client.println(\"&lt;head>\"); <\/code>\n<code>client.println(\"&lt;title>Arduino Web Page with AJAX - Maker and IoT Ideas&lt;\/title>\"); <\/code>\n<code>client.println(\"&lt;script>\"); <\/code>\n<code>client.println(\"function GetSwitchState() {\"); <\/code>\n<code>client.println(\"nocache = \\\"&amp;nocache=\\\"\\ + Math.random() * 1000000;\"); <\/code>\n<code>client.println(\"var request = new XMLHttpRequest();\"); <\/code>\n<code>client.println(\"request.onreadystatechange = function() {\"); <\/code>\n<code>client.println(\"if (this.readyState == 4) {\"); <\/code>\n<code>client.println(\"if (this.status == 200) {\"); <\/code>\n<code>client.println(\"if (this.responseText != null) {\"); client.println(\"document.getElementById(\\\"switch_txt\\\")\\<\/code>.innerHTML =this.responseText;\");\n\nclient.println(\"}}}}\");\nclient.println(\"request.open(\\\"GET\\\", \\\"ajax_switch\\\" + nocache, true);\");\nclient.println(\"request.send(null);\");\nclient.println(\"setTimeout('GetSwitchState()', 1000);\");\nclient.println(\"}\");\nclient.println(\"\");\nclient.println(\"\");\nclient.println(\"\"); \nclient.println(\"Arduino Web Server with AJAX\"); \nclient.println(\"Switch Status on D2\"); \nclient.println( \"Switch state: Not requested\u2026\"); \nclient.println(\"\");\nclient.println(\"\");\n}\n\/\/ display received HTTP request on serial port\nSerial.print(HTTP_req);\nHTTP_req = \"\"; \/\/ finished with request, empty string\nbreak;\n}\n\/\/ every line of text received from the client ends with \\r\\n\nif (c == '\\n') {\n\/\/ last character on line of received text\n\/\/ starting new line with next character read\ncurrentLineIsBlank = true;\n}\nelse if (c != '\\r') {\n\/\/ a text character was received from client\ncurrentLineIsBlank = false;\n}\n} \/\/ end if (client.available())\n} \/\/ end while (client.connected())\ndelay(1); \/\/ give the web browser time to receive the data\nclient.stop(); \/\/ close the connection\n} \/\/ end if (client)\n}\n\n\/\/ send the state of the switch to the web browser\nvoid GetSwitchState(EthernetClient cl)\n{\nif (digitalRead(2)) {\ncl.println(\"Switch at D2 is: OFF, LED at D3 is OFF\");\ndigitalWrite(3,LOW);\n}\nelse {\ncl.println(\"Switch at D2 is: ON, LED at D2 is ON\");\ndigitalWrite(3,HIGH);\n}\n}<\/pre>\n\n\n\n<p>Upload the code to your Arduino<\/p>\n<\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"results\">Testing the results<\/h2>\n\n\n\n<p>Open a web browser and go to the IP Address of the server ( the one you set in your code).<br>If you did everything correctly, you should see a screen similar to this.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"458\" data-src=\"http:\/\/144.126.248.244\/wp-content\/uploads\/2020\/09\/Ajax-Webserver-OFF-1024x458.png\" alt=\"\" class=\"wp-image-413 lazyload\" data-srcset=\"https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/Ajax-Webserver-OFF-1024x458.png 1024w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/Ajax-Webserver-OFF-600x269.png 600w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/Ajax-Webserver-OFF-300x134.png 300w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/Ajax-Webserver-OFF-768x344.png 768w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/Ajax-Webserver-OFF.png 1347w\" data-sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/458;\" \/><figcaption>The Ajax Web Server shows the button and LED is OFF<\/figcaption><\/figure>\n\n\n\n<p>Now press the button<\/p>\n\n\n\n<p>The web page should immediately update and tell you that the button is On, and the LED is ON<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"459\" data-src=\"http:\/\/144.126.248.244\/wp-content\/uploads\/2020\/09\/Ajax-Webserver-ON-1024x459.png\" alt=\"\" class=\"wp-image-414 lazyload\" data-srcset=\"https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/Ajax-Webserver-ON-1024x459.png 1024w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/Ajax-Webserver-ON-600x269.png 600w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/Ajax-Webserver-ON-300x134.png 300w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/Ajax-Webserver-ON-768x344.png 768w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/Ajax-Webserver-ON.png 1359w\" data-sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/459;\" \/><figcaption><br>Ajax Web Server showing Status of Button and LED as ON<\/figcaption><\/figure>\n\n\n\n<p>The Generated HTML will look like this <\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<pre class=\"wp-block-preformatted\">&lt;!DOCTYPE html>\n\n&lt;html>\n\n&lt;head>\n\n&lt;title>Arduino Web Page with AJAX - Maker and IoT Ideas&lt;\/title>\n\n&lt;script>\n\nfunction GetSwitchState() {\n\nnocache = \"&amp;nocache=\" + Math.random() * 1000000;\n\nvar request = new XMLHttpRequest();\n\nrequest.onreadystatechange = function() {\n\nif (this.readyState == 4) {\n\nif (this.status == 200) {\n\nif (this.responseText != null) {\n\ndocument.getElementById(\"switch_txt\").innerHTML = this.responseText;\n\n}}}}\n\nrequest.open(\"GET\", \"ajax_switch\" + nocache, true);\n\nrequest.send(null);\n\nsetTimeout('GetSwitchState()', 1000);\n\n}\n\n&lt;\/script>\n\n&lt;\/head>\n\n&lt;body onload=\"GetSwitchState()\">\n\n&lt;h1>Arduino Web Server with AJAX&lt;\/h1>\n\n&lt;h3>Switch Status on D2&lt;\/h3>\n\n&lt;p id=\"switch_txt\">Switch state: Not requested...&lt;\/p>\n\n&lt;\/body>\n\n&lt;\/html><\/pre>\n<\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"moreimages\">Images of the Working Hardware<\/h2>\n\n\n\n<figure class=\"wp-block-gallery columns-3 is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\"><ul class=\"blocks-gallery-grid\"><li class=\"blocks-gallery-item\"><figure><img decoding=\"async\" width=\"1024\" height=\"768\" data-src=\"http:\/\/144.126.248.244\/wp-content\/uploads\/2020\/09\/20200901_205724-1024x768.jpg\" alt=\"\" data-id=\"415\" data-link=\"http:\/\/144.126.248.244\/?attachment_id=415\" class=\"wp-image-415 lazyload\" data-srcset=\"https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205724-1024x768.jpg 1024w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205724-scaled-600x450.jpg 600w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205724-300x225.jpg 300w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205724-768x576.jpg 768w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205724-1536x1152.jpg 1536w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205724-2048x1536.jpg 2048w\" data-sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/768;\" \/><\/figure><\/li><li class=\"blocks-gallery-item\"><figure><img decoding=\"async\" width=\"1024\" height=\"768\" data-src=\"http:\/\/144.126.248.244\/wp-content\/uploads\/2020\/09\/20200901_205729-1024x768.jpg\" alt=\"\" data-id=\"416\" data-link=\"http:\/\/144.126.248.244\/?attachment_id=416\" class=\"wp-image-416 lazyload\" data-srcset=\"https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205729-1024x768.jpg 1024w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205729-scaled-600x450.jpg 600w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205729-300x225.jpg 300w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205729-768x576.jpg 768w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205729-1536x1152.jpg 1536w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205729-2048x1536.jpg 2048w\" data-sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/768;\" \/><\/figure><\/li><li class=\"blocks-gallery-item\"><figure><img decoding=\"async\" width=\"1024\" height=\"768\" data-src=\"http:\/\/144.126.248.244\/wp-content\/uploads\/2020\/09\/20200901_205255-1024x768.jpg\" alt=\"\" data-id=\"417\" data-link=\"http:\/\/144.126.248.244\/?attachment_id=417\" class=\"wp-image-417 lazyload\" data-srcset=\"https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205255-1024x768.jpg 1024w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205255-scaled-600x450.jpg 600w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205255-300x225.jpg 300w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205255-768x576.jpg 768w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205255-1536x1152.jpg 1536w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205255-2048x1536.jpg 2048w\" data-sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/768;\" \/><\/figure><\/li><li class=\"blocks-gallery-item\"><figure><img decoding=\"async\" width=\"1024\" height=\"768\" data-src=\"http:\/\/144.126.248.244\/wp-content\/uploads\/2020\/09\/20200901_205312-1024x768.jpg\" alt=\"\" data-id=\"418\" data-link=\"http:\/\/144.126.248.244\/?attachment_id=418\" class=\"wp-image-418 lazyload\" data-srcset=\"https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205312-1024x768.jpg 1024w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205312-scaled-600x450.jpg 600w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205312-300x225.jpg 300w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205312-768x576.jpg 768w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205312-1536x1152.jpg 1536w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205312-2048x1536.jpg 2048w\" data-sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/768;\" \/><\/figure><\/li><li class=\"blocks-gallery-item\"><figure><img decoding=\"async\" width=\"1024\" height=\"768\" data-src=\"http:\/\/144.126.248.244\/wp-content\/uploads\/2020\/09\/20200901_205729-1-1024x768.jpg\" alt=\"\" data-id=\"419\" data-link=\"http:\/\/144.126.248.244\/?attachment_id=419\" class=\"wp-image-419 lazyload\" data-srcset=\"https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205729-1-1024x768.jpg 1024w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205729-1-scaled-600x450.jpg 600w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205729-1-300x225.jpg 300w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205729-1-768x576.jpg 768w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205729-1-1536x1152.jpg 1536w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205729-1-2048x1536.jpg 2048w\" data-sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/768;\" \/><\/figure><\/li><li class=\"blocks-gallery-item\"><figure><img decoding=\"async\" width=\"1024\" height=\"768\" data-src=\"http:\/\/144.126.248.244\/wp-content\/uploads\/2020\/09\/20200901_205741-1024x768.jpg\" alt=\"\" data-id=\"420\" data-full-url=\"http:\/\/144.126.248.244\/wp-content\/uploads\/2020\/09\/20200901_205741-scaled.jpg\" data-link=\"http:\/\/144.126.248.244\/?attachment_id=420\" class=\"wp-image-420 lazyload\" data-srcset=\"https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205741-1024x768.jpg 1024w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205741-scaled-600x450.jpg 600w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205741-300x225.jpg 300w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205741-768x576.jpg 768w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205741-1536x1152.jpg 1536w, https:\/\/www.makeriot2020.com\/wp-content\/uploads\/2020\/09\/20200901_205741-2048x1536.jpg 2048w\" data-sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/768;\" \/><\/figure><\/li><\/ul><\/figure>\n\n\n\n<p>Please note that I did not use a push button switch in my example. I have just used a piece of hookup wire to connect the pulled-up pin to ground, as it is easier to photograph that way, without my finger being in the way on a button. \ud83d\ude42<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclude\">Conclusion<\/h2>\n\n\n\n<p>This concludes part 1 of this series. This example can very easily be extended to be more useful, as well as be modified to work on other platforms, like ESP32.<br>In further parts, I will show you how to extend this very simple server into becoming something much more useful. Please visit again to see the rest of this series.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are many ways to use Arduino to create your own IoT device. One of the easiest is to configure your Arduino as a Web Server. This way, you can connect to it from any browser capable device on your home network. It is also quite a bit safer to do it this way, as &hellip; <a href=\"https:\/\/www.makeriot2020.com\/index.php\/2020\/09\/01\/arduino-web-server-using-ajax-part-1\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Arduino Web Server using AJAX &#8211; Part 1&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":415,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,53],"tags":[60,6,59,62,55,61],"class_list":["post-406","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino","category-iot-devices","tag-ajax","tag-arduino","tag-arduino-webserver","tag-ethernet-shield","tag-iot","tag-javascript"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/posts\/406","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/comments?post=406"}],"version-history":[{"count":0,"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/posts\/406\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/media\/415"}],"wp:attachment":[{"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/media?parent=406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/categories?post=406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/tags?post=406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}