Showing posts with label ESP8266 Projects. Show all posts
Showing posts with label ESP8266 Projects. Show all posts

IOT Robot with NodeMCU and Arduino using Blynk.

Introduction:

Controlling robots wirelessly is great fun. There are many methods available through which you can control your robot wirelessly.
They are:
  1.  RF remote controller
  2.  Bluetooth signal
  3.  IR signal
  4.  Wifi or IOT etc...
Here I have made a project of robot controlled over IOT using blynk app,arduino and nodemcu.

Things needed

  • Arduino
  • Nodemcu(Esp8266)
  • 2 DC motors and Motor driver
  • LCD display(may or may not added)
  • Batteries or any other power source
  • Blynk Application 
  • Jumper wires etc.

Step 1: Building the Body of Robot

I Build the robot with Sun-board and card board gluing them with super glue. I used old mobile batteries as source and stick them to body. here are some pictures of my build.


Step 2: Connection of different elements

  • Connect two dc motors to the motor driver. for more about motor drivers follow this:https://www.ganeshgadgets.co.in/2017/09/line-follower-part-2-motor-driver.html
  • Connect arduino to the motor driver. use enable of motor driver with PWM inputs of arduino.
  • Power up nodemcu with arduino from 5v pin. Here the idea is when arduino receives digital output from nodemcu at its input pins it would do certain actions.
  • 5 outputs from nodemcu(D0-D4) is fed to 5 pins of arduino(A0 toA5 -here digital pins are used so pin 14 to pin 19).
  • Example when D0 of nodemcu is high, Arduino receives signal and command noter driver to go forward. 
