Wireless Distance Sensor DIY
by Tanishq Jaiswal in Circuits > Arduino
3240 Views, 3 Favorites, 0 Comments
Wireless Distance Sensor DIY
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
Connect the HC-SR04 to Arduino in the Following Way:
Vcc -- 5V
Trig -- Pin 13
Eco -- Pin 12
Gnd -- Gnd
Connect the Bluetooth Module HC-06 to Arduino Nano in the Following Way:
Vcc -- 3.3V
Gnd -- Gnd
Tx -- Rx
Rx -- Tx
The Library
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!!
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
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!
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