i.e. Just for fun, don't use this for any serious applications
- HCSR04 sonic proximity sensor (two pin interface)
- Raspberry Pi with updated Python3/pip3
- Clone the repo onto your local machine and transfer to your Pi's filesystem, or just clone it to your Pi directly
- Navigate to the project root:
pip3 install -r requirements.txt
- Change the pin constants (TRIG_PIN, ECHO _PIN, optional LED_PIN) to match your circuit
- Be sure to call the setup method before calling other functions:
s = ProximitySensor()
s.setup()
...
- Call
sensor.scan()
in a loop for simple logging of detection and ranging data
Note that only one sensor is supported per Pi! Do not try to use multiple sensors on the same circuit, as they will interfere with each other.