pyupm_hcsr04 module

class pyupm_hcsr04.HCSR04(triggerPin, echoPin)[source]

Bases: object

API for the HC-SR04 Ultrasonic Sensor.

ID: hcsr04

Name: Ultrasonic Distance Measuring Sensor

Category: sound

Manufacturer: generic

Connection: gpio

Link:https://www.sparkfun.com/products/13959 This module defines the HC-SR04 interface for libhcsr04

C++ includes: hcsr04.hpp

getDistance(unit)[source]

double getDistance(HCSR04_U unit)

Gets the distance from the sensor

unit: Selects units for measurement

pyupm_hcsr04.hcsr04_close(dev)[source]

void hcsr04_close(hcsr04_context dev)

HCSR04 Close function

dev: hcsr04_context pointer

pyupm_hcsr04.hcsr04_get_distance(dev, unit)[source]

double hcsr04_get_distance(hcsr04_context dev, HCSR04_U unit)

Function to get the distance from the HCSR04 sensor

unit: cm/inches

distance in specified unit

pyupm_hcsr04.hcsr04_init(triggerPin, echoPin)[source]

hcsr04_context hcsr04_init(int triggerPin, int echoPin)

HCSR04 Initialization function

triggerPin: GPIO pin for trigger

echoPin: GPIO pin used for output from sensor

hcsr04_context