SlideShare a Scribd company logo
1 of 8
1
Raspberry Tutorial #3
- Measuring the distance -
Dong Ho Son
POSTECH
Pohang, Korea
donghoson@postech.ac.kr
2
Measuring the distance - Overview
 Let’s use the sensor
• Ultrasonic distance sensor
− A sensor that can measure the distance to an object by using sound waves
Source: education.rec.ri.cmu.edu/content/electronics/boe/ultrasonic_sensor/1.html
3
Measuring the distance - components
 Let’s measure the distance
 Necessary Components
• 1 x Raspberry Pi
• 1 x Breadboard
• 2 x Resistor
• 1 x Ultrasonic sensor
• Jumper cables
4
Measuring the distance – Circuit Configuration
 VCC  5V pin
 Trig  the pin GPIO 18
 Echo  resistors
 GND  Ground pin
5
Measuring the distance - Python
6
Measuring the distance - Python
 GPIO.setup(GPIO_TRIGGER, GPIO.OUT)
• Select GPIO #18 as output pin
• To make ultrasonic signal
 GPIO.setup(GPIO_ECHO, GPIO.IN)
• Select GPIO #24 as input pin
• To receive the signal
 GPIO.output(GPIO_TRIGGER, True)
time.sleep(0.00001)
GPIO.output(GPIO_TRIGGER, False)
• Send the ultrasonic signal
7
Measuring the distance - Python
 GPIO.input(GPIO_ECHO)
• High while sending signal
• Low when signal is returned
 TimeElapsed = StopTime – StartTime
• Time difference between start and arrival
 distance = (TimeElapsed * 34300) / 2
• Multiply with the sonic speed 34300 cm/s
• Divide by 2, because there and back
8
Measuring the distance - Result
 Distance is measured!

More Related Content

Similar to Raspberry pi tutorial #3

Forest bouandary alert system for animal
Forest bouandary alert system for animalForest bouandary alert system for animal
Forest bouandary alert system for animalRiken Suthar
 
Iaetsd ethernet based intelligent security system
Iaetsd ethernet based intelligent security systemIaetsd ethernet based intelligent security system
Iaetsd ethernet based intelligent security systemIaetsd Iaetsd
 
DTW EVEN SEM PROJECT.pptx
DTW EVEN SEM PROJECT.pptxDTW EVEN SEM PROJECT.pptx
DTW EVEN SEM PROJECT.pptxAkshay422454
 
SENSORS AND BLUETOOTH COMMUNICATION
SENSORS AND BLUETOOTH COMMUNICATIONSENSORS AND BLUETOOTH COMMUNICATION
SENSORS AND BLUETOOTH COMMUNICATIONsoma saikiran
 
Ultrsonic sensor_Arduino_DRKG.pptx
Ultrsonic sensor_Arduino_DRKG.pptxUltrsonic sensor_Arduino_DRKG.pptx
Ultrsonic sensor_Arduino_DRKG.pptxKesavanGopal1
 
60 hz Electromagnetic Field Detection-Interface System
60 hz Electromagnetic Field Detection-Interface System60 hz Electromagnetic Field Detection-Interface System
60 hz Electromagnetic Field Detection-Interface SystemGaurav Jaina
 
Ultrasonic sensor
Ultrasonic sensorUltrasonic sensor
Ultrasonic sensorAdarsh Raj
 
Ultrasonicsensor 170828140914
Ultrasonicsensor 170828140914Ultrasonicsensor 170828140914
Ultrasonicsensor 170828140914amitshaha3
 
Ultrasonic sensors
Ultrasonic sensorsUltrasonic sensors
Ultrasonic sensorsAnCh24
 
Sensor and Actuators using Rasberry Pi controller
Sensor and Actuators using Rasberry Pi controllerSensor and Actuators using Rasberry Pi controller
Sensor and Actuators using Rasberry Pi controllerArsalanAthar
 
Distance measuring unit with zigbee protocol, Ultra sonic sensor
Distance measuring unit with zigbee protocol, Ultra sonic sensorDistance measuring unit with zigbee protocol, Ultra sonic sensor
Distance measuring unit with zigbee protocol, Ultra sonic sensorAshok Raj
 
ultrasonic sensor.pptx
ultrasonic sensor.pptxultrasonic sensor.pptx
ultrasonic sensor.pptxAiganymNurbek
 
