You are on page 1of 4

Name: Roshan s Branch: Electronics

Roll No: A19 Sem: VII

Experiment No: 07
Aim: To detect obstacles remotely with a Raspberry Pi.

Requirements i)Hardware required: Raspberry Pi, Ultrasonic sensor, breadboard, wires, and
: micro
USB cable.
ii) Software required: Command line

Theory:

Raspberry Pi
Raspberry Pi is the name of a series of single-board computers made by the Raspberry Pi
Foundation. Raspberry Pi is defined as a minicomputer the size of a credit card that is
interoperable with any input and output hardware device like a monitor, a television, a
mouse, or a keyboard – effectively converting the set-up into a full-fledged PC at a low
cost. The Raspberry Pi operates in the open source ecosystem: it runs Linux (a variety of
distributions), and its main supported operating system, Pi OS, is open source and runs a
suite of open source software. The Raspberry Pi Foundation contributes to the Linux kernel
and various other open source projects as well as releasing much of its own software as
open source.

The raspberry pi board comprises a program memory (RAM), processor and graphics chip,
CPU, GPU, Ethernet port, GPIO pins, Xbee socket, UART, power source connector. And
various interfaces for other external devices. It also requires mass storage, for that we use
an SD flash memory card. So that raspberry pi board will boot from this SD card. Essential
hardware specifications of raspberry pi board mainly include SD card containing Linux OS,
US keyboard, monitor, power supply and video cable. Optional hardware specifications
include USB mouse, powered USB hub, case, internet connection, the Model A or B: USB
WiFi adapter is used and internet connection to Model B is LAN cable.

Ultrasonic Sensor:

An ultrasonic sensor is an electronic device that measures the distance of a target object
by emitting ultrasonic sound waves, and converts the reflected sound into an electrical
signal. Ultrasonic waves travel faster than the speed of audible sound (i.e. the sound that
humans can hear). Ultrasonic sensors have two main components: the transmitter (which
emits the sound using piezoelectric crystals) and the receiver (which encounters the sound
after it has travelled to and from the target).

Features:
Power Supply: +5V DC
Quiescent Current: <2mA
Working Current: 15mA
Effectual Angle: <15°
Ranging Distance: 2cm – 400 cm
Resolution: 0.3 cm
Measuring Angle: 30 degree
Dimension: 45mm x 20mm x 15mm

Procedure:

1) Select the required components.


2) Make the necessary connection among all the components.
3) Interface the controller to connect to the cloud.
4) Write and run the code.
5) Observe the output.

Interfacing :
Program:

import RPi.GPIO as GPIO


import time
GPIO.setmode(GPIO.BCM)
GPIO_TRIG = 11
GPIO_ECHO = 18
GPIO.setup(GPIO_TRIG, GPIO.OUT)
GPIO.setup(GPIO_ECHO, GPIO.IN)
GPIO.output(GPIO_TRIG, GPIO.LOW)
Time.sleep(2)
GPIO.output(GPIO_TRIG, GPIO.HIGH)
Time.sleep(0.00001)
GPIO.output(GPIO_TRIG, GPIO.LOW)
while GPIO.input(GPIO_ECHO)==0:
start_time = time.time()
print(f”Object not Detected”)
while GPIO.input(GPIO_ECHO)==1:
Bounce_back_time = time.time()
pulse_duration = Bounce_back_time - start_time
distance = round(pulse_duration * 17150, 2)
print(f”Object Detected”)
print (f"Distance: ‘, {distance}, ‘cm. ‘")
GPIO.cleanup()
Output:

Conclusion:

In this experiment, we have interfaced the Ultrasonic sensor with Raspberry Pi


and detected the obstacles remotely.

You might also like