Reader small image

You're reading from  Practical Python Programming for IoT

Product typeBook
Published inNov 2020
Reading LevelIntermediate
PublisherPackt
ISBN-139781838982461
Edition1st Edition
Languages
Right arrow

Measuring distance with an ultrasonic sensor

In the previous section, we learned how to detect movement with a PIR sensor. As we discovered, our PIR sensor was a digital device that signaled movement detection by making its output a digital HIGH.

It's time to learn how to measure distance with our Raspberry Pi. There are a variety of sensors that are capable of performing this task, and they commonly either work with sound or light. Our example will be based around the popular HC-SR04 ultrasonic distance sensor (it works on sound), as pictured in the following figure:

Figure 11.4 – HC-SR04 ultrasonic distance sensor module

A place where you commonly find ultrasonic distance sensors is modern car bumper bars (they're often little round circles, which is a different form factor than the HC-SR04 pictured in the preceding figure). These sensors calculate the distance between your car and a nearby object and, for example, make a beeper inside your car...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Practical Python Programming for IoT
Published in: Nov 2020Publisher: PacktISBN-13: 9781838982461