hcsr04sensor - Python Module

Donate | PDF Manual

Fork Star Issue Watch

HCSR04 Sensor

Installing hcsr04sensor

sudo apt install python3-pip python3-rpi.gpio
sudo pip3 install hcsr04sensor


The python hcsr04sensor module source code is available on Github.


The Raspi-Sump Discord group has a new channel called #hcsr04sensor. This is one place you can ask questions specifically about the module. While Raspi-Sump uses this module it can also be used for other applications. This is the place to discuss non Raspi-Sump issues related to hcsr04sensor.

If you are interested contact me for an invite link. You need to have a Discord account to join.


Use Python to calculate distance, depth and volume measurements with an HCSR04 Ultrasonic Sound Sensor and a Raspberry Pi. The module also works with a waterproof JSN-SR04T sensor.

The module does the following;

Connecting the Sensor

The HCSR04 sensor has four pins.