Smartphone Controlled Rover IoT Robot using NodeMCU(ESP8266) DIY Kit

Smartphone Controlled Rover IoT Robot using NodeMCU(ESP8266) DIY Kit

iot rover esp8266

For this project, we will be making a simple Wi-Fi controlled robotic tank controlled from a smartphone using Blynk App. In this project an ESP8266 NodeMCU board was used and the principles presented in this tutorial can be applied to other robot models. 

In this quick tutorial we get to Know Your L293D Dual H-Bridge Motor Controller Module

What is Blynk?

Blynk is an app made for android and ios to communicate with Arduino and Raspberry pi. It has a very neat graphical interface which makes it very easy to control and use.

Here we are using the blink app to make a joystick to control the rover.

Requirements :

  • Computer with an internet connection
  • Download and install Arduino IDE

Components

NodeMCU ESp8266

Breadboard

l293d motor driver

L293D MOTOR DRIVER

Jumper wires

bo motor

Bo- motor

caster wheel


Caster wheel

1 nos

wheel

wheel

1 nos

9v battery

9v battery and clip

Software

Hardware

node mcu 8266 wifi

Getting
Started with
Web Switch ESP8266

NodeMCU ESP8266

Node mcu is a micro controller which is made under the LUA based firmware and architecture made for IOT application . It also includes expressif systems and hardware firmware ,which is based on the ESP-12 module. It is a very capable microcontroller which can be used easily for IOT applications with the blynk-app . The features are :- 

  • The operating voltage is 5V
  • Digital input/output pins are 14
  • Analog i/p pins are 6
  • DC Current for each input/output pin is 40 mA
  • Flash Memory is 32 KB
  • SRAM is 2 KB
  • EEPROM is 1 KB
  • CLK Speed is 16MHz
node mcu esp 8266 pin out

Pin out diagram
ESP8266

L293D MOTOR DRIVER

Why Motor Drivers?

Motor Driver is one of the circuit required to power and work our motors .It makes it much more easier to manage the direction of the motors and when and where to stop or start the motor . Here we can see that there is a low power(+5v) input to give to the ic usually from the micro controller to tell the direction of the motors or when to start or stop .The motors take a higher power so ,we give a different vcc  (+9/12v) .

So if there is any need to make a robot ,look no further ..we can use a L293D motor driver.

L293D Motor Driver

L293D is a 16 pin IC where you can control the speed and direction of the motor which will be connected to it .It has a Quadruple h-bridge which lets you change the direction of the current , in turn changing the direction of the motor .It can be used for dc motor , stepper motor or even a geared motor. 

  • It has an operating voltage from 4.5 v to 36 v 
  • it has a current rating from 600ma to 1 A

L293D working

The L293D IC works on the principle of H-bridge , where the polarity or the direction of the current can be changed , thus the motor direction can be changed . 

 

H bridge Truth table

Connection Guide

STEP1: CONNECTING L293D Motor Driver to NodeMCU

Wire up the signal lines and power lines of the L293D Motor Driver to NOdeMCU.  

  • L293D Motor Driver 5V/Vcc -> NodeMCU Vin
  • L293D Motor Driver GND ->NodeMCU GND
  • L293D Motor Driver A –> NodeMCU D5
  • L293D Motor Driver B –NodeMCU D6
  • L293D Motor Driver C –NodeMCU D7
  • L293D Motor Driver D –NodeMCU D8

STEP2 : CONNECTING L293D Motor Driver to Motor

Wire up the motor lines of the L293D Motor Driver to Motor.  

  • L293D Motor Driver 1 -> Right Motor +
  • L293D Motor Driver 2 ->Right Motor
  • L293D Motor Driver 3 >Left Motor +
  • L293D Motor Driver 4 –>Left  Motor 
  •  

L293D MOTOR DRIVER Diagram
With ESP8266

Setting up the Blynk App : IoT Dashboard

The first step is to install the Blynk App on your smartphone inorder to monitor the sensor values

Soon after the code has been uploaded to the NodeMCU, following steps are to be performed on the Blynk App.

Step 1: Create  a Blynk account and>select add new project>add project title >select nodeMCU

Step 2:Create a new project, and select your hardware  as soon as you create the new account

Step 3:Select the hardware as NodeMCU

Step 4: Navigate to project settings and copy Auth Token to clipboard -or- will be sent to your email account.

 A unique authentication code is sent for every new project you created by the Blynk app.  In order to connect your smartphone to the hardware, you need this code. The authentication code will be sent to the email address you used at the time of registration.

Step 5:  To control the digital pin, add widget “Button

Choose Virtual  pin as V3

Choose the Virtual  pin as V2

Select the Virtual  pin as V0

Select the Virtual  pin as V1

Step 7 : Program on NodeMCU and choose the Run button on the BLYNK App.

 

PROGRAMMING

The NodeMCU programming is the same as that of Arduino except for the distribution of pins in the Nodemcu board. Follow the below steps for programming NodeMCU & Arduino IDE

Download Arduino IDE

Step 1: Install the Arduino IDE 1.6.4 or Greater

Download Arduino IDE from Arduino.cc (1.6.4 or greater) –never use 1.6.2!  Use your existing IDE in case if you have already installed it. In case of the proxy is giving you any problem, try downloading the ready-to-go package from the ESP8266-Arduino project

Note: In case if your board is not detected by the computer, check whether the USB data cable connection is damaged or not and if still the problem exists check if the correct driver is installed( follow step 2 to install the driver).

In order to upload code to the ESP8266 and use the serial console, connect any data-capable micro USB cable to ESP8266 IOT Board and the other side to your computer’s USB port.

 

