Wireless Distance Sensor DIY

by Tanishq Jaiswal in Circuits > Arduino

3240 Views, 3 Favorites, 0 Comments

Wireless Distance Sensor DIY

vlcsnap-2019-11-17-20h58m08s312.png

The ability to measure the distance via ultrasonic sensor within the cost of a couple of dollars is quite fantastic, to be honest, and adding the wireless functionality is even appealing, you could use it as a parking sensor in an old car where the distance will be displayed on your phone instead of an external display.

So let us get started with the build! Here is the video tutorial for the same which also includes its working in real-time.

Things Required

vlcsnap-2019-11-17-13h06m11s093.png
vlcsnap-2019-11-17-13h06m16s927.png
vlcsnap-2019-11-17-13h04m34s308.png
vlcsnap-2019-11-17-13h05m56s695.png
vlcsnap-2019-11-17-13h04m49s490.png
vlcsnap-2019-11-17-13h05m07s997.png

1.) HC-SR04 (This is ultra-cheap Ultrasonic Distance Sensor)

2.) HC-06 (Bluetooth Module )

3.) Arduino (I used Nano)

4.) USB (For Arduino)

5.) Jumpers Wires

Connect the HC-SR04 to Arduino in the Following Way:

vlcsnap-2019-11-17-13h06m47s187.png
vlcsnap-2019-11-17-13h06m23s360.png

Vcc -- 5V

Trig -- Pin 13

Eco -- Pin 12

Gnd -- Gnd

Connect the Bluetooth Module HC-06 to Arduino Nano in the Following Way:

vlcsnap-2019-11-17-20h56m47s501.png
vlcsnap-2019-11-17-13h07m07s039.png

Vcc -- 3.3V

Gnd -- Gnd

Tx -- Rx

Rx -- Tx

The Library

vlcsnap-2019-11-17-20h57m02s279.png

For the library, you need to download the HC-SR04 Library for this, inside the Arduino IDE, go to Tools->Manage Libraries and then search HC-SR04 and install the one by Martin Sosic.

Upload the Code!!

vlcsnap-2019-11-17-20h57m17s599.png
vlcsnap-2019-11-17-20h57m26s292.png

For this make sure the Tx and Rx pins of Bluetooth Module and Arduino are disconnected before uploading the code, after successful upload you can reconnect.

For the code, go to File->Examples->Tools->HC-SR04->Simple, Upload it to the Arduino. If you open the serial monitor at 9600 Baud rate after uploading the code, you will see the distance measured by the ultrasonic sensor. Now its time to add the Bluetooth module

The Serial Monitor App

vlcsnap-2019-11-17-21h50m17s138.png

This is a generic Android application which acts as a serial monitor via Bluetooth, you can find similar apps on IOS.

Just go to the connect button and click the HC-06 to get connected.

Done!

vlcsnap-2019-11-17-20h58m08s312.png

After Pairing and connecting the Bluetooth Module to the app, you would easily be able to read the data which measures the distance between the object and sensor in Millimeters, it is recommended that you do not measure the distance of less than 3 centimeters and more than 3 meters.

Thank You So Much For Reading!

Regards, Tanishq