Skip to content

alaudet/pinsource

Repository files navigation

Pinsource

Pinsource is a Python library for easily interacting with sensors on the Raspberry Pi. It is a fork and modernisation of hcsr04sensor. Currently supports ultrasonic distance sensors; additional sensor types are planned.


Why Pinsource?

The original name hcsr04sensor was too narrow, the library already works with other ultrasonic sensors such as the JSN-SR04T 2.0, and is intended to grow beyond that.

Pinsource uses lgpio instead of RPi.GPIO, which adds support for Raspberry Pi 5 and keeps the library compatible with current Raspberry Pi OS releases.

The license has also changed from MIT to Apache 2.0.


Supported Hardware

  • Raspberry Pi 2, 3, 4, and 5
  • Ultrasonic sensors: HC-SR04, JSN-SR04T 2.0 (waterproof). JSN-SR04T 3.0 not recommended.

Supported OS

OS Architecture
Raspberry Pi OS 13 (Trixie) 32-bit and 64-bit
Raspberry Pi OS 12 (Bookworm) 32-bit and 64-bit

Install

Pinsource is available via the Linuxnorth APT repository.

You should remove any previous versions of hcsr04sensor before doing this.

# 1. Import the signing key
curl -fsSL https://apt.linuxnorth.org/public_key.asc \
  | sudo gpg --dearmor -o /usr/share/keyrings/linuxnorth-archive-keyring.gpg

# 2. Add the repository
echo "deb [signed-by=/usr/share/keyrings/linuxnorth-archive-keyring.gpg] \
  https://apt.linuxnorth.org trixie main" \
  | sudo tee /etc/apt/sources.list.d/linuxnorth.list

# 3. Install
sudo apt update
sudo apt install python3-pinsource

Please report issues in the issue tracker.

Usage

The pinsource CLI command is a quick way to test your sensor:

pinsource --help

See the recipes/ folder for example scripts using the library directly.


Why not just use gpiozero?

gpiozero is an excellent project. Pinsource exists primarily to support Raspi-Sump with the specific measurement behaviour that application requires, and as a learning exercise in library design.


Contributing

See CONTRIBUTING.md before submitting a pull request.

Issue tracker: https://github.com/alaudet/pinsource/issues


License

Released under the Apache 2.0 License.


Copyright © 2026 Al Audet

About

A gpio sensor module

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages