You are on page 1of 25

LED CONTROL USING ESP8266 WIFI MODULE

A Mini Project-based lab report submitted to

submitted in partial fulfilment of the award of degree

BACHELOR OF TECHNOLOGY

(E.C.E)
KLEF
Submitted by:
NAME ID. No
B.SRINIVAS REDDY 170040077
By “Batch-11”
Under the esteemed guidance of
NAME OF FACULTY: Mr.K.PRAGHASH (Asst.Prof)

KLEF
Green Fields, Vaddeswaram,
Guntur Dist. -522502.

1|Page
KONERU LAKSHMAIAH EDUCATIONAL FOUNDATION
DEPARTMENT OF ELECTRONICS AND COMMUNICATION
ENGINEERING

Declaration

I Hereby declare that this project based lab report has been prepared by me in partial
fulfilment of the requirement for the award of degree “Bachelor of Engineering and
Technology in Department of Electronics and Communication Engineering” during
the academic year 2019-2020.

I also declare that this project based lab report is of my own effort and it has not been
submitted to any other university for the award of any degree.

B.SRINIVAS REDDY (170040077)

2|Page
KONERU LAKSHMAIAH EDUCATIONAL FOUNDATION

DEPARTMENT OF ELECTRONICS AND COMMUNICATION


ENGINEERING

Certificate
This is to certify that the Project Report entitled “LED CONTROL USING
ESP8266 WIFI MODULE” is being submitted by B.SRINIVAS
REDDY(170040077), in partial fulfillment for the award of Bachelor of
Technology in CSRG during the academic year 2019-20.

Project Guider Course Coordinator Head Of the Department

3|Page
ACKNOWLEGDEMENT

Apart from the efforts of ours, the success of any work depends largely on the encouragement
and guidelines of many others. We take this opportunity to express our gratitude to the people
who have been instrumental in the successful completion of this project based lab report.
We express our gratitude to our Project Guide Mr.K.PRAGHASH , Asst.Professor, Dept of
Electronics & Communications Engineering .We can’t thank him enough for tremendous
support and help. We feel motivated and encouraged every time we attend his meeting. Without
his encouragement and guidance this Project would not have materialized.
We are thankful to our Head of the Department Dr. Suman Maloji, Professor, Dept of
Electronics & Communications Engineering who modeled us both technically and morally
for achieving greater success in life.
We would like to show our greatest appreciation to Dr. N. Venkatram, Dean Academics,
KLEF for his valuable suggestions and statements.
Finally, we owe a lot to the teaching and non-teaching staff of the Dept. of ECE for their direct
or indirect support in doing our Lab based project work.

B.SRINIVAS REDDY (170040077)

4|Page
CONTENTS

SL NO. CONTENT PAGE NO:

1 ABSTRACT 6

2 INTRODUCTION 7

3 BLOCK DIAGRAM 8

4 COMPONENT SPECIFICATIONS 9-12

5 WORKING PRINCIPLE 13-18

6 CIRCUIT DIAGRAM 19

7 FLOW CHART 20

8 PSEUDOCODE 21-22

9 OUTPUT SCREENSHOTS 23-24

10 CONCLUSION 24

11 REFERENCES 25

12 FUTURE ENHANCEMENTS 25

5|Page
ABSTRACT
In this project we are going to design a switch based LED’s system using simple
hardware. It is implemented using wifi module for wireless communication and
Arduino UNO board for receiving and analysing the data. The idea behind the
project is very simple. Connect an LED to the Arduino Board. This LED must be
connected over WiFi i.e. within a local network through a Smart Phone or a
Laptop.For this, use the ESP8266 WiFi Module and interface it to Arduino
through Serial Communication. Arduino will command the ESP8266 module to
get connected to a WiFi network and receive data from the client (an HTML
page).

Based on the information sent by the client (with the help of a Web Browser), the
Arduino will either turn ON or OFF the LED.In this project we are using
switching (or) buttons for controlling the LED’s via Wifi module. The access of
changing the colours of LED’s is easy as it controlled by esp8266 wifi module.

6|Page
INTRODUCTION

The ArduinoUno is an open-source microcontroller board based on


the Microchip ATmega328P microcontroller and developed by Arduino.cc. The
board is equipped with sets of digital and analog input/output (I/O) pins that may
be interfaced to various expansion boards (shields) and other circuits.[1] The
board has 14 Digital pins, 6 Analog pins, and programmable with the Arduino
IDE (Integrated Development Environment) via a type B USB cable. It can be
powered by the USB cable or by an external 9-volt battery, though it accepts
voltages between 7 and 20 volts. It is also similar to the Arduino Nano and
Leonardo. The hardware reference design is distributed under a Creative
Commons Attribution Share-Alike 2.5 license and is available on the Arduino
website. Layout and production files for some versions of the hardware are also
available.

