Login

Controlling NodeMCU using Blynk app

Objectives

  • Control onboard LED on NodeMCU using the Blynk app.
  • Connecting the RGB LED module to NodeMCU and control the digital pins.

Things

  1. NodeMCU board (quantity: 1 no.)
  2. Micro USB cable A to B (quantity: 1 no.)
  3. Breadboard (quantity: 1 no.)
  4. RGB LED module (quantity: 1 no)
  5. Jumper wire (quantity: 4 no)
  6. Mobile phone (quantity: 1 no)
  7. Arduino IDE on your computer

Let’s begin!

Setting up Blynk app

Step 1: Download the Blynk app from your  app store.

Step 2: Enter the name of your Project. Select the board as NodeMCU. Make a note of the Auth token. You will need it in the code. Click OK on the top.

 

Setting up Arduino IDE

Install Blynk Library on the Arduino IDE by downloading the Blynk Library from Sketch->Include library->Manage libraries..

Blynk library

 

Controlling the onboard LED in NodeMCU

In the Blynk app

Step 1: You will be taken to a blank dashboard. Click on it to add components. Select a  button to add it to the dashboard.

Step 2: – Click on the button to edit it. Set PIN D0.

Step 3: Click on D0.

Step 4: Click on the Play button to start the connection.

Step 5: Click the button ON and OFF to control the LED.

 

Final Code

To copy the code, right click on view raw at the bottom of the code, click on open link in new tab and then copy the code.

Uploading the code

Step 1: Enter the final code in the Arduino IDE window.

  • When you click on New to open a new blank code in the Arduino IDE, you will get a new window with two functions: void setup() and void loop()
  • You can either type commands as shown in the final code under void setup() and void loop() functions or
  • Delete the contents of this window. Then copy and paste the final code in the Arduino IDE window.

Step 2: Compile/ verify the code by clicking on the verify button.

  • Make sure the board is connected to your computer
  • Check if the correct board and port is selected.

Step 3: Upload the code by clicking on the upload button, which is right next to the verify button.

  • The Arduino IDE provides a progress bar when it’s uploading.
  • After it is done, you will see “Done uploading” on the bottom left of your IDE.
  • If you encounter any errors, you need to go back to the code and fix the errors.

There you go!

After uploading the code, on-board Blue LED blink control by ON & OFF button  Notice that the LED stays ON when you click on the ON button and LED stays OFF when you click on OFF button.

 

Let’s begin the next experiment!

Controlling RGB LED module with NodeMCU using Blynk app

Interfacing RGD LED module with NodeMCU

 

Step 1: You will be taken to a blank dashboard. Click on it to add components. Select a D5 button to add it to the dashboard.

Step 2: Select a D6 button to add it to the dashboard

Step 3: Click on it to add components. Select a D7 button to add it to the dashboard

Step 4: Click on the Play button to start the connection. Clicking the buttons will control the LED.

 

Final Code

To copy the code, right click on view raw at the bottom of the code, click on open link in new tab and then copy the code.

Uploading the code

Step 1: Enter the final code in the Arduino IDE window.

  • When you click on New to open a new blank code in the Arduino IDE, you will get a new window with two functions: void setup() and void loop()
  • You can either type commands as shown in the final code under void setup() and void loop() functions or
  • Delete the contents of this window. Then copy and paste the final code in the Arduino IDE window.

Step 2: Compile/ verify the code by clicking on the verify button.

  • Make sure the board is connected to your computer
  • Check if the correct board and port is selected.

Step 3: Upload the code by clicking on the upload button, which is right next to the verify button.

  • The Arduino IDE provides a progress bar when it’s uploading.
  • After it is done, you will see “Done uploading” on the bottom left of your IDE.
  • If you encounter any errors, you need to go back to the code and fix the errors.

There you go!

After uploading the code, the RGB LED blinks red when you click on the button D5 , green and blue colors in sequenc by click on the D6 &D7 button. Clicking the button will control the RGB module.

Let’s begin the next experiment!

Reading analog sensor values with NodeMCU using Blynk app

Interfacing IR sensor module (analog) with NodeMCU

 

Step 1: You will be taken to a blank dashboard. Click on it to add components. Select a button to add it to the dashboard

Step 2: To get analog sensor data, we can use a Level H or Level V meter or a Guage. We can link it to pin A0

Step 3: Now  we can link it to pin A0

Step 4: The output of the sensors will appear as follows

 

Final Code

To copy the code, right click on view raw at the bottom of the code, click on open link in new tab and then copy the code.

Uploading the code

Step 1: Enter the final code in the Arduino IDE window.

  • When you click on New to open a new blank code in the Arduino IDE, you will get a new window with two functions: void setup() and void loop()
  • You can either type commands as shown in the final code under void setup() and void loop() functions or
  • Delete the contents of this window. Then copy and paste the final code in the Arduino IDE window.

Step 2: Compile/ verify the code by clicking on the verify button.

  • Make sure the board is connected to your computer
  • Check if the correct board and port is selected.

Step 3: Upload the code by clicking on the upload button, which is right next to the verify button.

  • The Arduino IDE provides a progress bar when it’s uploading.
  • After it is done, you will see “Done uploading” on the bottom left of your IDE.
  • If you encounter any errors, you need to go back to the code and fix the errors.

There you go!

After uploading the code, To get analog sensor data, we can use a Level H or Level V meter or a Guage. We can link it to pin A0 and output will appear on the app screen.

 

 

 

 

We would love to see what you build out of these learnings!

Click here to submit your projects, share it with the world and stand a chance to be rewarded.

top

Knowledge and Content by Li2 Technologies | © 2021 NASSCOM Foundation | All rights reserved

X