The new version NodeMCUv1.0 comes with the CP2102 serial chip, you can download (also provided with the kit)  and install the driver from https://www.silabs.com/products/development-tools/…. The NodeMCUv0.9 comes with the CH340 serial chip, you can download and install the driver from: https://github.com/nodemcu/nodemcu-devkit/tree/mas…

 

 

Step 2: Installing NodeMCU package for Arduino IDE

Paste the copied link(givenbelow) and insert it(add. boad Manager URL) in Arduino IDE using the following sequence->File menu -> Preferences-> Paste copied link into the area shown in the black box in the above image. Close and restart the Arduino IDE.

The link should look something like this:

http://arduino.esp8266.com/stable/package_esp8266com_index.json

In Arduino IDE, paste the link using the following sequence-:

Choose File menu ->  select Preferences-> Paste copied link into the area shown in the black box in the above image. Then Close and restart the Arduino IDE.

Select Tools -> Boards manager and search for ESP8266 and install the libraries/files given under the heading ESP8266 by ESP community.

Restart the Arduino IDE

 

Scroll down, Install “esp8266 by ESP8266 Community”, from the ESP8266 board menu as shown below.

Select NodeMCU 1.0 ( ESP-12EModule), from the list of boards in Tool-Boards menu

Choose connected NodeMCU port number and the rest of the settings values can be left to default values

Install Blynk Library for Arduino IDE

 Install Blynk as ZIP file in Arduino IDE

Blynk library is available as a downloadable ZIP.  install 3rd party libraries in the IDE, starting with Arduino IDE version 1.0.5.

 Download Blynk Library from the given below link Download Blynk Library, you should never unzip the downloaded library, leave it as is.

Download the Blynk Library by clicking the button:

  • In the Arduino IDE, select to Sketch > Include Library > Add .ZIP Library from the drop-down list in menu
  • Choose the library zip file you have already downloaded.
  • Return to the Sketch > Include Library menu at the bottom of the drop-down menu. Now it’s ready to be used in your sketch. In your Arduino sketches directory, the zip file will already have been expanded in the libraries folder.

Copy Paste the code and click Upload

Arduino Code

Download the Arduino source code.

 We use the virtual pins in the blynk app to send the data for moving the IOT rover.

Before sending the values, we must configure the Wi-Fi settings. (put your ssid and password of your wifi router)

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

#define BLYNK_PRINT Serial
 //http://superkitz.com/libraries/blynk-library-master.zip

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] =   "Blynk Auth key"; // You should get Auth Token in the Blynk App.
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Your wifi ssid";  //Enter the SSID from the smartphone
char pass[] = "Your Password";//Enter the wifi hotspot password

int mL1=D5;
int mL2=D6;
int mR3=D7;
int mR4=D8;
int led=D0;


BLYNK_WRITE(V0)
{
 int f = param[0].asInt();
  Serial.println(f);
  if(f==1)
  {
    digitalWrite(mL1,LOW);
    digitalWrite(mL2,HIGH);
    digitalWrite(mR3,LOW);
    digitalWrite(mR4,HIGH);
}
    else
    {
    digitalWrite(mL1,LOW);
    digitalWrite(mL2,LOW);
    digitalWrite(mR3,LOW);
    digitalWrite(mR4,LOW);
}
}

BLYNK_WRITE(V1)
{
 int b = param[0].asInt();
  Serial.println(b);
  if(b==1)
  { digitalWrite(led,HIGH);
    digitalWrite(mL1,HIGH);
    digitalWrite(mL2,LOW);
    digitalWrite(mR3,HIGH);
    digitalWrite(mR4,LOW);
  }
    else
    {
    digitalWrite(led,LOW);
    digitalWrite(mL1,LOW);
    digitalWrite(mL2,LOW);
    digitalWrite(mR3,LOW);
    digitalWrite(mR4,LOW);
}
}

BLYNK_WRITE(V2)
{
 int l = param[0].asInt();
  Serial.println(l);
  if(l==1)
  { digitalWrite(led,HIGH);
    digitalWrite(mL1,LOW);
    digitalWrite(mL2,HIGH);
    digitalWrite(mR3,HIGH);
    digitalWrite(mR4,LOW);
  }
else
{   digitalWrite(led,LOW);
    digitalWrite(mL1,LOW);
    digitalWrite(mL2,LOW);
    digitalWrite(mR3,LOW);
    digitalWrite(mR4,LOW);
}
}
  
BLYNK_WRITE(V3)
{
 int r = param[0].asInt();
  Serial.println(r);
  if(r==1)
  { digitalWrite(led,HIGH);
    digitalWrite(mL1,HIGH);
    digitalWrite(mL2,LOW);
    digitalWrite(mR3,LOW);
    digitalWrite(mR4,HIGH);
  }
  else
  { digitalWrite(led,LOW);
    digitalWrite(mL1,LOW);
    digitalWrite(mL2,LOW);
    digitalWrite(mR3,LOW);
    digitalWrite(mR4,LOW);
}
}
  
void setup()
{
  // Debug console
  Serial.begin(9600);
  pinMode(mL1,OUTPUT);
  pinMode(mL2,OUTPUT);
  pinMode(mR3,OUTPUT);
  pinMode(mR4,OUTPUT);
  pinMode(led,OUTPUT);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
  
}

void loop()
{
  Blynk.run();


}
  

Then, click the Upload button in the Arduino IDE and wait a few seconds until you see the message “Done uploading.” in the bottom left corner.

Leave a Reply