The idea behind the project is very simple. Connect an LED to the Arduino
Board. This LED must be connected over WiFi i.e. within a local network through
a Smart Phone or a Laptop.For this, use the ESP8266 WiFi Module and interface
it to Arduino through Serial Communication. Arduino will command the
ESP8266 module to get connected to a WiFi network and receive data from the
client (an HTML page).

Based on the information sent by the client (with the help of a Web
Browser), the Arduino will either turn ON or OFF the LED.In this project we are
using switching (or) buttons for controlling the LED’s via Wifi module. The
access of changing the colours of LED’s is easy as it controlled by esp8266 wifi
module.

7|Page
Block Diagram:-

Commands ESP8266
(Mobile) Wifi module

Transmission side

Receiver side

8|Page
Components :-

Name of component Req. No


Arduino uno 1
WIFI module (ESP 8266) 1
Remote XY (Download from play store) 1

Bread Board 1
Leds (blue) 2
Jumper wires 10

Specifications
Arduino Uno:

 Microcontroller: ATmega328P
 Operating Voltage: 5V
 Input Voltage (recommended): 7-12V
 In/out Voltage (limit): 6-20V
 Digital I/O Pins: 14 (of which 6 provide PWM output)

9|Page
 PWM Digital I/O Pins: 6
 Analog Input Pins: 6
 DC Current per I/O Pin: 20 mA
 DC current for 3.3V Pin: 50 mA
 Flash Memory: 32 KB (ATmega328P) of which 0.5 KB used by bootloader
 SRAM: 2 KB (ATmega328P)
 EEPROM: 1 KB (ATmega328P)
 Clock Speed: 16 MHz
 Length: 68.6 mm

 Arduino Uno is a microcontroller board developed by Arduino.cc which is an


open-source electronics platform mainly based on AVR microcontroller
Atmega328.
 First Arduino project was started in Interaction Design Institute Ivrea in 2003
by David Cuartielles and Massimo Banzi with the intention of providing a
cheap and flexible way to students and professional for controlling a number
of devices in the real world.
 The current version of Arduino Uno comes with USB interface, 6 analog input
pins, 14 I/O digital ports that are used to connect with external electronic
circuits. Out of 14 I/O ports, 6 pins can be used for PWM output.
 It allows the designers to control and sense the external electronic devices in
the real world.

 This board comes with all the features required to run the controller and can
be directly connected to the computer through USB cable that is used to
transfer the code to the controller using IDE (Integrated Development
Environment) software, mainly developed to program Arduino. IDE is equally

10 | P a g e
compatible with Windows, MAC or Linux Systems, however, Windows is
preferable to use. Programming languages like C and C++ are used in IDE.
 Apart from USB, battery or AC to DC adopter can also be used to power the
board.
 Arduino Uno boards are quite similar to other boards in Arduino family in
terms of use and functionality, however, Uno boards don’t come with FTDI
USB to Serial driver chip.
 There are many versions of Uno boards available, however, Arduino Nano V3
and Arduino Uno are the most official versions that come with Atmega328 8-
bit AVR Atmel microcontroller where RAM memory is 32KB.
 When nature and functionality of the task go complex, Mirco SD card can be
added in the boards to make them store more information.

ESP8266:-

Features:-
 Low cost, compact and powerful Wi-Fi Module
 Power Supply: +3.3V only
 Current Consumption: 100mA
 I/O Voltage: 3.6V (max)
 I/O source current: 12mA (max)

11 | P a g e
 Built-in low power 32-bit MCU @ 80MHz
 512kB Flash Memory
 Can be used as Station or Access Point or both combined
 Supports Deep sleep (<10uA)
 Supports serial communication hence compatible with many development
platform like Arduino
 Can be programmed using Arduino IDE or AT-commands or Lua Script

 The ESP8266 WiFi Module is a self contained SOC with integrated TCP/IP
protocol stack that can give any microcontroller access to your WiFi
network. The ESP8266 is capable of either hosting an application or
offloading all Wi-Fi networking functions from another application
processor.

 Each ESP8266 module comes pre-programmed with an AT command set


firmware, meaning, you can simply hook this up to your Arduino device
and get about as much WiFi-ability as a WiFi Shield offers (and that's just
out of the box)! The ESP8266 module is an extremely cost effective board
with a huge, and ever growing, community.

 This module has a powerful enough on-board processing and storage


capability that allows it to be integrated with the sensors and other
application specific devices through its GPIOs with minimal development
up-front and minimal loading during runtime.