HC-SR04 Ultrasonic sensor with Arduino
HC-SR04 Ultrasonic sensor with ArduinoHC-SR04 Ultrasonic sensor with Arduino
HC-SR04 Ultrasonic sensor with Arduinoyeokm1
 
A Pyroelectric Infrared Sensor
A Pyroelectric Infrared SensorA Pyroelectric Infrared Sensor
A Pyroelectric Infrared Sensorbgbgbg
 

Similar to Raspberry pi tutorial #3 (20)

Forest bouandary alert system for animal
Forest bouandary alert system for animalForest bouandary alert system for animal
Forest bouandary alert system for animal
 
SENSOR DATA COMMUNICATION TO THNIGSPEAK IOT PLATFORM USING RASPBERRY P
SENSOR DATA COMMUNICATION TO THNIGSPEAK  IOT PLATFORM USING RASPBERRY PSENSOR DATA COMMUNICATION TO THNIGSPEAK  IOT PLATFORM USING RASPBERRY P
SENSOR DATA COMMUNICATION TO THNIGSPEAK IOT PLATFORM USING RASPBERRY P
 
Iaetsd ethernet based intelligent security system
Iaetsd ethernet based intelligent security systemIaetsd ethernet based intelligent security system
Iaetsd ethernet based intelligent security system
 
DTW EVEN SEM PROJECT.pptx
DTW EVEN SEM PROJECT.pptxDTW EVEN SEM PROJECT.pptx
DTW EVEN SEM PROJECT.pptx
 
SENSORS AND BLUETOOTH COMMUNICATION
SENSORS AND BLUETOOTH COMMUNICATIONSENSORS AND BLUETOOTH COMMUNICATION
SENSORS AND BLUETOOTH COMMUNICATION
 
Ultrsonic sensor_Arduino_DRKG.pptx
Ultrsonic sensor_Arduino_DRKG.pptxUltrsonic sensor_Arduino_DRKG.pptx
Ultrsonic sensor_Arduino_DRKG.pptx
 
4th-Yr-PROJECT-REPORT
4th-Yr-PROJECT-REPORT4th-Yr-PROJECT-REPORT
4th-Yr-PROJECT-REPORT
 
ULTRASONIC PERIPATETIC SCANNER FOR AUTONOMOUS TEST BENCH USING RASPBERRY Pi
ULTRASONIC PERIPATETIC SCANNER FOR AUTONOMOUS TEST BENCH USING RASPBERRY PiULTRASONIC PERIPATETIC SCANNER FOR AUTONOMOUS TEST BENCH USING RASPBERRY Pi
ULTRASONIC PERIPATETIC SCANNER FOR AUTONOMOUS TEST BENCH USING RASPBERRY Pi
 
60 hz Electromagnetic Field Detection-Interface System
60 hz Electromagnetic Field Detection-Interface System60 hz Electromagnetic Field Detection-Interface System
60 hz Electromagnetic Field Detection-Interface System
 
Lab2ppt
Lab2pptLab2ppt
Lab2ppt
 
Ultrasonic sensor
Ultrasonic sensorUltrasonic sensor
Ultrasonic sensor
 
Ultrasonicsensor 170828140914
Ultrasonicsensor 170828140914Ultrasonicsensor 170828140914
Ultrasonicsensor 170828140914
 
Ultrasonic sensors
Ultrasonic sensorsUltrasonic sensors
Ultrasonic sensors
 
Sensor and Actuators using Rasberry Pi controller
Sensor and Actuators using Rasberry Pi controllerSensor and Actuators using Rasberry Pi controller
Sensor and Actuators using Rasberry Pi controller
 
Distance measuring unit with zigbee protocol, Ultra sonic sensor
Distance measuring unit with zigbee protocol, Ultra sonic sensorDistance measuring unit with zigbee protocol, Ultra sonic sensor
Distance measuring unit with zigbee protocol, Ultra sonic sensor
 
ultrasonic sensor.pptx
ultrasonic sensor.pptxultrasonic sensor.pptx
ultrasonic sensor.pptx
 
HC-SR04 Ultrasonic sensor with Arduino
HC-SR04 Ultrasonic sensor with ArduinoHC-SR04 Ultrasonic sensor with Arduino
HC-SR04 Ultrasonic sensor with Arduino
 
