IOT application with the ESP826-01: Wi-Fi control of a led lamp

Software programmed in the ESP8266-01:


This is the continuation of the IOT theme that we have been developing so far.

On this occasion we wanted to develop a practical and useful project with the ESP8266-01. It is an LED lamp with on / off and intensity control via Wi-Fi, using an Internet IP address and an Android application made with APP Inventor.

The previous program can be used and / or modified without any restriction.

Designed Hardware:


In this project it has been elaborated:
1.               Development plate for the ESP8266 (own). On this board the ESP8266-01 is mounted and it allows to connect its outputs to the UART interface and the GPIO ports.
2.               Power supply plate + 3.3V @ 300 mA. (own) It serves as a regulator from 5V to 3.3 V, provides current and stability.
3.               DC-DC plate type boost converter : 5/12 V @ 300 mA. (own) This plate serves as a control module and power to light the 3W LED lamp (300 lumens), which operates with a working voltage between 9-12 V.



The developed card (figure 2) has the protection resistors for the serial connection, jumper- type selectors to choose the working modes ( flash or boot ) and reset, direct outputs of ports GPIO 00 and 02, outputs to open collector o open collector r to handle loads of up to 200 mA directly, two led indicators to indicate the status of the GPIO ports (negative logic) and pin type connectors that allow the connections of the serial cable and the GPIO ports to the outside . 

The electronic scheme of this card is presented in figure:
Electronic Device Designing

This board or card must be powered by a 3.3 V supply that supplies at least 300 mA.
Using this card and a personal computer with OS Windows 8.1 and Arduino IDE (see 1.8) has been loaded into the ESP8266-01 program already indicated above.
The aforementioned program configures the ESP8266-01 in server mode + access point (STA + AP), thus allowing it to connect to an Internet network through a router , the connection is made using an already known login and password , and which are used each time the module is started to connect to the default local network with Internet access.

Once the ESP8266-01 module is connected, it activates port 80 as a server (STA) and sends its IP by serial console. This IP is the one used later to send and / or receive requests from and to the module. 

To control from Internet must first access the router and address ( port forwarding ) port 80 to the IP address of the server (ESP8266-01). In this way, the commands to be sent and / or received through an Internet IP are redirected. See: Electronic Device Designing.

From this point the program pulls in an infinite loop or loop listening to port 80. If there are messages through HTML, they are received and decoded, if it corresponds with some expected command, the action is executed in the GPIO ports and a notification is sent back to the client in HTML format.

The previous algorithm is repeated successively during the time that the ESP8266-01 is connected to the network.

Control App (Andorid) client:

An additional program developed using the MIT Invertor App  (which has already been discussed in this blog), allows you to design an Android app that executes commands via Wi-Fi, between your phone or tablet and the ESP8266-01 module. The program allows you to use a local IP or Internet IP to remotely access the lamp control.
The control of the lamp consists of being able to turn on / off and adjust three power levels: 25, 50, 75 percent of the maximum.
To achieve the levels of 25, 50 and 75% we use the pulse width modulation technique, known as PWM ( pulse width modulation ). The base frequency is 1kHz.

Comments