12 | P a g e
Working principle
The ESP8266 module will be configured as a standalone WiFi access point. No
binding to an existing WiFi network is required for this mode of operation. To
connect, the smartphone must be connected to the created access point.
Step 1. Create a graphical user interface project
Enter the RemoteXY editor. Set one button in the smartphone field. Highlight this
button, then select the "Snap to pin" property to 13 (LED) value in the right pane
of the "Element" tab.

Step 2. Configure the project


 In the right pane, select the following settings under the "Configuration"
tab.

13 | P a g e
In the right pane, set the following settings under the "Module interface" tab.

 The settings indicate the ESP8266 to be connected to the Arduino via the
Hardware Serial (pins 0 and 1) at 115200 speed.
 The settings also specify the name of the future access point and the
password for the access point.
Step 3. Get the sketch for the Arduino
 Press the "Get source code" button.
 In the opened page with the source code of the sketch, download it to your
computer (the link "Download code") and open it in the Arduino IDE.
 Also, download the library RemoteXY (the link "Download Library") from
this page.
 The library being installed correctly, the source code for the sketch must
be compiled without errors.
 More information on installing the RemoteXY library for the Arduino IDE

14 | P a g e
Step 4. Set up the ESP8266
The ESP8266 module needs to be set up. Your module might already have the
necessary default settings, but it is better to check it.
You need to check the following:
 The module has a firmware supporting AT commands of the version no lower
than v0.40;
 The module is set up for the 115200 speed.
More information on configuring the ESP8266 to work with RemoteXY
Step 5. Connect the ESP8266 to the Arduino Uno
 Connect the ESP8266 to the Arduino Uno according to the diagram below.
Note that the RX-TX contacts are connected by a crosswire.
 Since the ESP8266 module has 3.3V signal levels and the Arduino has 5V
ones, it is necessary to use a resistive voltage divider to convert the signal
level.
Step 6: Load the sketch into the Arduino
 The sketch is loaded into the Arduino in the normal way. However,
programming is not possible because the ESP8266 module is connected to
pins 0 and 1, the compiler will show an error.
 Before programming, disconnect the wires going to the ESP8266 from
terminals 0 and 1. Fulfill programming. Then place the contacts back. Press
the Arduino reset button.
Step 7. Connect from the mobile application.
 Install the RemoteXY mobile application on your smartphone/tablet.
 Press the new connection "+" button in the top panel in the application. In
the window that opens, select the connection "WiFi access point".
 In the iOS application, go to the system settings first and connect to the
access point "RemoteXY" using the password "12345678". The connected

15 | P a g e
access point must be displayed in the opened window. Press the "Connect"
button.

 In the Android application, turn on WiFi and press the update button for a
list of available access points. Select the RemoteXY access point. In the
window that opens, enter the password for the access point "12345678",
press the "Connect" button.

16 | P a g e
If there is no connection ...
You can check the connection between the Arduino and the ESP8266 using the
Serial Monitor, which you can open in the Tools tab of the Arduino IDE.
Open the Serial Monitor and set the speed to 115200. Press the reset button on
the Arduino board.
Check for a properly loaded program
If there are no messages after the Arduino reset in the Serial Monitor, it might
mean that the Arduino will not execute your program. It is possible that:
 the sketch needed was not downloaded;
 your Arduino is not on;
 the Serial Monitor is not connected to the Arduino;
 there is something wrong with your Arduino.
Check the connection between the Arduino and the ESP8266
If you see the following sequence of commands after the Arduino reset in the
Serial Monitor, this means that the ESP8266 initialization is successful and there
is a connection between the Arduino and the ESP8266:
If you only see repeating "AT" commands, this means that there is no connection
between the Arduino and the ESP8266.

AT Commands:-

 AT
 AT+RST
 ATE0
 AT+CWMODE=2
 AT+CWDHCP=0,1
 AT+CWSAP="RemoteXY","12345678",10,4
 AT+CIPMODE=0
 AT+CIPMUX=1
 AT+CIPSERVER=1,6377

17 | P a g e
There may be no connection for various reasons. The main ones are listed below:
 RX and TX pins are not connected correctly, the contacts are reversed, or not
connected to the right contacts, or are not connected at all;
 there is no power supply to the ESP8266, when the power is supplied to the
ESP8266, the red LED must be lit;
 there is not enough 3.3 V power supply for the ESP8266;
 the ESP8266 module is defective.
 Check the ESP8266 firmware
 If after the Arduino reset in the Serial Monitor you only see the beginning
of the commands sequence, but there is no
end AT+CIPSERVER=1,6377 command, this means that the ESP8266
module has an obsolete firmware. Firmware upgrade is required.
 More information on updating the ESP8266 firmware.
 Check the power supply for the ESP8266
 Your ESP8266 might not have enough power supply. Some Arduino cards
