Internet of Things-IoT                    Blynk+NodeMCU ESP8266
Robotics Family 2018-2019

Internet of Things-IoT Blynk+NodeMCU ESP8266

No alt text provided for this image

How it works

An IoT system consists of sensors/devices which “talk” to the cloud through some kind of connectivity. Once the data gets to the cloud, software processes it and then might decide to perform an action, such as sending an alert or automatically adjusting the sensors/devices without the need for the user.

No alt text provided for this image

IoT Advantages

No alt text provided for this image

IoT Cloud Platforms

No alt text provided for this image

IoT Hardware Platforms

No alt text provided for this image

Project Description

It is a digital conversation between the IoT hardware platform (NodeMCU ESP8266) and the IoT Cloud platform (Blynk application on the android tablet).

The NodeMCU is physically connected to a DHT11 Temperature/Humidity sensor through digital pin 5(GPIO 14), a COB LED panel through a relay on digital pin 7(GPIO 13), and a mini Fan through a relay on digital pin 8 (GPIO 15).

The Temperature/Humidity sensor detects the temperature and humidity levels and sends them to the Blynk application through the Blynk cloud server. The Blynk application will display the temperature and humidity values using a digital gauge and labeled value display.

No alt text provided for this image

DHT11 > NodeMCU > Blynk server > Blynk application on the android tablet

The process of controlling the appliances is done in the opposite way. The COB Led panel and the mini Fan will turn on or off accordingly when the push buttons on the Blynk interface are pressed.

No alt text provided for this image

Button pressed (on the tablet)> Blynk server > NodeMCU > Relay > Light/Fan

The Implementation

Computer science IGCSE Students from grades 9 and 10 had many practical sessions on how to program the NodeMCU and setup the Blynk application on their tablets. They practiced in school, and had to complete some individual tasks on how to read sensors' values through the serial monitor by their own. Robotics family provided the students with the required hardware, tutorials, and support in order to improve their self learning skills.

No alt text provided for this image

Required Hardware/Appliances

  • NodeMCU ESP8266
  • DHT11 Temperature/Humidity sensor
  • 2 Channel relay
  • 12V COB led panel
  • 12V Fan
  • Android Tablet
  • 12V Power supply(adapter or battery)

Mobile Application

  • Blynk IoT platform

Schematics and connections

No alt text provided for this image

Blynk Setup

No alt text provided for this image
No alt text provided for this image

Full tutorial on how to setup the interface can be found on the Blynk official website

The Code

#include <DHT.h> // import the DHT library 
#include <ESP8266WiFi.h> // import the ESP8266WiFi library
#include <BlynkSimpleEsp8266.h> // import the BlynkSimpleEsp8266 library
DHT dht(14, DHT11); // create dht instance of the class DHT with two arguments (connection pin, DHT sensor type))
BlynkTimer timer;  // create BlynkTimer instance of the class timer

char auth[] = "c52*****25ce"; // your Blynk Auth Token
char ssid[] = "******";      // Your wifi ssid
char pass[] = "********";   // your password


void setup()
{
  pinMode(13,OUTPUT);  // relay GPIO 13 (Light) set as output pin
  pinMode(15,OUTPUT); // relay GPIO 15 (Fan) set as output pin
  digitalWrite(13, LOW);  // Turn off the light
  digitalWrite(15, LOW); // Turn off the fan

  Blynk.begin(auth, ssid, pass); // start the communication with blynk server
  dht.begin(); // start reading from the dht11 sensor
  timer.setInterval(1000L, sendSensor); //calls the sendSensor function at specified time interval
}


void loop()
{
  Blynk.run();  // execute the Blynk function
  timer.run(); // execute the timer function
}


void sendSensor() // a function that reads the dht11 values and sends them to the virtual pins
{
  float h = dht.readHumidity();     //read the humidity value and assign it to 'h'
  float t = dht.readTemperature(); //read the temperature value and assign it to 't' 
  Blynk.virtualWrite(V4, t);      // send the value of 't' to virtual pin 4
  Blynk.virtualWrite(V3, h);     // send the value of 'h' to virtual pin 3
}


BLYNK_WRITE(V1) //execute the BLYNK_WRITE function on virtual pin 1
  {
  int pinValue = param.asInt();// read the state of light button 
  if (pinValue == 1)          // if 1 (pressed)
    {
    digitalWrite(13, HIGH);  //turn on the light (turn on relay on GPIO 13)
    }
  else 
    {
    digitalWrite(13, LOW);  //turn off the light (turn on relay on GPIO 13)
    }
  }


  BLYNK_WRITE(V2) // execute the BLYNK_WRITE function on virtual pin 2
  {
  int pinValue2 = param.asInt(); // read the state of fan button 
  if (pinValue2 == 1)           // if 1 (pressed)
    {
    digitalWrite(15, HIGH);    //turn on the light (turn on relay on GPIO 15)
    }
  else
    {
    digitalWrite(15, LOW);    //turn off the light (turn on relay on GPIO 15)
    }
  }
No alt text provided for this image

The presentation

The IoT concept and project were introduced and presented at Robotics Family's annual robotics fair. Yorgo and his Team made an outstanding presentation. Parents, staff, and attendees were Amazed by the achievement, proving again that our students are in parallel with present and future technologies.

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image



To view or add a comment, sign in

More articles by Zahi Wehbe

  • RVIS and the Massachusetts Institute of Technology (MIT) Host a successful MISTI program

    RVIS and the Massachusetts Institute of Technology (MIT) Host a successful MISTI program

    Final Picture of participants with the MIT Instructors Riffa Views International School (RVIS) and The American…

    1 Comment
  • Riffa Views International School and The American University of Bahrain Partner with the Massachusetts Institute of Technology (MIT)

    Riffa Views International School and The American University of Bahrain Partner with the Massachusetts Institute of Technology (MIT)

    Riffa Views International School (RVIS) and the American University of Bahrain (AUBH) announced their partnership with…

    1 Comment
  • Automated Light Tracking Solar Panel

    Automated Light Tracking Solar Panel

    One major advantage with the use of renewable energy is that as it is renewable, it is sustainable and so will never…

  • Facial Recognition System

    Facial Recognition System

    Choosing the right biometric security solution has become a major decision for businesses, across industries. Yet, with…

  • Automated Greenhouse System

    Automated Greenhouse System

    One of the best things about owning a greenhouse is that you can use it for a variety of things. You can grow fresh…

    2 Comments
  • Bionic Prosthetic hand

    Bionic Prosthetic hand

    Bionic prosthetic hands are rapidly evolving. An in-depth knowledge of this field of medicine is currently only…

    2 Comments
  • Alex the humanoid robot

    Alex the humanoid robot

    Alex the humanoid robot is a STEAM Project designed and implemented by grade 10 students. It is the second generation…

    4 Comments
  • E.R.A.S.E.R

    E.R.A.S.E.R

    Eco-friendly Radio-controlled Autonomous Solar Equipped Rover - by Robotics Family 2018. Robotics Family's pride! Third…

    1 Comment
  • RoboCodingClub - Grades 4 to 7 Club

    RoboCodingClub - Grades 4 to 7 Club

    The future is already here! RoboCodingClub is a Coding and Robotics club intended to prepare our students for future…

  • MR. ROBOT 1.0

    MR. ROBOT 1.0

    Robotics Family's first ever Robot. A project implemented by grade 12 Computer Science AP students in 2017.

Insights from the community

Others also viewed

Explore topics