Monday, 13 February 2017

GPS Based Security for Bicycles

We all love to ride our bicycles ,some do it for hobbies and some want to use it as a profession in their lives.Everyone wants their things bought from hard-earned money to be protected and that is why i felt the need to do this project.

Basic Idea:

The basic idea behind this project is that it would consist of a GPS receiver and a microcontroller which is capable of getting connected to internet having built in WiFi. This requirement is best fulfilled by Node-MCU as Raspi is a bit expensive and very expensive when it comes to comparison of Node-MCU with raspi,but with great price comes great performance.
After we have got our modules required ,we will write a simple code to receive the latitude and longitude of the location where the device is located and after that we will upload the same data to Thingspeak and then we can write a python script to read the values from thingspeak and show the map or the location of the device.

Installation Guide:

Everything can be placed inside a small box and to attach it to the bicycles or bikes ,we will be using a small magnet instead of screws and nuts. 

 Hope the idea comes to life.

Any suggestions would be appreciated!!


Friday, 30 December 2016



I came to Chandigarh in 2007 and the traffic was much lesser as compared to the present scenario in the city. Now, it is 2017 and after a span of 10 years, everyone is familiar with the chaos in the parking spaces. Imagine, when you reach a parking area and you don't find a parking space . In such a situation, the owner will park his/her vehicle in an NO PARKING zone and in some cases have to pay the fine for the same.
Now, Imagine a situation where you access the parking area from anywhere using twitter or just by typing an IP in your web browser on your mobile or laptop.This will save a lot of valuable time and also prevent you from paying fine. Let's now get to the technical part.
I am assuming that you all are familiar with using Arduino IDE.

Ultrasonic Sensor

Ultrasonic sensor has 4 pins namely VCC, GND, TRIG, ECHO. The ultrasonic sensor sends pulses of high frequency and as soon as it gets reflected from the object(if any object is there within 400cm), Echo pin will receive the signal and indicate that an object has been detected.Click here to know how to detect objects and measure the distance using ultrasonic sensor. 

Logic for detecting cars

In this project, two ultrasonic sensors are employed to detect cars and other four-wheelers and reject all pedestrians.There are three possible conditions.
1. Only Sensor 1 is active(T1).
2. Both Sensor 1 AND Sensor 2 is active(T3).
3. Only Sensor 2 is active(T2).
Every time a condition is met, a timer is started and all the three timers are stopped and values are stored in three different variables. The timers values are then compared and logic is developed.I have measured all the time values and noted them in a notebook and logic developed for entry was T1>=T3>=T2.
Each time this condition is met in the software, an entry will be detected and accordingly the entry variable will also be updated with the new value. To prevent errors in detection from the hardware, place the sensors 1.5m or 2m apart from each other and place sensors at a height of  100cm above from ground.

Wiring the circuit

 If you are going to use my code for your project, make sure to make the connections as folllowing.

After making the connections as from the above pic upload the following code and test whether it is detecting enteries appropriately.
Here is the CODE For entry detection.
Once the Enteries are detected, get ready to see some magic with few lines of code. Make the following connections.Tx of Arduino to Rx of Node-Mcu.
Rx of Arduino to Tx of Node-Mcu.
Before uploading this code to node-mcu, make sure Arduino is turned off and proper board is selected in the Arduino IDE.
Here is the Code For WiFi connection and data upload.
To know about Thingspeak libraries and ESP8266 libraries and making a new channel on Thingspeak      Click Here. Firstly the serial data is read and then written on the Thingspeak using the above code.
Here are the output and twitter notification.

 This is how i tested the system(Make sure to decrease the height of sensor,its an old pic :P)

Final Circuit 
Link for libraries.
NewPing: NewPing
Stopwatch: Stopwatch

If you are facing any problems or having any problems in this project, ask in comments.
Working Video is on My Youtube Channel.
Keep Learning and Keep sharing the Knowledge.

Tuesday, 20 December 2016

Soil Moisture,Node-mcu and IoT