have a weak 3.3V voltage regulator, which is not capable of delivering 200-
300mA in peak modes. In this case, you will also see a break in the
command sequence in the Serial Monitor.
 It is possible that the power connection cables are too long or too thin.
 Check the peculiarities of your smartphone
 Some models of smartphones on Android base have some peculiarities of
connecting WiFi access points, and the access point may not turn on
automatically. Try to connect to the access point manually beforehand,
using the system settings. After that, try to connect to the device from the
RemoteXY application. If in this case the connection is established, your
smartphone has that kind of peculiarity.

18 | P a g e
Circuit Diagram:-

Circuit Explaination :-
1. I have used the software serial feature of the Arduino and made its digital
pins 2 and 3 as RX and TX. These pins must be connected to TX and RX
Pins of the ESP8266 WiFi Module.

2. An LED is connected to the Digital I/O Pin 11 of the Arduino. (This is the
LED that we will be controlling over WiFi).

3. Coming to the rest of the connections with respect to the ESP8266, it’s
VCC and CH_PD pins are connected to 3.3V of the Arduino and GND is
connected to, well the GND pin of the Arduino. A Push Button is connected
between RESET of ESP8266 and GND.

4. Both the GPIO Pins of the ESP8266 i.e. GPIO0 and GPIO2 are left open
as we won’t be using those pins in this project.

19 | P a g e
Flow chart:-

20 | P a g e
PSEUDO CODE:-

#define REMOTEXY_MODE__ESP8266_HARDSERIAL_POINT

#include <RemoteXY.h>

// RemoteXY connection settings


#define REMOTEXY_SERIAL Serial
#define REMOTEXY_SERIAL_SPEED 115200
#define REMOTEXY_WIFI_SSID "RemoteXY"
#define REMOTEXY_WIFI_PASSWORD ""
#define REMOTEXY_SERVER_PORT 6377
#define REMOTEXY_ACCESS_PASSWORD "123456789"
// RemoteXY configurate
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
{ 255,2,0,0,0,42,0,8,13,0,
2,0,64,29,22,11,2,26,31,31,
79,78,0,79,70,70,0,129,0,69,
43,11,6,17,72,97,108,108,0,1,
0,24,28,12,12,2,31,88,0 };

// this structure defines all the variables of your control interface


struct {
// input variable
uint8_t switch_1; // =1 if switch ON and =0 if OFF
uint8_t button_1; // =1 if button pressed, else =0

21 | P a g e
// other variable
uint8_t connect_flag; // =1 if wire connected, else =0

} RemoteXY;
#pragma pack(pop)
#define PIN_SWITCH_1 13
#define PIN_BUTTON_1 12
void setup()
{
RemoteXY_Init ();

pinMode (PIN_SWITCH_1, OUTPUT);


pinMode (PIN_BUTTON_1, OUTPUT);

void loop()
{
RemoteXY_Handler ();

digitalWrite(PIN_SWITCH_1, (RemoteXY.switch_1==0)?LOW:HIGH);
digitalWrite(PIN_BUTTON_1, (RemoteXY.button_1==0)?LOW:HIGH);

22 | P a g e
Output Screenshots:-

(i) Circuit set-up using above diagram

(ii)When we press the normal button we can see the light turned on.
This light may be present in hall.

23 | P a g e
(iii) When we press the switch then we can see that the other light is
turned on and we can say it as in Bed room light.

Conclusion:-
In this project we had designed a switch based LED’s system using simple
hardware. It is implemented using wifi module for wireless communication and
Arduino UNO board for receiving and analysing the data. Based on the
information sent by the client (with the help of a Web Browser), the Arduino will
either turn ON or OFF the LED.In this project we are using switching (or) buttons
for controlling the LED’s via Wifi module. The access of changing the colours of
LED’s is easy as it controlled by esp8266 wifi module.

24 | P a g e
References:-
1. https://create.arduino.cc/projecthub/msr048/controlling-leds-via-esp8266-
18d3b0
2. http://remotexy.com/en/help/start/arduino-esp8266-ss/
3. https://goo.gl/XjmCJE
4. https://www.youtube.com/watch?v=fC88c49dHsw

Future enhancements
 We can place different kinds of LED’s and different switching methods
can be implemented.
 We can use our project in many applications like in Home
applications,industrial applications etc.
 By using Bluetooth there is a chance of losing the connection as when
we replace it with the IOT there is no chance of losing the connection.
 By using IOT there is no limitation range for controlling the RGB
LED’s we can operate it from anywhere.

25 | P a g e

You might also like