Radar Detector
Radar Detector Radar Detector
Radar Detector
 
A Pyroelectric Infrared Sensor
A Pyroelectric Infrared SensorA Pyroelectric Infrared Sensor
A Pyroelectric Infrared Sensor
 
EFFICIENT EMBEDDED SURVEILLANCE SYSTEM WITH AUTO IMAGE CAPTURING AND EMAIL SE...
EFFICIENT EMBEDDED SURVEILLANCE SYSTEM WITH AUTO IMAGE CAPTURING AND EMAIL SE...EFFICIENT EMBEDDED SURVEILLANCE SYSTEM WITH AUTO IMAGE CAPTURING AND EMAIL SE...
EFFICIENT EMBEDDED SURVEILLANCE SYSTEM WITH AUTO IMAGE CAPTURING AND EMAIL SE...
 

More from 동호 손

Raspberry pi : how to get started
Raspberry pi : how to get startedRaspberry pi : how to get started
Raspberry pi : how to get started동호 손
 
Introduction to raspberry pi
Introduction to raspberry piIntroduction to raspberry pi
Introduction to raspberry pi동호 손
 
Arduino tutorial #2
Arduino tutorial #2Arduino tutorial #2
Arduino tutorial #2동호 손
 
Arduino tutorial #1
Arduino tutorial #1Arduino tutorial #1
Arduino tutorial #1동호 손
 
Arduino : how to get started
Arduino : how to get startedArduino : how to get started
Arduino : how to get started동호 손
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to Arduino동호 손
 
OpenVirtex (OVX) Tutorial
OpenVirtex (OVX) TutorialOpenVirtex (OVX) Tutorial
OpenVirtex (OVX) Tutorial동호 손
 

More from 동호 손 (7)

Raspberry pi : how to get started
Raspberry pi : how to get startedRaspberry pi : how to get started
Raspberry pi : how to get started
 
Introduction to raspberry pi
Introduction to raspberry piIntroduction to raspberry pi
Introduction to raspberry pi
 
Arduino tutorial #2
Arduino tutorial #2Arduino tutorial #2
Arduino tutorial #2
 
Arduino tutorial #1
Arduino tutorial #1Arduino tutorial #1
Arduino tutorial #1
 
Arduino : how to get started
Arduino : how to get startedArduino : how to get started
Arduino : how to get started
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to Arduino
 
OpenVirtex (OVX) Tutorial
OpenVirtex (OVX) TutorialOpenVirtex (OVX) Tutorial
OpenVirtex (OVX) Tutorial
 

Recently uploaded

Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 

Recently uploaded (20)

9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 

Raspberry pi tutorial #3

  • 1. 1 Raspberry Tutorial #3 - Measuring the distance - Dong Ho Son POSTECH Pohang, Korea donghoson@postech.ac.kr
  • 2. 2 Measuring the distance - Overview  Let’s use the sensor • Ultrasonic distance sensor − A sensor that can measure the distance to an object by using sound waves Source: education.rec.ri.cmu.edu/content/electronics/boe/ultrasonic_sensor/1.html
  • 3. 3 Measuring the distance - components  Let’s measure the distance  Necessary Components • 1 x Raspberry Pi • 1 x Breadboard • 2 x Resistor • 1 x Ultrasonic sensor • Jumper cables
  • 4. 4 Measuring the distance – Circuit Configuration  VCC  5V pin  Trig  the pin GPIO 18  Echo  resistors  GND  Ground pin
  • 6. 6 Measuring the distance - Python  GPIO.setup(GPIO_TRIGGER, GPIO.OUT) • Select GPIO #18 as output pin • To make ultrasonic signal  GPIO.setup(GPIO_ECHO, GPIO.IN) • Select GPIO #24 as input pin • To receive the signal  GPIO.output(GPIO_TRIGGER, True) time.sleep(0.00001) GPIO.output(GPIO_TRIGGER, False) • Send the ultrasonic signal
  • 7. 7 Measuring the distance - Python  GPIO.input(GPIO_ECHO) • High while sending signal • Low when signal is returned  TimeElapsed = StopTime – StartTime • Time difference between start and arrival  distance = (TimeElapsed * 34300) / 2 • Multiply with the sonic speed 34300 cm/s • Divide by 2, because there and back
  • 8. 8 Measuring the distance - Result  Distance is measured!