0% found this document useful (0 votes)
70 views11 pages

Smart Home

This document describes an ESP32 smart home project that implements LED blinking controlled by a Blynk mobile app. The project connects an LED and resistor to an ESP32 board. Code is written to blink the LED and integrate it with Blynk widgets using callbacks. Users can then control the LED state with a switch and adjust the blink interval with a slider in the Blynk app connected to the ESP32 over WiFi.

Uploaded by

Seth Rathanak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views11 pages

Smart Home

This document describes an ESP32 smart home project that implements LED blinking controlled by a Blynk mobile app. The project connects an LED and resistor to an ESP32 board. Code is written to blink the LED and integrate it with Blynk widgets using callbacks. Users can then control the LED state with a switch and adjust the blink interval with a slider in the Blynk app connected to the ESP32 over WiFi.

Uploaded by

Seth Rathanak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Smart Home

Lectured: Dr. Chou Koksal

Name:

1. SOMBATH SOKUN ID: e20200991

2. PAO MENGHEANG ID:

3. OUN VANTHA ID:

4. PRUM VISAL ID:

5. SETH RATHANAK ID: e20200160


Title: Report on ESP32 LED Blink, Blynk Switch, and Blynk Slider

Contents:

I. Introduction:
II. Equipment
III. Blynk Setup:
IV. LED Blink Code with Blynk Integration:
V. Explanation:
VI. Uploading and Testing:
VII. Conclusion:
I. Introduction:

• The ESP32 is a popular microcontroller widely used for Internet of Things (IoT) applications.
In this report, we will discuss how to implement LED blinking on the ESP32 using the Blynk platform.
Additionally, we will explore the integration of Blynk switches and sliders to control the LED.
II. Equipment

• Hardware Setup:
• To implement the LED blink project with Blynk, the following hardware components are required:
- ESP32 development board
- LED (any color)
- Resistor (usually 220 ohms)
- Breadboard
- Jumper wires
• Software:
- Arduino IDE

• The LED and resistor are connected in series with the ESP32 GPIO pin, similar to the setup for regular LED blinking.
III. Blynk Setup:

• Blynk is a platform that allows for the creation of IoT applications through a smartphone app. To set up
Blynk for the ESP32 LED blink project, follow these steps:
- Download the Blynk app from the iOS App Store or Google Play Store.
- Create a new Blynk account or log in if you already have one.
- In the Blynk app, create a new project and obtain an authentication token.
- Add the necessary widgets (switch and slider) to the project interface.
IV. LED Blink Code with Blynk Integration:

• To incorporate Blynk functionality into the LED blink project, we need to modify the code. The following code snippet
demonstrates how to control the LED using a Blynk switch and adjust the blink interval with a Blynk slider:
•#define BLYNK_TEMPLATE_ID "TMPL66HpozyZ1"
•#define BLYNK_TEMPLATE_NAME "LED Brightness"
•#define BLYNK_AUTH_TOKEN "dp0q3hEsowfJO_dFVCy46i0SMvVvMMwS"

•#include <WiFi.h>
•#include <WiFiClient.h>
•#include <BlynkSimpleEsp32.h>

•//Set youe blynk auth token
•char auth[] = BLYNK_AUTH_TOKEN;

•//Set your WIFI credentials
•char ssid[] = "YourWIFISSID";
•char pass[] = "YourWIFIPassword";

•BlynkTimer timer;

•const int freq = 5000;
•const int ledChannel = 0;
•const int resolution = 8;

•//Set the LED pin
•int LED = 15;

•void setup() {
• ledcSetup(ledChannel, freq, resolution);
• ledcAttachPin(LED, ledChannel);
•//connect blynk
• Blynk.begin(auth, ssid, pass);
•}

•void loop() {
• Blynk.run();
• timer.run();
•}
•BLYNK_WRITE(V0) {
• int data = param.asInt();
• int pwmWave = map(data, 0, 4095, 0, 255);
• ledcWrite(ledChannel, pwmWave);
V. Explanation:

• The code begins by including the necessary libraries (WiFi, WiFiClient, BlynkSimpleEsp32) and defining
the required constants. The auth, ssid, and pass variables need to be replaced with your Blynk
authentication token and Wi-Fi credentials.

• In the setup() function, the LED pin is configured as an output, and the Blynk connection is established
using Blynk.begin().

• The loop() function runs the Blynk code and controls the LED blinking. The LED turns on, waits for the
specified interval (`blinkInterval`), turns off, and then waits again.

• The BLYNK_WRITE(SWITCH_PIN) function is a Blynk callback that is triggered when the switch
widget state changes. It reads the switch status and controls the LED accordingly.
• The BLYNK_WRITE(SLIDER_PIN) function is another Blynk callback triggered when the slider widget value changes. It
reads the slider value and updates the blinkInterval variable.

VI. Uploading and Testing:

• To upload and test the code on the ESP32 board, follow these steps:
- Connect the ESP32 board to your computer using a USB cable.
- Ensure that the correct board and port are selected in the Arduino IDE.
- Click on the "Upload" button to compile and upload the code to the ESP32 board.
- Once the code is uploaded, open the Blynk app on your smartphone and connect to your project using the
authentication token.
- Use the switch widget to control the LED state and the slider widget to adjust the blink interval.
VII. Conclusion:

• By integrating Blynk into the ESP32 LED blink project, we can control the LED using a smartphone app. The
Blynk switch allows for turning the LED on and off, while the Blynk slider enables adjusting the blink
interval. This report has provided the necessary code and instructions to successfully implement LED
blinking with Blynk on the ESP32, offering a foundation for more advanced IoT projects and remote control
applications.
Equipment:

Jumper Wire Breadboard ESP32

Resistance LED

You might also like