Mod.Intemnet of Things
Node MCU Pinout — ESP8266 12E
WIFI Antenna
ESP8266-12E
CECE
eK
USB Serial
Cireuit Connection
Attach NodeMCU on Breadboard.
Connect VCC of Relay with Pin 3.3V of NodeMCU.
Connect GND of Relay with GND of NodeMCU
Connect Pin Signal of Relay with Pin D7 (GPIO 13) of NodeMCU
Connect one terminal of Bulb (Blue Wire) with Pin NC (Normally Close) of Relay.
© Connect one terminal of Adapter with Pin C (Common) of Relay.
‘© Connect the other terminal of Bulb (Red Wire) with another terminal of Adapter.
Electronics & Telecommunication Engineering, MMCOE, Pune-52. PageMod.Intemnet of Things
Interfacing Diagram
Code:
code senal pint)
include
dstatpentne
Serial prntin WiFi connectee’
cconst char" ssi
const char" pass
1 Stan the server
serve begin);
int ledPin = 13; 1! GPIC Serial printin Server started”
WiFiServer server(80),
/1 Prin the IP address
void setup) { ‘Sefial prinUse this URL to comect.
Serial bogin( 115200); Serial print:
delay(10} Serial prt (MF locallPO}:
Serial prin’
pinMode(tedPin, OUTPUT)
digitalWnite(ledPin, LOW), }
Connect to WiFi network vost Jone
Serial printing
Sana printin(
Serial prnt((Connectng to"
Senial printin(ssid)
nt has connected
= server avalable(y
WiFi begin(ssid, password)
Val unt ie client sends some data
Serial prntin’ new client’)
while (WiFi status() = WL_CONNECTED){ ——whila(eient avaitabla()t
dalay(500) celay(‘)
}
Electronics & Telecommunication Engineering, MMCOE, Pune-52. PageMod.Internet of Things BEE&TC
1 Read the frst ine ofthe request
‘Sting request = clentreadStingLnil(\r);
Seria prntin(request),
bent Mush,
Match the request
intvaue = LOW;
if (request indexO1/LED=ON") = 1) {
digitalWritefedPin, LOW)
value = LOW,
i
In (request indexO1CLED=OFF*)I=-1) ¢
digitalWirte(odPin, HGH);
value = HIGH
+
1 Set ledPin according to the request
UdigitaWrte(edPin, vakie)
1 Returnthe response
lent printn HTTF/1.1 200 OK);
client printin( Gentent-Typo: toxthtmi)
cent printin(“) (1 do not forget this one
client pritin(",
cent printin(-
"
cent pritin( <2 nref=1"/LED=ONI""">