After a lot of browsing on the internet , I found nothing about how to interface a moisture sensor with Node-MCU. So, I decided to try it by myself.
Node-MCU is an open source IoT platform to make and build awesome stuff with data analysis and access throughout the world with the help of Thingspeak. It has built in ESP8266 with it, which makes it pretty easy to use.
This small project was a part of our college semester project. Our teacher asked everyone in the class to make a project based on wireless communication, that is, transferring data over a channel which doesn't have wires. In the past , I had worked with Arduino IDE and boards but never made something that employs wireless communication. I have worked with data storage , graphing using python, sensor interfacing but never with wireless communication. Everyone was busy making big circuits out of which some were working , some were not, but I appreciate their efforts. I wanted to make something useful and smart at the same time.
Some legend once said,"Why do hard work when you can opt for smartness". Node-MCU is a very smart micro-controller unit, I must say.
Lets go to the technical part now. The moisture sensor is based on a voltage produced due to variable resistance.The two probes of the sensor are to be dipped in water or soil to measure the moisture content.
These two probes are variable resistances which when dipped in water(Maximum moisture) produces a voltage at the output pin. For water the number of bits calculated by the analog channel is 1024 i.e above 3.3V(Node-MCU works with 3.3V). In short , make the following connections
 Node-MCU                 Sensor
VCC(3.3V/5V)  ---->   VCC
A0      ----->                OUT
GND  ---->                  GND

After you are done with connections. Open your Arduino IDE and write the code to sense and upload the moisture content to Thingspeak. The code is at the bottom of the page.
You might need to download the library for ESP8266 and Thingspeak. To install these libraries, follow the following path in Arduino IDE.
Go to  Sketch>Include library>Manage library.
In the search bar , search for both of the libraries.
Here is the screenshot to make it easy.

After the successful installation of libraries.Visit Thingspeak and create an account. After this, follow the following procedure to make a channel and get an API key and channel id.
Click on channels and then on My Channel.Click on New Channel.

Fill all the details you wish to fill including name and fields labels. Make it public if you want to.
When You will save the channel , you will get an API key by clicking on the channel keys in your channel section.
Now write the following code in the Arduino IDE.

#include <ThingSpeak.h>

