IoT led
Now controlling devices through internet / mobile app is easy. With the help of Blynk IoT platform and ESP-01 module.
STEP 1 - Gather these components
- CP2102 USB to UART module.
- ESP-01 module.
- LED
- Push Switch
- 220ohm resistor
- Jumper wires (female to male) , single core breadboard wire, breadboard.
STEP 2 - Make connections as per circuit.
STEP 3 - Create Blynk account.
1. Go to Blynk website and click on "log in".
2. Click on create new account.
3. Enter your email id.
The Blynk account is now created.
STEP 4 - Creating Blynk Template.
1. Click on the "square grid like icon" that's for template and create new template.
4. Create a Blynk Datastream , we are going to use a "virtual pin", that's like a space in Blynk server to store our switch state (0 or 1) data.
5. Give name to virtual pin, select Pin - V0, Datatype - Integer, min - "0" , max - "1", Click on create.
6. Create a web dashboard , add new widget like switch, guage, slider. We are going to use a switch widget. Drag and place the switch and go to it's settings.
7. Give name to the switch widget as switch and link Datastream V0 to our widget. eg - It's like attaching string to a puppet.
STEP 5 - Getting the Arduino IDE to upload the Blynk IoT code.
1. To add ESP boards to Arduino IDE. open Arduino IDE >> file >> preference
2. Copy and paste below given link in additional board manager URL's
http://arduino.esp8266.com/stable/package_esp8266com_index.json
Then click on "Manage libraries".
8. Replace the example code with the below given code. Many blynk header files will also open, don't close them.
*note - Copy the template name and template id and paste it at the top of the code provided by Blynk when we created the template.
code:-
#define BLYNK_TEMPLATE_ID " " // Copy and paste the template id from blynk template
#define BLYNK_TEMPLATE_NAME " " // Copy and paste the template name from blynk template
#define BLYNK_FIRMWARE_VERSION "0.1.0"
#define BLYNK_PRINT Serial
#define APP_DEBUG
#include "BlynkEdgent.h"
// Uncomment your board, or configure a custom board in Settings.h
//#define USE_SPARKFUN_BLYNK_BOARD
//#define USE_NODE_MCU_BOARD
//#define USE_WITTY_CLOUD_BOARD
//#define USE_WEMOS_D1_MINI
int led = 2; //D2 on the board
BLYNK_WRITE(V0) // Executes when the value of virtual pin 0 changes
{
Serial.println(param.asInt());
if(param.asInt() == 1)
{
digitalWrite(led,HIGH);
}
else
{
digitalWrite(led,LOW);
}
}
void setup()
{
Serial.begin(115200);
pinMode(led,OUTPUT);
delay(100);
BlynkEdgent.begin();
}
void loop() {
BlynkEdgent.run();
}
// end of code9.Now "save as" the code give it another name (eg - "IoT led") a new sketch will open.
Close the example code. Connect the CP2102 to the COM port. Select the board
"generic esp8266" and COM port.
If the board is connected it will show "Generic ESP8266 on COM ". This video will show
you how to upload program in ESP-01 module.
NOW CLICK ON UPLOAD.
STEP 6 - Creating Blynk device using Blynk app. Watch the below given video
If you found this blog useful and want to support me, then you can donate me. The money you give will be used to make more advance electronics projects and setting up better lab.

Comments
Post a Comment