{"id":91808,"date":"2019-12-18T14:22:02","date_gmt":"2019-12-18T14:22:02","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=91808"},"modified":"2025-03-17T12:21:35","modified_gmt":"2025-03-17T12:21:35","slug":"esp8266-relay-module-ac-web-server","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/esp8266-relay-module-ac-web-server\/","title":{"rendered":"ESP8266 NodeMCU Relay Module &#8211; Control AC Appliances (Web Server)"},"content":{"rendered":"\n<p>Using a relay with the ESP8266 is a great way to control AC household appliances remotely. This tutorial explains how to control a relay module with the ESP8266 NodeMCU. We&#8217;ll take a look at how a relay module works, how to connect the relay to the ESP8266 and build a web server to control a relay remotely (or as many relays as you want).<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/ESP8266-Relay-Module-Tutorial-project-web-server-featured.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP8266 Relay Module - Control AC Appliances (Web Server)\" class=\"wp-image-91809\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/ESP8266-Relay-Module-Tutorial-project-web-server-featured.jpg?w=1280&amp;quality=100&amp;strip=all&amp;ssl=1 1280w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/ESP8266-Relay-Module-Tutorial-project-web-server-featured.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/ESP8266-Relay-Module-Tutorial-project-web-server-featured.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/ESP8266-Relay-Module-Tutorial-project-web-server-featured.jpg?resize=768%2C432&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div>\n\n\n<p>Learn how to control a relay module with ESP32 board: <a href=\"https:\/\/randomnerdtutorials.com\/esp32-relay-module-ac-web-server\/\"><strong>Guide for ESP32 Relay Module<\/strong> &#8211; Control AC Appliances + Web Server Example<\/a>. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Watch the Video Tutorial<\/h2>\n\n\n\n<p>Watch the following video tutorial or keep reading this page for the written instructions and all the resources. <\/p>\n\n\n<p style=\"text-align:center\"><iframe width=\"720\" height=\"405\" src=\"https:\/\/www.youtube.com\/embed\/giACxpN0cGc?rel=0\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introducing Relays<\/h2>\n\n\n\n<p>A relay is an electrically operated switch and like any other switch, it that can be turned on or off, letting the current go through or not. It can be controlled with low voltages, like the 3.3V provided by the ESP8266 GPIOs and allows us to control high voltages like 12V, 24V or mains voltage (230V in Europe and 120V in the US).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1, 2, 4, 8, 16 Channels Relay Modules<\/h3>\n\n\n\n<p>There are different relay modules with a different number of channels. You can find relay modules with one, two, four, eight and even sixteen channels. The number of channels determines the number of outputs we&#8217;ll be able to control.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/Relay-1-2-4-8-ch-channel-modules.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Relay modules with different number of channels\" class=\"wp-image-91706\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/Relay-1-2-4-8-ch-channel-modules.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/Relay-1-2-4-8-ch-channel-modules.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>There are relay modules whose electromagnet can be powered by 5V and with 3.3V. Both can be used with the ESP8266 &#8211; you can either use the Vin pin (that provides 5V) or the 3.3V pin.<\/p>\n\n\n\n<p>Additionally, some come with built-in optocoupler that add an extra &#8220;layer&#8221; of protection, optically isolating the ESP8266 from the relay circuit.<\/p>\n\n\n\n<p><strong>Get a relay module<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/5v-2-channel-relay-module-optocoupler\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">5V 2-channel relay module<\/a> (with optocoupler)<\/li>\n\n\n\n<li><a href=\"https:\/\/www.banggood.com\/2Pcs-5V-1-Channel-Level-Trigger-Optocoupler-Relay-Module-For-Arduino-p-1366337.html?p=MA240439985285201910\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">5V 1-channel relay module<\/a> (with optocoupler) <\/li>\n\n\n\n<li><a href=\"https:\/\/www.banggood.com\/5V-8-Channel-Relay-Module-Board-For-Arduino-PIC-AVR-DSP-ARM-p-74110.html?p=MA240439985285201910\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">5V 8-channel relay module<\/a> (with optocoupler) <\/li>\n\n\n\n<li><a aria-label=\"5V 16-channel relay module (opens in a new tab)\" href=\"https:\/\/www.banggood.com\/BESTEP-16-Channel-5V-Relay-Module-LM2596-With-Optocoupler-Protection-Low-Level-Trigger-For-Auduino-p-1390338.html?p=MA240439985285201910&amp;cur_warehouse=CN\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">5V 16-channel relay module<\/a> (with optocoupler)<\/li>\n\n\n\n<li><a href=\"https:\/\/www.banggood.com\/BESTEP-1-Channel-3_3V-Low-Level-Trigger-Relay-Module-Optocoupler-Isolation-Terminal-For-Arduino-p-1355736.html?p=MA240439985285201910\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">3.3V 1-channel relay module<\/a> (with optocoupler) <\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Relay Pinout<\/h2>\n\n\n\n<p>For demonstration purposes, let&#8217;s take a look at the pinout of a 2-channel relay module. Using a relay module with a different number of channels is similar.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"850\" height=\"372\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/Relay-pinout.png?resize=850%2C372&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"2-channel Relay Module Pinout\" class=\"wp-image-91429\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/Relay-pinout.png?w=850&amp;quality=100&amp;strip=all&amp;ssl=1 850w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/Relay-pinout.png?resize=300%2C131&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/11\/Relay-pinout.png?resize=768%2C336&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 850px) 100vw, 850px\" \/><\/figure><\/div>\n\n\n<p>The two connectors (with three sockets each) on the left side of the relay module connect high voltage, and the pins on the right side (low-voltage) connect to the ESP8266 GPIOs.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Mains Voltage Connections<\/h3>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/Relay-2-ch-channel-module-output-pins-pinout.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Relay module mains voltage side\" class=\"wp-image-91707\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/Relay-2-ch-channel-module-output-pins-pinout.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/Relay-2-ch-channel-module-output-pins-pinout.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>The relay module shown in the previous photo has two connectors, each with three sockets: common (<span class=\"rnthl rntcblack\">COM<\/span>), normally closed (<span class=\"rnthl rntclblue\">NC<\/span>), and normally open (<span class=\"rnthl rntcyellow\">NO<\/span>).<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>COM:<\/strong>\u00a0connect the current you want to control (mains voltage).<\/li>\n\n\n\n<li><strong>NC\u00a0(Normally Closed):<\/strong>\u00a0the normally closed configuration is used when you want the relay to be closed by default. The NC are COM pins are connected, meaning the current is flowing unless you send a signal from the ESP8266 to the relay module to open the circuit and stop the current flow.<\/li>\n\n\n\n<li><strong>NO\u00a0(Normally Open):<\/strong>\u00a0the normally open configuration works the other way around: there is no connection between the NO and COM pins, so the circuit is broken unless you send a signal from the ESP8266 to close the circuit.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Control Pins<\/h3>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/Relay-2-ch-channel-module-with-optocoupler-top-view.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"2-channel Relay Module\" class=\"wp-image-91711\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/Relay-2-ch-channel-module-with-optocoupler-top-view.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/Relay-2-ch-channel-module-with-optocoupler-top-view.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>The low-voltage side has a set of four pins and a set of three pins. The first set consists of <span class=\"rnthl rntcred\">VCC<\/span> and <span class=\"rnthl rntcblack\">GND<\/span> to power up the module, and input 1 (<span class=\"rnthl rntclblue\">IN1<\/span>) and input 2 (<span class=\"rnthl rntclgreen\">IN2<\/span>) to control the bottom and top relays, respectively. <\/p>\n\n\n\n<p>If your relay module only has one channel, you&#8217;ll have just one IN pin. If you have four channels, you&#8217;ll have four IN pins, and so on.<\/p>\n\n\n\n<p>The signal you send to the IN pins, determines whether the relay is active or not. The relay is triggered when the input goes below about 2V. This means that you&#8217;ll have the following scenarios:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Normally Closed configuration (NC)<\/strong>:\n<ul class=\"wp-block-list\">\n<li>HIGH signal &#8211; current is flowing<\/li>\n\n\n\n<li>LOW signal &#8211; current is <strong>not <\/strong>flowing<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Normally Open configuration (NO)<\/strong>:\n<ul class=\"wp-block-list\">\n<li>HIGH signal &#8211; current is <strong>not <\/strong>flowing<\/li>\n\n\n\n<li>LOW signal &#8211; current is flowing<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p>You should use a normally closed configuration when the current should be flowing most of the times, and you only want to stop it occasionally. <\/p>\n\n\n\n<p>Use a normally open configuration when you want the current to flow occasionally (for example, turn on a lamp occasionally). <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Power Supply Selection<\/h3>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/Relay-2-ch-channel-module-input-pins-pinout.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"2-channel relay module control pins\" class=\"wp-image-91708\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/Relay-2-ch-channel-module-input-pins-pinout.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/Relay-2-ch-channel-module-input-pins-pinout.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>The second set of pins consists of <span class=\"rnthl rntcblack\">GND<\/span>, <span class=\"rnthl rntcred\">VCC<\/span>, and <span class=\"rnthl rntcorange\">JD-VCC<\/span> pins. The <span class=\"rnthl rntcorange\">JD-VCC<\/span> pin powers the electromagnet of the relay. Notice that the module has a jumper cap connecting the VCC and JD-VCC pins; the one shown here is yellow, but yours may be a different color. <\/p>\n\n\n\n<p>With the jumper cap on, the <span class=\"rnthl rntcred\">VCC<\/span> and <span class=\"rnthl rntcorange\">JD-VCC<\/span> pins are connected. That means the relay electromagnet is directly powered from the ESP8266 power pin, so the relay module and the ESP8266 circuits are not physically isolated from each other. <\/p>\n\n\n\n<p>Without the jumper cap, you need to provide an independent power source to power up the relay\u2019s electromagnet through the <span class=\"rnthl rntcorange\">JD-VCC<\/span> pin. That configuration physically isolates the relays from the ESP8266 with the module\u2019s built-in optocoupler, which prevents damage to the ESP8266 in case of electrical spikes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">ESP8266 Safest Pins to Use with Relays<\/h2>\n\n\n\n<p>Some ESP8266 pins output a 3.3V signal when the ESP8266 boots. This may be problematic if you have relays or other peripherals connected to those GPIOs.  <\/p>\n\n\n\n<p>Additionally, some pins must be pulled HIGH or LOW in order to boot the ESP8266. <\/p>\n\n\n\n<p>Taking this into account, the safest ESP8266 pins to use with relays are: GPIO 5, GPIO 4, GPIO 14, GPIO 12 and GPIO 13.<\/p>\n\n\n\n<p class=\"rntbox rntclblue\">For more information about the ESP8266 GPIOs read: <a href=\"https:\/\/randomnerdtutorials.com\/esp8266-pinout-reference-gpios\/\"><strong>ESP8266 Pinout Reference: Which GPIO pins should you use?<\/strong><\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Wiring a Relay Module to the ESP8266 NodeMCU Board<\/h2>\n\n\n\n<p>Connect the relay module to the ESP8266 as shown in the following diagram. The diagram shows wiring for a 2-channel relay module, wiring a different number of channels is similar.<\/p>\n\n\n\n<p class=\"rntbox rntcred\"><strong>Warning: <\/strong> in this example, we\u2019re dealing with mains voltage. Misuse can result in serious injuries. If you&#8217;re not familiar with mains voltage ask someone who is to help you out. While programming the ESP or wiring your circuit make sure everything is disconnected from mains voltage. <\/p>\n\n\n\n<p>Alternatively, you can use a 12V power source to control 12V appliances.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/relay-esp8266-wiring.png?quality=100&#038;strip=all&#038;ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1038\" height=\"661\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/relay-esp8266-wiring.png?resize=1038%2C661&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Wiring a Relay Module to the ESP8266 NodeMCU Board\" class=\"wp-image-91891\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/relay-esp8266-wiring.png?w=1038&amp;quality=100&amp;strip=all&amp;ssl=1 1038w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/relay-esp8266-wiring.png?resize=300%2C191&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/relay-esp8266-wiring.png?resize=1024%2C652&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/relay-esp8266-wiring.png?resize=768%2C489&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 1038px) 100vw, 1038px\" \/><\/a><\/figure><\/div>\n\n\n<p>In this example, we&#8217;re controlling a lamp. We just want to light up the lamp occasionally, so it is better to use a normally open configuration.<\/p>\n\n\n\n<p>We&#8217;re connecting the IN1 pin to <span class=\"rnthl rntclgreen\">GPIO 5<\/span>, you can use any other suitable GPIO. See <a href=\"https:\/\/randomnerdtutorials.com\/esp8266-pinout-reference-gpios\/\">ESP8266 GPIO Reference Guide<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Controlling a Relay Module with the ESP8266 NodeMCU &#8211; Arduino Sketch<\/h2>\n\n\n\n<p>The code to control a relay with the ESP8266 is as simple as controlling an LED or any other output. In this example, as we&#8217;re using a normally open configuration, we need to send a LOW signal to let the current flow, and a HIGH signal to stop the current flow.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/ESP8266-Relay-Module-Tutorial-project-example-off.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Control a Lamp with the ESP8266 using a Relay\" class=\"wp-image-91810\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/ESP8266-Relay-Module-Tutorial-project-example-off.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/ESP8266-Relay-Module-Tutorial-project-example-off.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>The following code will light up your lamp for 10 seconds and turn it off for another 10 seconds.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*********\n  Rui Santos\n  Complete project details at https:\/\/RandomNerdTutorials.com\/esp8266-relay-module-ac-web-server\/\n  \n  The above copyright notice and this permission notice shall be included in all\n  copies or substantial portions of the Software.\n*********\/\n\nconst int relay = 5;\n\nvoid setup() {\n  Serial.begin(115200);\n  pinMode(relay, OUTPUT);\n}\n\nvoid loop() {\n  \/\/ Normally Open configuration, send LOW signal to let current flow\n  \/\/ (if you're usong Normally Closed configuration send HIGH signal)\n  digitalWrite(relay, LOW);\n  Serial.println(&quot;Current Flowing&quot;);\n  delay(5000); \n  \n  \/\/ Normally Open configuration, send HIGH signal stop current flow\n  \/\/ (if you're usong Normally Closed configuration send LOW signal)\n  digitalWrite(relay, HIGH);\n  Serial.println(&quot;Current not Flowing&quot;);\n  delay(5000);\n}\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/ESP8266\/ESP8266_Relay_Control.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How the Code Works<\/h3>\n\n\n\n<p>Define the pin the relay IN pin is connected to.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>const int relay = 5;<\/code><\/pre>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">setup()<\/span>, define the relay as an output.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>pinMode(relay, OUTPUT);<\/code><\/pre>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">loop()<\/span>, send a <span class=\"rnthl rntliteral\">LOW<\/span> signal to let the current flow and light up the lamp.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>digitalWrite(relay, LOW);<\/code><\/pre>\n\n\n\n<p>If you&#8217;re using a normally closed configuration, send a <span class=\"rnthl rntliteral\">HIGH<\/span> signal to light up the lamp. Then, wait 5 seconds.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>delay(5000); <\/code><\/pre>\n\n\n\n<p>Stop the current flow by sending a <span class=\"rnthl rntliteral\">HIGH<\/span> signal to the relay pin. If you&#8217;re using a normally closed configuration, send a <span class=\"rnthl rntliteral\">LOW<\/span> signal to stop the current flow.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>digitalWrite(relay, HIGH);<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Control Multiple Relays with ESP8266 NodeMCU Web Server<\/h2>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"450\" height=\"900\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/ESP32-relay-web-server.png?resize=450%2C900&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Control Multiple Relays with ESP8266 Web Server\" class=\"wp-image-91725\" style=\"width:225px;height:450px\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/ESP32-relay-web-server.png?w=450&amp;quality=100&amp;strip=all&amp;ssl=1 450w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/ESP32-relay-web-server.png?resize=150%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 150w\" sizes=\"(max-width: 450px) 100vw, 450px\" \/><\/figure><\/div>\n\n\n<p>In this section, we&#8217;ve created a web server example that allows you to control as many relays as you want via web server whether they are configured as normally opened or as normally closed. You just need to change a few lines of code to define the number of relays you want to control and the pin assignment.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Installing the Libraries for the Web Server<\/h3>\n\n\n\n<p>We&#8217;ll build the web server using the following libraries:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/github.com\/ESP32Async\/ESPAsyncWebServer\" target=\"_blank\" rel=\"noopener\" title=\"\">ESPAsyncWebServer by ESP32Async<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/github.com\/ESP32Async\/ESPAsyncTCP\" target=\"_blank\" rel=\"noopener\" title=\"\">ESPAsyncTCP&nbsp;by ESP32Async<\/a><\/li>\n<\/ul>\n\n\n\n<p>You can install these libraries using the Arduino Library Manager. Go to&nbsp;<strong>Sketch&nbsp;<\/strong>&gt;&nbsp;<strong>Include Library<\/strong>&nbsp;&gt;&nbsp;<strong>Manage Libraries<\/strong>&nbsp;and search for the libraries&#8217; names.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Code<\/h3>\n\n\n\n<p>After installing the required libraries, copy the following code to your Arduino IDE.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*********\n  Rui Santos &amp; Sara Santos - Random Nerd Tutorials\n  Complete project details at https:\/\/RandomNerdTutorials.com\/esp8266-relay-module-ac-web-server\/\n  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n*********\/\n\n\/\/ Import required libraries\n#include &quot;ESP8266WiFi.h&quot;\n#include &quot;ESPAsyncWebServer.h&quot;\n\n\/\/ Set to true to define Relay as Normally Open (NO)\n#define RELAY_NO    true\n\n\/\/ Set number of relays\n#define NUM_RELAYS  5\n\n\/\/ Assign each GPIO to a relay\nint relayGPIOs[NUM_RELAYS] = {5, 4, 14, 12, 13};\n\n\/\/ Replace with your network credentials\nconst char* ssid = &quot;REPLACE_WITH_YOUR_SSID&quot;;\nconst char* password = &quot;REPLACE_WITH_YOUR_PASSWORD&quot;;\n\nconst char* PARAM_INPUT_1 = &quot;relay&quot;;  \nconst char* PARAM_INPUT_2 = &quot;state&quot;;\n\n\/\/ Create AsyncWebServer object on port 80\nAsyncWebServer server(80);\n\nconst char index_html[] PROGMEM = R&quot;rawliteral(\n&lt;!DOCTYPE HTML&gt;&lt;html&gt;\n&lt;head&gt;\n  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;\n  &lt;style&gt;\n    html {font-family: Arial; display: inline-block; text-align: center;}\n    h2 {font-size: 3.0rem;}\n    p {font-size: 3.0rem;}\n    body {max-width: 600px; margin:0px auto; padding-bottom: 25px;}\n    .switch {position: relative; display: inline-block; width: 120px; height: 68px} \n    .switch input {display: none}\n    .slider {position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; border-radius: 34px}\n    .slider:before {position: absolute; content: &quot;&quot;; height: 52px; width: 52px; left: 8px; bottom: 8px; background-color: #fff; -webkit-transition: .4s; transition: .4s; border-radius: 68px}\n    input:checked+.slider {background-color: #2196F3}\n    input:checked+.slider:before {-webkit-transform: translateX(52px); -ms-transform: translateX(52px); transform: translateX(52px)}\n  &lt;\/style&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n  &lt;h2&gt;ESP Web Server&lt;\/h2&gt;\n  %BUTTONPLACEHOLDER%\n&lt;script&gt;function toggleCheckbox(element) {\n  var xhr = new XMLHttpRequest();\n  if(element.checked){ xhr.open(&quot;GET&quot;, &quot;\/update?relay=&quot;+element.id+&quot;&amp;state=1&quot;, true); }\n  else { xhr.open(&quot;GET&quot;, &quot;\/update?relay=&quot;+element.id+&quot;&amp;state=0&quot;, true); }\n  xhr.send();\n}&lt;\/script&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n)rawliteral&quot;;\n\n\/\/ Replaces placeholder with button section in your web page\nString processor(const String&amp; var){\n  \/\/Serial.println(var);\n  if(var == &quot;BUTTONPLACEHOLDER&quot;){\n    String buttons =&quot;&quot;;\n    for(int i=1; i&lt;=NUM_RELAYS; i++){\n      String relayStateValue = relayState(i);\n      buttons+= &quot;&lt;h4&gt;Relay #&quot; + String(i) + &quot; - GPIO &quot; + relayGPIOs[i-1] + &quot;&lt;\/h4&gt;&lt;label class=\\&quot;switch\\&quot;&gt;&lt;input type=\\&quot;checkbox\\&quot; onchange=\\&quot;toggleCheckbox(this)\\&quot; id=\\&quot;&quot; + String(i) + &quot;\\&quot; &quot;+ relayStateValue +&quot;&gt;&lt;span class=\\&quot;slider\\&quot;&gt;&lt;\/span&gt;&lt;\/label&gt;&quot;;\n    }\n    return buttons;\n  }\n  return String();\n}\n\nString relayState(int numRelay){\n  if(RELAY_NO){\n    if(digitalRead(relayGPIOs[numRelay-1])){\n      return &quot;&quot;;\n    }\n    else {\n      return &quot;checked&quot;;\n    }\n  }\n  else {\n    if(digitalRead(relayGPIOs[numRelay-1])){\n      return &quot;checked&quot;;\n    }\n    else {\n      return &quot;&quot;;\n    }\n  }\n  return &quot;&quot;;\n}\n\nvoid setup(){\n  \/\/ Serial port for debugging purposes\n  Serial.begin(115200);\n\n  \/\/ Set all relays to off when the program starts - if set to Normally Open (NO), the relay is off when you set the relay to HIGH\n  for(int i=1; i&lt;=NUM_RELAYS; i++){\n    pinMode(relayGPIOs[i-1], OUTPUT);\n    if(RELAY_NO){\n      digitalWrite(relayGPIOs[i-1], HIGH);\n    }\n    else{\n      digitalWrite(relayGPIOs[i-1], LOW);\n    }\n  }\n  \n  \/\/ Connect to Wi-Fi\n  WiFi.begin(ssid, password);\n  while (WiFi.status() != WL_CONNECTED) {\n    delay(1000);\n    Serial.println(&quot;Connecting to WiFi..&quot;);\n  }\n\n  \/\/ Print ESP8266 Local IP Address\n  Serial.println(WiFi.localIP());\n\n  \/\/ Route for root \/ web page\n  server.on(&quot;\/&quot;, HTTP_GET, [](AsyncWebServerRequest *request){\n    request-&gt;send(200, &quot;text\/html&quot;, index_html, processor);\n  });\n\n  \/\/ Send a GET request to &lt;ESP_IP&gt;\/update?relay=&lt;inputMessage&gt;&amp;state=&lt;inputMessage2&gt;\n  server.on(&quot;\/update&quot;, HTTP_GET, [] (AsyncWebServerRequest *request) {\n    String inputMessage;\n    String inputParam;\n    String inputMessage2;\n    String inputParam2;\n    \/\/ GET input1 value on &lt;ESP_IP&gt;\/update?relay=&lt;inputMessage&gt;\n    if (request-&gt;hasParam(PARAM_INPUT_1) &amp; request-&gt;hasParam(PARAM_INPUT_2)) {\n      inputMessage = request-&gt;getParam(PARAM_INPUT_1)-&gt;value();\n      inputParam = PARAM_INPUT_1;\n      inputMessage2 = request-&gt;getParam(PARAM_INPUT_2)-&gt;value();\n      inputParam2 = PARAM_INPUT_2;\n      if(RELAY_NO){\n        Serial.print(&quot;NO &quot;);\n        digitalWrite(relayGPIOs[inputMessage.toInt()-1], !inputMessage2.toInt());\n      }\n      else{\n        Serial.print(&quot;NC &quot;);\n        digitalWrite(relayGPIOs[inputMessage.toInt()-1], inputMessage2.toInt());\n      }\n    }\n    else {\n      inputMessage = &quot;No message sent&quot;;\n      inputParam = &quot;none&quot;;\n    }\n    Serial.println(inputMessage + inputMessage2);\n    request-&gt;send(200, &quot;text\/plain&quot;, &quot;OK&quot;);\n  });\n  \/\/ Start server\n  server.begin();\n}\n  \nvoid loop() {\n\n}\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/ESP8266\/ESP8266_Relay_Module_Web_Server.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Define Relay Configuration<\/h3>\n\n\n\n<p>Modify the following variable to indicate whether you&#8217;re using your relays in normally open (NO) or normally closed (NC) configuration. Set the <span class=\"rnthl rntliteral\">RELAY_NO<\/span> variable to <span class=\"rnthl rntliteral\">true<\/span> for normally open os set to <span class=\"rnthl rntliteral\">false<\/span> for normally closed.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#define RELAY_NO true<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Define Number of Relays (Channels)<\/h3>\n\n\n\n<p>You can define the number of relays you want to control on the <span class=\"rnthl rntliteral\">NUM_RELAYS<\/span> variable. For demonstration purposes, we&#8217;re setting it to 5.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#define NUM_RELAYS 5<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Define Relays Pin Assignment<\/h3>\n\n\n\n<p>In the following array variable you can define the ESP8266 GPIOs that will control the relays.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>int relayGPIOs&#091;NUM_RELAYS] = {5, 4, 14, 12, 13};<\/code><\/pre>\n\n\n\n<p>The number of relays set on the <span class=\"rnthl rntliteral\">NUM_RELAYS<\/span> variable needs to match the number of GPIOs assigned in the <span class=\"rnthl rntliteral\">relayGPIOs<\/span> array.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Network Credentials<\/h3>\n\n\n\n<p>Insert your network credentials in the following variables.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>const char* ssid     = \"REPLACE_WITH_YOUR_SSID\";\nconst char* password = \"REPLACE_WITH_YOUR_PASSWORD\";<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Wiring 8 Channel Relay to ESP8266 NodeMCU<\/h2>\n\n\n\n<p>For demonstration purposes, we\u2019re controlling 5 relay channels. Wire the ESP8266 NodeMCU board to the relay module as shown in the next schematic diagram.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/Relay-pinout-8channels-esp8266.png?quality=100&#038;strip=all&#038;ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1200\" height=\"1040\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/Relay-pinout-8channels-esp8266.png?resize=1200%2C1040&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ES8266 8-channel relay module wiring diagram schematic\" class=\"wp-image-91892\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/Relay-pinout-8channels-esp8266.png?w=1218&amp;quality=100&amp;strip=all&amp;ssl=1 1218w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/Relay-pinout-8channels-esp8266.png?resize=300%2C260&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/Relay-pinout-8channels-esp8266.png?resize=1024%2C888&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/Relay-pinout-8channels-esp8266.png?resize=768%2C666&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/a><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Demonstration<\/h2>\n\n\n\n<p>After making the necessary changes, upload the code to your ESP8266.<\/p>\n\n\n\n<p>Open the Serial Monitor at a baud rate of 115200 and press the ESP8266 RST button to get its IP address.<\/p>\n\n\n\n<p>Then, open a browser in your local network and type the ESP8266 IP address to get access to the web server.<\/p>\n\n\n\n<p>You should get something as follows with as many buttons as the number of relays you&#8217;ve defined in your code.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/ESP8266-Relay-Module-Tutorial-project-web-server-example-on-demo.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP8266 Web Server controlling AC lamp with relay module\" class=\"wp-image-91811\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/ESP8266-Relay-Module-Tutorial-project-web-server-example-on-demo.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/ESP8266-Relay-Module-Tutorial-project-web-server-example-on-demo.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>Now, you can use the buttons to control your relays remotely using your smartphone.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Enclosure for Safety<\/h3>\n\n\n\n<p>For a final project, make sure you place your relay module and ESP inside an enclosure to avoid any AC pins exposed.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/enclosure-for-relay-module.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Enclosure for Relay Module\" class=\"wp-image-92448\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/enclosure-for-relay-module.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/enclosure-for-relay-module.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>Using relays with the ESP8266 is a great way to control AC household appliances remotely. You can also read our other <a href=\"https:\/\/randomnerdtutorials.com\/esp32-relay-module-ac-web-server\/\">Guide to control a Relay Module with <strong>ESP32<\/strong><\/a>. <\/p>\n\n\n\n<p>Controlling a relay with the ESP8266 is as easy controlling any other output, you just need to send HIGH and LOW signals as you would do to control an LED.<\/p>\n\n\n\n<p>You can use our other web server examples that control outputs to control relays. You just need to pay attention to the configuration you&#8217;re using. In case you&#8217;re using a normally open configuration, the relay works with inverted logic. You can use the following web server examples to control your relay:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp8266-web-server\/\">ESP8266 Web Server \u2013 Arduino IDE<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp8266-web-server-spiffs-nodemcu\/\">ESP8266 Web Server using SPIFFS (control outputs)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-esp8266-micropython-web-server\/\">ESP32\/ESP8266 MicroPython Web Server \u2013 Control Outputs<\/a><\/li>\n<\/ul>\n\n\n\n<p>Learn more about the ESP8266 with our resources:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/home-automation-using-esp8266\/\">Home Automation using ESP8266<\/a><\/li>\n\n\n\n<li><a style=\"font-size: inherit; background-color: initial;\" href=\"https:\/\/randomnerdtutorials.com\/micropython-programming-with-esp32-and-esp8266\/\">MicroPython Programming with the ESP32 and ESP8266<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/projects-esp8266\/\">More ESP8266 resources&#8230;<\/a><\/li>\n<\/ul>\n\n\n\n<p>Thanks for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using a relay with the ESP8266 is a great way to control AC household appliances remotely. This tutorial explains how to control a relay module with the ESP8266 NodeMCU. We&#8217;ll &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"ESP8266 NodeMCU Relay Module &#8211; Control AC Appliances (Web Server)\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/esp8266-relay-module-ac-web-server\/#more-91808\" aria-label=\"Read more about ESP8266 NodeMCU Relay Module &#8211; Control AC Appliances (Web Server)\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":5,"featured_media":91809,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[265,214,246,300,240,264],"tags":[],"class_list":["post-91808","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-esp8266-project","category-esp8266","category-esp8266-arduino-ide","category-0-esp8266","category-esp8266-projects","category-project"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/12\/ESP8266-Relay-Module-Tutorial-project-web-server-featured.jpg?fit=1280%2C720&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/91808","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=91808"}],"version-history":[{"count":1,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/91808\/revisions"}],"predecessor-version":[{"id":168089,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/91808\/revisions\/168089"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/91809"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=91808"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=91808"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=91808"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}