0% found this document useful (0 votes)
5 views27 pages

MNU ICI334 Lab2

The document provides a comprehensive guide on using the Arduino IDE for programming the NodeMCU ESP8266, including installation steps for necessary drivers and the creation of basic projects like blinking an LED and using a photoresistor. It details the structure of Arduino sketches, emphasizing the setup() and loop() functions, and outlines the components and steps needed for a photoresistor project. Additionally, it includes instructions for connecting components and writing code for the projects.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views27 pages

MNU ICI334 Lab2

The document provides a comprehensive guide on using the Arduino IDE for programming the NodeMCU ESP8266, including installation steps for necessary drivers and the creation of basic projects like blinking an LED and using a photoresistor. It details the structure of Arduino sketches, emphasizing the setup() and loop() functions, and outlines the components and steps needed for a photoresistor project. Additionally, it includes instructions for connecting components and writing code for the projects.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

IOT Protocols

Dr. Abdelwahab Fawzy


ECE, Faculty of Electronic Engineering, Menoufia University
ICI334 IOT Protocols Dr. Abdelwahab Fawzy

Overview

Arduino IDE

Installing NodeMCU ESP8266 in Arduino IDE

Installing NodeMCU CH340 Driver & CP2102 Driver

Sketches

Your First NodeMCU Project: Blinking the On-board LED

Photoresistor Project: Circuit & Components

2
ICI334 IOT Protocols Dr. Abdelwahab Fawzy

Arduino IDE
• The Arduino IDE enables you to write and edit code and convert this code into instructions that NodeMCU
hardware understands.

3
ICI334 IOT Protocols Dr. Abdelwahab Fawzy

Installing NodeMCU ESP8266 in Arduino IDE


• First, open the Arduino IDE and go to File → Preferences.

4
ICI334 IOT Protocols Dr. Abdelwahab Fawzy

Installing NodeMCU ESP8266 in Arduino IDE


• On the Additional Boards Manager URLs, paste the following URL.
https://arduino.esp8266.com/stable/package_esp8266com_index.json

5
ICI334 IOT Protocols Dr. Abdelwahab Fawzy

Installing NodeMCU ESP8266 in Arduino IDE


• Now go to Tools → Board → Boards Manager.

6
ICI334 IOT Protocols Dr. Abdelwahab Fawzy

Installing NodeMCU ESP8266 in Arduino IDE


• Search ESP8266 and install esp8266 by ESP8266 community.

7
ICI334 IOT Protocols Dr. Abdelwahab Fawzy

Installing NodeMCU CH340 Driver & CP2102 Driver

• Now, connect your NodeMCU ESP8266, and install the CH340 Driver. • Install the CP2102 Driver.

8
ICI334 IOT Protocols Dr. Abdelwahab Fawzy

Sketches
• A sketch is the name that Arduino uses for a program.

• There are two special functions that are a part of every Arduino sketch: setup() and loop().
• The setup() is called once when the sketch starts.
• It’s a good place to do setup tasks like setting pin modes.
• The loop() function is called over and over and is the heart of most sketches.
• You need to include both functions in your sketch, even if you don’t need them for anything.

9
ICI334 IOT Protocols Dr. Abdelwahab Fawzy

Your First NodeMCU Project: Blinking the On-board LED


• Turn the on-board LED on and off every second.
• The following is the GPIO Code

10
ICI334 IOT Protocols Dr. Abdelwahab Fawzy

Your First NodeMCU Project: Arduino AVR Boards


• Now go to Tools → Board → ESP8266 Boards.
• Select NodeMCU 1.0 (ESP-12E Module).

11
ICI334 IOT Protocols Dr. Abdelwahab Fawzy

Your First NodeMCU Project: Port


• Go to Tools → Port and select the port of your NodeMCU board.

12
ICI334 IOT Protocols Dr. Abdelwahab Fawzy

Your First NodeMCU Project: Upload a Sketch


• Click the Upload button to program your NodeMCU with the sketch.

13
ICI334 IOT Protocols Dr. Abdelwahab Fawzy

Analog vs. Digital Signals

14
ICI334 IOT Protocols Dr. Abdelwahab Fawzy

Reading Analog Voltage

• The ESP8266-12E module has one ADC pin.


• The ADC pin has a 10-bit resolution, which means you’ll get values between 0 and 1023.

15
ICI334 IOT Protocols Dr. Abdelwahab Fawzy

Photoresistor (Light Sensor)


• The photoresistor is a light-sensitive, variable resistor.
• Photoresistors are perfect for making light-controlled switches.

16
ICI334 IOT Protocols Dr. Abdelwahab Fawzy

Photoresistor: Circuit & Components

❑ Components
1) NodeMCU ESP8266 V3
2) LED
3) Photoresistor
4) 330Ω Resistor
5) 10KΩ Resistor
6) Jumpers
7) Breadboard

17
ICI334 IOT Protocols Dr. Abdelwahab Fawzy

Photoresistor: Steps
1) Connect breadboard power (+) and ground (-) rails to NodeMCU 3.3V and GND, respectively.

18
ICI334 IOT Protocols Dr. Abdelwahab Fawzy

Photoresistor: Steps
2) Drag a photoresistor to your breadboard, so its legs plug into two different rows.

19
ICI334 IOT Protocols Dr. Abdelwahab Fawzy

Photoresistor: Steps
3) Create a wire connecting one photoresistor leg to power.

20
ICI334 IOT Protocols Dr. Abdelwahab Fawzy

Photoresistor: Steps
4) Drag a 10KΩ resistor to connect the other photoresistor leg to the ground.

21
ICI334 IOT Protocols Dr. Abdelwahab Fawzy

Photoresistor: Steps
5) Connect the photoresistor leg that is connected with the ground to the NodeMCU A0 pin.

22
ICI334 IOT Protocols Dr. Abdelwahab Fawzy

Photoresistor: Steps
6) Plug the LED into two different breadboard rows.

23
ICI334 IOT Protocols Dr. Abdelwahab Fawzy

Photoresistor: Steps
7) The cathode (shorter leg) connects to one leg of a resistor of 330Ω, and the other resistor leg to the ground.

24
ICI334 IOT Protocols Dr. Abdelwahab Fawzy

Photoresistor: Steps
8) Wire up the LED anode (longer leg) to NodeMCU pin D1.

25
ICI334 IOT Protocols Dr. Abdelwahab Fawzy

Photoresistor: Code

26
[email protected]

You might also like