Saturday, 9 March 2019

IOT Robot with NodeMCU and Arduino using Blynk.


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:
  • 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

                  #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(a0,INPUT); pinMode(a1,INPUT); pinMode(a2,INPUT);
                   pinMode(a3,INPUT); pinMode(a4,INPUT);

                  // 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);
                    digitalWrite(af, LOW);
                    digitalWrite(bf, LOW);
                    digitalWrite(br, HIGH);
                    if (digitalRead(a2) == HIGH)  //RIGHT
                    lcd.setCursor(0, 1);
                    lcd.print("RIGHT     ");     
                    digitalWrite(af, LOW);
                    digitalWrite(bf, HIGH);
                    if (digitalRead(a3) == HIGH)//LEFT
                    lcd.setCursor(0, 1);
                    lcd.print("LEFT      ");        
                    digitalWrite(af, HIGH);
                    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);
                    lcd.setCursor(0, 1);
                    lcd.print("        ");          
                    digitalWrite(af, HIGH);
                    digitalWrite(ar, HIGH);
                    digitalWrite(bf, HIGH);
                    digitalWrite(br, HIGH);


                  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.

                  Also like and subscribe the channel.

                  Monday, 25 February 2019

                  RCA composite cable for Raspberry Pi -Solved Problem

                  Converting your old CRT TV to a Raspberry Pie display is matter of great excitement. Raspberry Pi comes with many OS such as Raspbian OS, Retro Gaming OS-"Retropie", Media Centre OS-"OSMC" etc are helping getting good User experience.

                  When it comes to Old CRT TV they don't have in-built HDMI ports Instead they have AV ports. You might have seen AV cable between your set-up box and TV.

                  • To play via R-Pi you need HDMI to AV converter (expensive and not discussed here)
                    • RCA and AV composite cable
                    What problem arises!!!
                    There is bit difference between pin configuration on Raspberry Pi and other devices. This has been shown below.

                    So it is clear that the pin "video" and "ground"on 3.5mm jack is interchanged in case of RPi. To solve this you should buy RPi specified cables or DIY a female connector like me. So needed item are:
                    • AV female pins
                    • 3.5mm RCA pin
                    • wires and soldering material
                    Solder the wire according to the given figure below.
                    The out come looks like this.

                    Plug it to your TV and enjoy gaming and media like never before. Humming sound may arises due to interference.
                    **In OSMC OS goto setting and find Audio output option, there change the option to AV mode, then you will find zero noise or humming sound.
                    **You can buy readily modified cables at adafruit here thelink.
                    ##Thank you##

                    Saturday, 23 February 2019

                    “SOLAR TRACKER” USING ARDUINO

                    Solar power is renewable energy source and Solar panel helps in converting the solar power to electric power.
                    Solar tracker is a device which is used to sense solar intensity and rotate the solar panel in that respective direction. It would help in getting maximum solar energy through the solar panel and to its electrical conversion.

                    #wiki_stuffs: Orientation and inclination

                    A solar cell performs the best when its surface is perpendicular to the sun's rays, which change continuously over the course of the day and season. It is a common practice to tilt a fixed PV module (without solar tracker) at the same angle as the latitude of array's location to maximize the annual energy yield of module. For example, rooftop PV module at the tropics provides highest annual energy yield when inclination of panel surface is close to horizontal direction.
                    #wiki_stuffs: A solar tracker is a device that orients a payload toward the Sun. Payloads are usually solar panelsparabolic troughsfresnel reflectorslenses or the mirrors of a heliostat.
                    Things we need!!
                    • 1.      Solar panel (not necessarily a big one a mini could be better)
                    • 2.      DC motor(servo better if you know coding it)
                    • 3.      Motor driver
                    • 4.      Board, Wood piece or panel holding structure.
                    • 5.      Arduino and jumper wires
                    • 6.      Two IR (Infrared) sensors and resistor and diodes.
                    • 7.      Power source (12V or a power bank might work great)
                    • 8.    Incandescent bulb for testing purpose
                    Whats the Idea??
                    The idea is mounting two sensors and two ends of the solar panel and measuring the solar intensity via Arduino and then Arduino commands to tilt the panel toward that direction in which there is more intensity until the intensity of both the sensors became nearly equal. The tilting action can be done by motor and driving circuit.

                    Concept diagram for solar tracker.

                    Build IR Sensor!!

                    • You can easily find IR Receivers near by electronics store and build the above circuit.
                    • Don't forget to place diodes at output it will decrease interference.
                    • SEE REF:

                    How it looks when it is built!!

                    Coding is simple one. That is the tilting process going on until the difference between the sensor values become less than desired value.
                    ////////////////////////////Code Solar tracker////////////////////////////////////
                    int br = 3;//motor output reverse
                    int bf = 2;//motor output forward //you can use enable at pwm output or make iy short to 5v.

                    int a4=0,a5=0; //analog sensor input
                    int approx=10; //difference limit
                    void setup() {



                    void loop() {

                      Serial.print(' ');
                      Serial.print(' ');
                      Serial.println(' ');

                    int diff=a4-a5;
                        if(diff > approx)

                    int diff=a5-a4;
                        if(diff > approx)

                    Its a good project for students to start with hope you like it.

                    Monday, 24 September 2018

                    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.wikip

                    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 "" and repeat step-1 install esp8266 board from there.

                    Blynk Library:
                    Search for blynk Library or simply download it from:

                    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.

                    Monday, 13 August 2018

                    Blink using 555 timer

                    Have you imagined a blink circuit without arduino!! It was very common using a 555 timer circuit building a flasher or blink circuit.


                    1.555 timer IC
                    4.Printed Circuit Board
                    6.Tools for soldering and 5v power Supply


                    1. See the pin diagram of 555 IC.
                    2. Theory behind this.
                    The IC is connected as a astable multivibrator with a duty cycle of about 10%.
                    In figure 1 the LED will be ON for a short period of time and OFF for a longer period. The duty cycle can be reversed if the LED is connected as shown in figure 2 but the battery consumption will also increase due to the fact that the LED will stay ON for a longer period of time.

                    3. Circuit diagram.
                    If you didn't get anything by reading above,you can simply connect the elements according to the circuit diagram given below.
                    The above circuit diagram is copied from internet you can modify this accordingly. So I have replaced higher value resistors with 10k ohm and lower value resistors with 200 ohm and capacitor of 63V/10 uF.
                    Actual Circuit:
                    I suggest that before making the circuit of PCB, you should try it on breadboard for best results and adjust timing of your flasher circuit.
                    I have also brought out additional output pins from leds. You can use them to power up relays and flash bigger lights.
                    To vary resistor you can use variable resistor or a 10k potentiometer and also the capacitor also.

                    for reference:

                    Keep visiting me!!!

                    Sunday, 8 April 2018

                    Codes for adding letters to 8X5 leds

                    Codes for Adding letters to 8X5 LEDs

                    From the last blog we have written codes to On/Off a LED individually. So here I gonna explain how to display letters on leds.
                    The trick is simple and that is by blinking a LED each time. The speed is so fast that it appears that all LEDs are ON at same time.

                    I have used the alphabet patterns or you can say fonts as similar to 16x2 LCD display. So letters will be in 7X5 LEDs matrix.

                    So you can blink LEDs row wise(rows first) or column wise. here shows how can you blink LEDs one by one.
                    Code for Writing 'G' is given below:
                    void Gi()
                     int a=timel;//duration for which letter will be displayed
                     while( a > 0){
                     onled(1,2); onled(1,3); onled(1,4);
                     onled(2,1); onled(2,5);
                     onled(4,1); onled(4,3); onled(4,4); onled(4,5);
                     onled(5,1); onled(5,5);
                     onled(6,1); onled(6,5);
                     onled(7,2); onled(7,3); onled(7,4); onled(7,5);
                    This code can be used in the last blog I posted using as a function.

                    For the complete code click on link... and thanks for visiting.

                    Friday, 23 March 2018

                    DIY 8x5 LED Matrix display

                    DIY 8x5 LED Matrix display

                    If you want to make a 8X5 led matrix display without using any other MUX with arduino,then this article is for you.
                    Things you needed:
                    1. bunch of LEDs(check before use)
                    2. PCB Board(Brown board)

                    3. Jumper Wires(Male to female)

                    4. Arduino
                    5. 100 ohms resistors
                    6. Soldering Instrument and Hot glue gun

                    Wiring up/ Circuit connections:
                    Before you start have brief idea about leds:

                    • choose healthy LEDs only
                    • do check before soldering on the PCB.
                    • these needs min 1.5V and a few mA current. So accompany them with 200 or 100 ohm resistance.
                    All you need is connect all Anode of leds in a row together and connect all cathode of leds in a column together. The circuit diagram will clear your thoughts.

                    From the above diagram if the row-x is given Low state and column-y is given High state then the LED belongs to (x,y) will glow.
                    But in programming or using arduino the state of all other leds should be in opposite in order to Switch them off.
                    So the idea is to ON one led at a time and make all other leds OFF that time.

                    Here are some pictures while making the circuit:

                    •  Do add resistances(100 ohm or 200 ohms) otherwise the leds may damage due to over current flow. Add female header pins for make it arduino friendly.


                    here is the code:

                    int row=0,col=0;
                    int time1=5;
                    int timex=1;
                    void onled(int x,int y)//PASSING ROW AND COLUMN VARIABLES TO ON THE RESPECTIVE LED
                     if(x==1){row=2;} if(x==2){row=3;} if(x==3){row=4;} if(x==4){row=5;} if(x==5){row=6;} if(x==6){row=7;} if(x==7){row=8;} if(x==8){row=9;}
                     if(y==5){col=19;} if(y==4){col=18;} if(y==3){col=17;} if(y==2){col=16;} if(y==1){col=15;}
                    void reset()//THIS FUNCTION USED TO SUPPLY ANODE WITH gnd AND CATHODE WITH +5V

                    void setup() {


                    void loop() {
                     onled(1,1);//on led of row-1 col-1    
                    The result will look like this:

                    Displaying letters on this will be in the next blog,till then you can use loops for different new patterns.

                    Monday, 15 January 2018

                    16X2 LCD Interface with Arduino

                    16x2 LCD Interface with Arduino

                    Its quite inconvenience to use serial monitor of Arduino IDE to display data or any message when a wireless display is needed. Thus a on-board display will be helpful for solving this issue. 16x2 LCD is one of the simplest & cheapest display one can use for this purpose.

                    Things needed:
                    - Arduino
                    -16x2 lcd 
                    - Connecting wires

                    About 16x2 LCD :
                    The LCDs have a parallel interface, meaning that the microcontroller has to manipulate several interface pins at once to control the display.
                    The interface consists of the following pins:
                    ·         A register select (RS) pin that controls where in the LCD's memory you're writing data to. You can select either the data register, which holds what goes on the screen, or an instruction register, which is where the LCD's controller looks for instructions on what to do next.
                    ·         Read/Write (R/W) pin that selects reading mode or writing mode
                    ·         An Enable pin that enables writing to the registers
                    ·         data pins (D0 -D7). The states of these pins (high or low) are the bits that you're writing to a register when you write, or the values you're reading when you read.
                    ·         There's also a display constrast pin (Vo), power supply pins (+5V and Gnd) and LED Backlight (Bklt+ and BKlt-) pins that you can use to power the LCD, control the display contrast, and turn on and off the LED backlight, respectively.
                    The process of controlling the display involves putting the data that form the image of what you want to display into the data registers, then putting instructions in the instruction register. The LiquidCrystal Library simplifies this for you so you don't need to know the low-level instructions.

                    Circuit Diagram
                    There are generally 16 pin slots on 16x2 LCD module. Here I have used 12 as shown in the figure. After wiring the module connect it and see if the back light is glowing.

                    Coding Part:
                    Write or past this code in arduino IDE

                    // include the library code:
                    #include <LiquidCrystal.h>
                    char str1[]="GaneshGadgets";
                    char str2[]="";

                    LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

                    void setup() {
                      // set up the LCD's number of columns and rows:
                      lcd.begin(16, 2);
                    void loop() {
                    lcd.setCursor(0, 0);//cursor position
                    lcd.print("Ganeshgadgets ");
                    lcd.setCursor(3, 1);
                    lcd.print(" ");
                    The result will be like this:

                    Sunday, 3 December 2017

                    Processing + OpenCV + Android IPcam : Detect Face

                    OpenCV + Processing + Android IPcam : Detect Face

                    All you need for this project is listed below:
                    1- Processing 3.3.6
                    2- openCV library for processing + IP-capture library
                    3- Ipcam App installed on your android device

                    Specialty of this project is phone camera is used for live camera detection. So you don't need web-cam for this.
                    Giving you short brief about the need of this project. 

                    1- Processing 3.3.6
                    Processing is an open source computer programming language and integrated development environment (IDE) built for the electronic arts, new media art, and visual design communities with the purpose of teaching the fundamentals of computer programming in a visual context, and to serve as the foundation for electronic sketchbooks.

                    2- Libraries
                    • OpenCV
                    OpenCV (Open Source Computer Vision) is a library of programming functions mainly aimed at real-time computer vision. Originally developed by Intel, it was later supported by Willow Garage and is now maintained by Itseez. The library is cross-platform and free for use under the open-source BSD license.

                    OpenCV library can be downloaded from the software itself following
                    Sketch > Import Library > Add library > openCV Processing
                    You can download it from github
                    1. Unzip it and paste it to Sketchbook>libraries.
                    2. To find Sketchbook Location go to File>preferences>browse location.
                    3. After successful installation of library you can find example under "Contributed Libraries."

                    • IP Capture Library
                    Similarly you can download IP_Capture library from Sketch > Import Library > Add library
                    or you can download from Github

                    3- Ipcam App installed on your android device

                    There are many ipcam apps are available in playstore but i recommend this one.

                    After installing all software, libraries, apps lets get started. If you have some issue regarding installing mention in the comment box.

                    • First  turn on your  phone WiFi Hotspot and connect your PC to it. It will create a Local Network through which both devices can communicate. If you already have private network,then you can connect both your devices to that network
                    • Open the IPcam app then go to the bottom and click on Start server. You will see Ip address to get camera stream like " " note it down.
                    • Now open processing and write the following code. It is bit different code than the code given in the OpenCV Contributed examples.
                    import ipcapture.*;
                    import gab.opencv.*;
                    import java.awt.Rectangle;
                    OpenCV opencv;
                    Rectangle[] faces;

                    IPCapture video;
                    PImage src; //separate image variable to capture from Ip cam

                    void setup() {
                      size(640,480); // can use full screen instead
                      video = new IPCapture(this);
                      video.start(""," "," ");
                    void opncv() // function openCV
                      opencv = new OpenCV(this, src);
                      // See library reference to Detect eye,body,nose etc.
                      faces = opencv.detect(); 
                    void getlive() {
                        if (video.isAvailable()) 
                        image(video,0,0); // draw image on screen
                        src = get();
                        // get what is drawn on screen and paste that to src image

                    void draw() {
                      getlive(); //get live image
                      image(src, 0, 0);// show live image on screen
                      noFill(); // show a rectangle around face
                      stroke(0, 255, 0);
                      for (int i = 0; i < faces.length; i++) {
                        rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height);   
                    • This is the result you will get.

                    Thanks for visiting my blog.
                    If you face some issue comment.