Wireless distance measurement using ultrasonic sensor
Introduction:
The distance measurement project is very helpful project, which can be used in cars to avoid accidents, or in any distance monitoring systems in industry, and also can be used in liquid level indicators like fuel tanks in planes. This system consists of ultrasonic sensor with microcontroller and display. The sensor, display and circuit are connected with wires. So if it is required to place sensor and display at some distance (say 2-3 meter or more) then we have to make long wire connection. But in some systems it is required to monitor / measure distance from remote place. Like the sensor is connected in wireless robotic vehicle and we need to know the distance of any object around the vehicle at a remote place. In that case it is required to transmit the sensor output and display it on LCD at remote place. This is possible with the help of RF technology.
The new and different approach in this project is, monitoring distance or liquid level of fuel tank wirelessly from a remote place. Sensor is attached to tank or any movable object but the sensor value (distance) can be monitored at a remote place like on our desk. Wireless monitoring system is very useful in many cases.
Description:
The project uses two microcontrollers. One will measure distance using ultrasonic sensor module and transmit this value using RF Tx module and another will receive this value using RF Rx module and display it on LCD. Ultrasonic sensor works on basic radar principle. It generates continuous pulses, and receives echo signals if any object is in the range. Sensor analog data is converted in to digital form by using ADC in microcontroller and this data is transmitted by RF Tx module (434Mhz) connected to serial port of microcontroller. It is required to convert sensor value into distance in centimeter. The formula to convert is
Test distance = (high level time×velocity of sound (340M/S)) / 2
And also consider angle of measuring.
So now let us start building the project and for that first step is to collect required components and equipments:
Required components and equipments:
Sr. no. Name of component Required quantity
1 RF Tx module(434Mhz) 1
2 RF Rx module(434Mhz) 1
3 Ultrasonic sensor 1
4 LCD 1
5 1 K Pot 1
6 10 K resistor 1
7 Arduino pro mini development board 2
8 Battery – 9V 2
9 Bread board 2
10connecting wires
Circuit diagram:
To build the circuit on bread board as per above circuit diagram, follow step by step procedure
Procedure:
Transmitter section:
Step1: connect Tx module 2nd pin to the 12th pin of Arduino board, 1stpin to the ground and 3rd pin to the Vcc.
Step2: connect ultrasonic sensor module pin 1 to Vcc and pin 4 to ground. Connect trigger pin to pin 2 of Arduino and echo pin to the pin 4 of Arduino.
Receiver section:
Step1: connect Rx module1st pin to the ground and 4th pin to the Vcc
Step2: connect receiver module 2nd pin to the Arduino 11th pin
Step3: connect Arduino 2nd pin to LCD Enpin (6), 3rd pin to Rspin (4), and 4,5,6,7 pins to LCD D5,D6,D7,D8pins respectively.
Step4: connect RW pin (5) of LCD to ground.
Step 5: connect pins 1 and 16 of LCD to ground and 2 and 15 to Vcc. Connect 1 K pot to 3rd pin as shown to vary LCD brightness
Working:
1. In this project we are measuring distance using ultrasonic sensor module.The sensor value is in the form of analog. Sensor value is converted in to digital using microcontroller
2. Digital valueis applied to 434 MHz Tx module to send as ASK signal.
3. The LCD which is connected to microcontroller that displays the value received by the 434MhzRx module.
4. In this project data transmission is based on microcontroller serial ports.
5. When an object in front of ultrasonic module then the sonic waves reflects , these waves are called echo waves. Echo waves are receives by the sonic receiver and produces analog output.
6. This sensor output is converted in to cm scale to measure distance and transmitted to the receiver to display onLCD
Pictures:
You may also like:
Project Source Code
Project Source Code
###
#includeconstinttrigPin = 2;constintechoPin = 4;char Distance[4];void setup() {Serial.begin(9600);vw_setup(2000);}void loop() {int duration, inches, cm;pinMode(trigPin, OUTPUT);digitalWrite(trigPin, LOW);delayMicroseconds(2);digitalWrite(trigPin, HIGH);delayMicroseconds(10);digitalWrite(trigPin, LOW);pinMode(echoPin, INPUT);duration = pulseIn(echoPin, HIGH);// convert the time into a distance//inches = microsecondsToInches(duration);cm = microsecondsToCentimeters(duration);Serial.print(inches);Serial.print("in, ");Serial.print(cm);Serial.print("cm");Serial.println();delay(100);itoa(cm,Distance,10);digitalWrite(13, true); // Turn on a light to show transmittingvw_send((uint8_t *)Distance, strlen(Distance));vw_wait_tx(); // Wait until the whole message is gonedigitalWrite(13, false); // Turn off a light after transmissiondelay(200);}longmicrosecondsToCentimeters(long microseconds){return microseconds / 29 / 2;}Receiver:#includeLiquidCrystallcd(2, 3, 4, 5, 6, 7);#include// LED'sintledPin = 13;// Sensorsint Data;// RF Transmission containerchar Distance[4];void setup() {Serial.begin(9600);lcd.begin(16, 2);lcd.print("ENGINEERS GARAGE");lcd.setCursor(0, 1);// sets the digital pin as outputpinMode(ledPin, OUTPUT);pinMode(9, OUTPUT);pinMode(8, OUTPUT);// VirtualWire// Initialise the IO and ISR// Required for DR3100vw_set_ptt_inverted(true);// Bits per secvw_setup(2000);// Start the receiver PLL runningvw_rx_start();} // END void setupvoid loop(){uint8_tbuf[VW_MAX_MESSAGE_LEN];uint8_tbuflen = VW_MAX_MESSAGE_LEN;// Non-blockingif (vw_get_message(buf, &buflen)){inti;// Turn on a light to show received good messagedigitalWrite(13, true);// Message with a good checksum received, dump it.for (i = 0; i {// Fill Sensor1CharMsg Char array with corresponding// chars from buffer.Distance[i] = char(buf[i]);}Distance[buflen] = '';// Convert Sensor1CharMsg Char array to integerData = atoi(Distance);// DEBUGSerial.print("distance = ");Serial.print(Data);Serial.println(" cm ");lcd.setCursor(0, 2);lcd.print("Distance = ");lcd.print(Data); // change the analog out value:lcd.print("cm ");}}//Program to
###
Circuit Diagrams
Filed Under: Electronic Projects
Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.