const char* ssid="Your ssid";
const char* password="Your paasword";
unsigned long myChannelNumber = "Your channel id"; 
const char * myWriteAPIKey = "Your API key"; 
WiFiClient client;
void setup() {
  Serial.print("connecting to ");
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
void loop() {
ThingSpeak.writeField(myChannelNumber, 1, moisture, myWriteAPIKey); //Write data to channel
delay(15000); ///delay required for thingspeak data to upload.

Here is the setup I used for testing.

Upload the code and open Your channel to see the output.

This project can be used to look after your lawn when out of station or away from your home  by controlling the water pump from the sensor values and it can be controlled from anywhere in the world.
If You have any questions, ask in comments.

Sunday, 5 April 2015


Robotics, a field that is enjoyable , competitive and interesting.But before robotics there's another field that requires good mental ability and mathematics, i am talking about Programming.Programming is something that makes you talk to computers.Today,everything is totally based on programming. These days, even some singers( are trying to learn programming.There are many Programming languages like C(most basic language about which one should know),C++,C#,Arduino,HTML,PHP,JAVA,PYTHON and many others.We can do a lots of things using programming languages like a security system,make a robot to follow a certain given path(Line Follower),make a robot to avoid obstacles,making applications for android and lots of things.
Here, i will talk only about Arduino. Arduino is an easy to learn and user friendly language.I have made a line follower using Arduino language.To make such  kind of robots you need sensors,a laptop,circuit diagram of pin connections and good hand at mathematics techniques.We can make many things using Arduino language like a robot that would avoid any kind of obstacle in its way.

HARDWARE: The first and the foremost hardware includes chassis of the robot.We can build chassis from any kind of board having enough strength to hold all the equipments  like battery microcontroller etc.To build a chassis all You need is a measuring scale and some cutting instrument like Hack-Saw.Measure according to size of your robot you want to make and cut out the required area.To make anything including robots ,you need to build the base where we can keep our things.In robotics the things are-Motors,micro controller,Battery etc.

                                                            SENSOR GRID


There are two types of sensors that help the line follower to follow the line.One is IR emitter which will emit the light and the other is receiver which will receive the light.If the surface is full black then all of the transmitted line will be absorbed and receiver will get no light and accordingly voltage is produced.If the surface is white then all of the transmitted light will reflect back and produce voltage accordingly.


                                                   MOTOR CONNECTED ON A L-CLAMP

 To place the Motors we need a tool namely L-Clamp.L-Clamp is connected using screws on which motors are placed.Make sure you measure the dimensions of L-clamp correctly and mark accordingly on the board where they are to be connected.Once the Motors are connected we can connect tires to the motors.we need to connect the motors in a good orientation .By good orientation i mean that motors should not be tilted ,they should be straight and at same horizontal level with respect to each other.



A Micro Controller is an electronic device which will be storing the code we have written.We have different microcontrollers like Atmega8, Atmega168,Atmega328.These all are same in every aspect except that they store different size of code.  

                                                           FINAL ROBOT

Here is the final robot i have made,I have used a different battery here,it is made up of 8 cells each of 1.5V. We can use any 12V battery or any battery of any voltage depending on motor size.

SOFTWARE: To Write the software to make our robot to follow the black line ,we need to connect the pins of sensors to the pins of aurdino.


To run the Motors we need another IC known as H-BRIDGE IC. The pins of the IC are to be connected to the pins of the Aurdino and then the code is written so as to follow the track.
It looks quite simple and it is quite simple!!!!.
To make a robot to follow the line,what we need to do is
The robot should know which line is black and which is of white.
(Just think of Soccer , if a goal is needed to save then goalie should know where the ball is coming and make a dive accordingly to save the goal)
Here is the process to write a basic code:
1. Place the sensors of the robot on the surface(either black or white)
2. Note the voltage of the sensors  using a multimeter, if it is positive for a black surface that means it has a value 1(HIGH) when it is on a black surface
3. Write the code accordingly to turn left or right. Take for e.g if we have to turn left then sensors to the left of the robot should have HIGH value and all other LOW(dealing with digital) and similarly for right.To go Forward our sensors which are in the middle of sensor grid should have HIGH and all other LOW.
That's it any doubts ask in comments :)
Here are the screenshots of the code i am posting




Friday, 3 January 2014


    I have just entered in my college of engineering  but someone told me to get into the field of robotics ,but you know there are some people who just thinks that they are right in deciding their fields and i am also one of them.My answer to his free advice was that i am in electrical engineering and robotics is something not of my field,but that person has the answer to every doubt ,and then he told me that robotics doesn't come under any engineering course it is totally a different field . It is field in which if you take interest you will surely enjoy doing it .
You can convert even some scrap into something useful and that is what i have done   .
 I was just cleaning  my room and i got a robot lying alone in the scrap and then comes the idea of converting it into a useful robot and now it can run on four wheels and can play with a tennis ball .
 Now i will tell the making of my robot so that you can also make it , it is quite easy.
 The first thing i did was that i bought some material required to complete my process .Here  i am giving the details of materials that i used in making my robot.

                                                             The Robot  From The Scrap 


                                       This was the robot which i found from the scrap  

                                                      1. SOLDERING IRON


                                               This is the soldering iron i bought and on the left is the soldering wire  ,it is a solder on's company  soldering iron with a thin tip. While soldering ,keep one thing in mind that you are holding it in a right way ,and the right way to hold it is like a pen. Now wrap the wires around one another and then burn some soldering wire on the tip of the soldering iron and then move the tip over the wrapped wires and then the wires will get soldered .                                                                                               

                                                                UNSOLDERED WIRES                  
                                         THE SOLDERDED WIRES WILL LOOK LIKE THIS 
                                                                         2. BATTERY                                                                                

                   One will have to use a power supply to run the motors and the power supply will be given by using two 6V  battery.                                


RELAY :-      Let me describe you what is a relay , a relay is something used to run high current devices or to control a device through a low power level.A simple relay has 5 pins .There are 2 coil pins ,1 pole pin ,1 normally connected and 1 normally open . Without the application of voltage the pole pin is always connected with normally connected pin and when you will apply voltage the pole pin will got connected to normally open pin. 


It is always better to check the circuit  before applying , this can be achieved by a software known as proteus and here is the circuit which i designed in this software .

Now see that all the normally connected pins and one coil pin of all the relay are connected to each other and to negative terminal of the battery .One pin of all the switches are also shorted and other pins of respective switches are connected to other coil pin .The normally open pins of all the relays are also  shorted with each other and are connected to power supply through switches .when the above two switches are pressed normally open pin will get the voltage and then the pole pin will get connected to the open pin and the pole pin will also get voltage and the pole pins are going to the motors( which are connected to parallel  ) and hence motors will get the power supply and runs . 

The Final Robot 

This is the final robot which i converted from scrap .