Interfacing an ultrasonic sensor HC-SR04

Refer to Figure 6.17 for connection details:

Figure 6.17

As shown in Figure 6.17:

  • The Gnd terminal of the sensor is connected to GND (pin 34) of Raspberry Pi
  • The Echo terminal of the sensor is connected to GPIO 21 (pin 40) of Raspberry Pi with a 330 Ω resistor in between
  • One more connection is taken out from the Echo terminal with a 470 Ω resistor in between, from a point marked as Joint 2, and connected to the GND terminal of Raspberry Pi through Joint 1
  • The Trig terminal of the sensor is connected to GPIO 16 (pin 36) of Raspberry Pi
  • The Vcc terminal of the sensor is connected to +5V (pin 04) of ...

Get Internet of Things with Raspberry Pi 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.