Distance Sensor
You have received HC-SR04 ultrasonic distance sensors. This module, which measures distances using ultrasonic waves, consists of four pins:
VCC: sensor power supply (3.3V)
Trig: trigger pin
Echo: echo reception pin
GND: ground
Input and Output Voltages
Power supply voltage (VCC): 3.3V
Output voltage (Echo): 3.3V
Operation
Triggering: To initiate a measurement, a 10-microsecond signal must be sent to the Trig pin. This triggers the emission of a burst of 8 ultrasonic pulses at 40 kHz.
Reception: The sensor then waits to receive the echo of these pulses. When the echo is detected, the Echo pin goes high.
Time Measurement: The duration for which the Echo pin remains high corresponds to the time taken by the ultrasonic wave to travel to the obstacle and back.
Reminder: The speed of sound in air is approximately 343 m/s.
Connection to the Raspberry Pi
Warning
Be careful not to connect the VCC pin to the 5V output of the board, as this could damage it.
Connect the sensor’s VCC pin to a 3.3V pin on the Raspberry Pi.
Connect the sensor’s GND pin to a GND pin on the Raspberry Pi.
Connect the sensor’s Trig pin to a GPIO pin on the Raspberry Pi (e.g., GPIO 10).
Connect the sensor’s Echo pin to another GPIO pin on the Raspberry Pi (e.g., GPIO 9).