Code example:
if ( digitalRead(a0) == HIGH ) //forward//
 {
  lcd.setCursor(0, 1);
  lcd.print("FORWARD ");
  digitalWrite(af, HIGH);
  digitalWrite(ar, LOW);
  digitalWrite(bf, HIGH);
  digitalWrite(br, LOW);
 }

                   Step 3: Programming Nodemcu and Arduino

                  Code:
                  #include <LiquidCrystal.h>
                  LiquidCrystal lcd(8, 9, 10, 11, 12, 13); //16x2 lcd interface

                  int en = 3;//a-right motor  b-Left motor //
                  int af = 6;int ar = 7;
                  int bf = 5;int br = 4;

                  int a0=14 , a1=15 , a2= 16 ,a3= 17, a4= 18;//from nodemcu D0 to D4//

                  void setup() {
                  lcd.begin(16, 2); 

                   pinMode(en,OUTPUT);
                   pinMode(ar,OUTPUT);pinMode(af,OUTPUT);
                   pinMode(bf,OUTPUT);pinMode(br,OUTPUT);

                   pinMode(a0,INPUT); pinMode(a1,INPUT); pinMode(a2,INPUT);
                   pinMode(a3,INPUT); pinMode(a4,INPUT);

                   digitalWrite(en,HIGH);
                  // loading();
                  }

                  void loop() {
                    
                    if ( digitalRead(a0) == HIGH ) //forward//
                   {
                    lcd.setCursor(0, 1);
                    lcd.print("FORWARD "); 
                    digitalWrite(af, HIGH);
                    digitalWrite(ar, LOW);
                    digitalWrite(bf, HIGH);
                    digitalWrite(br, LOW);
                   }
                     if (digitalRead(a1) == HIGH) //backward//
                      {
                    lcd.setCursor(0, 1);
                    lcd.print("BACKWARD"); 
                    digitalWrite(af, LOW);
                    digitalWrite(ar,HIGH);
                    digitalWrite(bf, LOW);
                    digitalWrite(br, HIGH);
                      }
                    if (digitalRead(a2) == HIGH)  //RIGHT
                      {
                    lcd.setCursor(0, 1);
                    lcd.print("RIGHT     ");     
                    digitalWrite(af, LOW);
                    digitalWrite(ar,HIGH);
                    digitalWrite(bf, HIGH);
                    digitalWrite(br,LOW);
                        } 
                    if (digitalRead(a3) == HIGH)//LEFT
                      {
                    lcd.setCursor(0, 1);
                    lcd.print("LEFT      ");        
                    digitalWrite(af, HIGH);
                    digitalWrite(ar,LOW);
                    digitalWrite(bf, LOW);
                    digitalWrite(br, HIGH);
                      }
                    if (digitalRead(a4) == HIGH)//STOP
                      {
                    lcd.setCursor(0, 1);
                    lcd.print("STOP      ");        
                    digitalWrite(af, HIGH);
                    digitalWrite(ar, HIGH);
                    digitalWrite(bf, HIGH);
                    digitalWrite(br, HIGH);
                      }  
                    else
                    {
                    lcd.setCursor(0, 1);
                    lcd.print("        ");          
                    digitalWrite(af, HIGH);
                    digitalWrite(ar, HIGH);
                    digitalWrite(bf, HIGH);
                    digitalWrite(br, HIGH);
                     }

                  Conclusion:

                  You can easily build this. you can add lights to the robot and also other features using nodemcu. here is working video of the robot.
                  https://youtu.be/UsY_pJP5PVc

                  Also like and subscribe the channel.

                  IOT Switch using NodeMcu and Blynk app

                  The Internet of Things (IoT) is the network of physical devices, vehicles, home appliances, and other items embedded with electronicssoftwaresensorsactuators, and connectivity which enables these things to connect, collect and exchange datacreating opportunities for more direct integration of the physical world into computer-based systems, resulting in efficiency improvements, economic benefits, and reduced human exertions.(that's IOT from wiki)

                  A simple beginners IOT based switching action is done in this project.

                  Things we need in this project is:
                  1. NodeMcu
                  2. 1 led with 200ohm resister.
                  3. Arduino IDE and Blynk library
                  4. Blynk App on your phone.

                  What's NodeMcu??
                  NodeMCU is an open source IoT platform.It includes firmware which runs on the ESP8266 Wi-Fi SoC from Espressif Systems, and hardware which is based on the ESP-12 module.The term "NodeMCU" by default refers to the firmware rather than the development kits.(source: https://en.wikiphttps://en.wikipedia.org/wiki/NodeMCUedia.org/wiki/NodeMCU)



                  First try to install NodeMcu board!!
                  1. Go to: tools\board\board manager\esp8266 (search online)
                  else if not found
                  2. goto file\preferences then look for additional board manager urls. paste "http://arduino.esp8266.com/stable/package_esp8266com_index.json" and repeat step-1 install esp8266 board from there.

                  Blynk Library:
                  Search for blynk Library or simply download it from:https://github.com/blynkkk/blynk-library

                  After downloading it:
                  1. Decompress and paste the folder in Arduino library present in documents. (e.g. paste it at C:\Users\*****\Documents\Arduino\libraries
                  2. Start arduino IDE and you can see custom example of BLYNK library at file\examples.
                  3. Connect nodeMce to PC. choose correct board,in my case-NodeMCU 1.0(ESP 12E module). Select the correct COM port(select the com which appears after connecting nodeMcu).
                  4. In arduino IDE go to:files\examples\blynk\boards_wifi\esp8266_standalone.
                  5. 3 things to edit here a-"YourAuthToken", b-"YourNetworkName", c-"YourPassword"
                      'b' is your wifi network name (must connceted to internet) and 'c' is password set for that wifi network.  "YourAuthToken"-this will be discussed later after using the blynk app. After getting the authToken replace it and burn the code to nodeMcu.
                  6. Press reset. Watch connection Status on serial monitor. 

                  Jobs with the blynk App:
                  1. Download blynk App





                  2.Open the app login with FB or other methods.
                  3.Click on New project. Name the project(e.g. Iotswitch_gg). Choose Device: NodeMCU. Then create.
                  4.Authtoken is sent to your mentioned Email. Copy the authtoken and replace it in the code in nodeMCU. You can also get the Authtoken in the project setting.
                  5. Follow the steps in the app.

                  Hope you get it right!!!
                  KEEP VISITING MY BLOG.