Skip to content

lalugue/micropython-hcsr04

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

micropython-hcsr04

A MicroPython library/port based on Adafruit's CircuitPython HC-SR04 library.

Additionally, this MicroPython port does not contain third-party dependencies.

What is an HC-SR04?

The HC-SR04 is a module for measuring distances via ultrasonic waves. The device in itself is inexpensive and designed to be used with microcontrollers.

This library provides a driver for the module. The key difference is that this library is intended for MicroPython devices.

Usage and Example

Import the driver file hcsr04.py in one's main script and ensure that hcsr04.py is in the MicroPython device's file system for import.

This library also contains a short example:

from hcsr04 import HCSR04
import time

sonar = HCSR04(trigger_pin=2, echo_pin=3)

while True:
    try:
        print((sonar.distance,))
    except RuntimeError:
        print("Retrying!")
        pass
    time.sleep(0.1)

The example snippet is also included in examples/main.py

About

A MicroPython library/port based on Adafruit's CircuitPython HC-SR04 library

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages