Introduction: Node:Ultrasonic Sensor With Blynk

Picture of Node:Ultrasonic Sensor With Blynk

This project is so handy in some case where while driving we need to know the distance of the obstacle behind the car so that we can park easily without any damages to the car and read that value in an Android app without any difficulty turning back and constantly monitoring.

Hello!!, I'm Sridhar Janardhan, Today I am going to show you how to create a distance measuring and monitor that in an Android app.

Let's get started.

Step 1: Components Reuired:

Picture of Components Reuired:

The components required for this project are:

  • NodeMCU
  • Breadboard
  • Ultrasonic sensor
  • Blynk app
  • Jumper wires

Let's now power up the breadboard using NodeMCU

Step 2: Powering Breadboard Using Breadboard

Picture of Powering Breadboard Using Breadboard

To power up the breadboard:

  • Connect the 3.3-volt pin of the NodeMCU to the positive railing of the breadboard
  • Connect the GND pin to the negative railing of the breadboard.

Usually, we can connect Ultrasonicsensor pin directly to NodeMCU but if you connect like the above, It will be easy to connect multiple sensor and output device.

Step 3: Connect the HC-05 Ultrasonic Sensor

Picture of Connect the HC-05 Ultrasonic Sensor

The ultrasonic sensor is a distance measuring device that measures the distances of the obstacle by calculating the time between emission and reflecting of the wave.This is done by the TRIG and ECHO pin.Where the ECHO pin emits the wave and TRIG pin get's triggered on reflecting wave hitting back.

The connection of the sensor is as follows:

  • VCC pin: Connect to the positive railing of the breadboard.
  • GND pin: Connect to the negative railing of the breadboard.
  • TRIG pin: Connect to the Digital pin D1.
  • ECHO pin: Connect to the Digital pin D2.

Step 4: Blynk App

Picture of Blynk App
  • Download Blynk app from play store here:
  • Create a User account in the app.
  • Then press New project in the given List
  • Choose NodeMCU in choose device list
  • Connection type as WiFi
  • Theme left to your convenience that has no effect on the tutorials
  • drag towards the left side of the screen you can list of widgets.Select LCD in the widget.
  • Before you run the play button give the following details in the code

1) Wifi SSID

2)WiFi Password

3)Auth token, Given by the Blynk team in your email.

Step 5: Coding

Picture of Coding

#define BLYNK_PRINT Serial

#include

#include

#define TRIGGERPIN D1

#define ECHOPIN D2

// You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth[] = "Your auth token";

// Your WiFi credentials. // Set password to "" for open networks.

char ssid[] = "your wifi SSID";

char pass[] = "your password";

WidgetLCD lcd(V1);

void setup() {

// Debug console

Serial.begin(9600);

pinMode(TRIGGERPIN, OUTPUT);

pinMode(ECHOPIN, INPUT);

Blynk.begin(auth, ssid, pass);

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

lcd.clear(); //Use it to clear the LCD Widget

lcd.print(0, 0, "Distance in cm"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print") // Please use timed events when LCD printintg in void loop to avoid sending too many commands // It will cause a FLOOD Error, and connection will be dropped }

void loop() {

lcd.clear();

lcd.print(0, 0, "Distance in cm"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print") long duration, distance;

digitalWrite(TRIGGERPIN, LOW);

delayMicroseconds(3);

digitalWrite(TRIGGERPIN, HIGH);

delayMicroseconds(12);

digitalWrite(TRIGGERPIN, LOW);

duration = pulseIn(ECHOPIN, HIGH);

distance = (duration/2) / 29.1;

Serial.print(distance);

Serial.println("Cm");

lcd.print(7, 1, distance);

Blynk.run();

delay(3500);

}

Step 6: Output

Picture of Output

The above pics are the screenshot taken in Blynk.If you are not getting any output make sure you did the following:

  • Set the LCD to advance version
  • Then set virtual pin to V1

Thank you.

Comments

OngZ2 (author)2017-10-09

Hai, I,m using an Arduino Uno board and a ESP8266 Wi-Fi Module for this project. however, I'm getting 0 cm all the time. Can you provide me with some any possible solution about this problem? Thank you

About This Instructable

575views

23favorites

License:

Bio: I am an electronic hobbyist on Arduino, Photon, Raspberry Pi and common electronics.A passionate cook.Any assistance in electronics and web development feel free ... More »
More by callmeappytechie:PIR Controlled Buzzer Using ArduinoDIY LampshadeTasty Egg Bonda
Add instructable to: