urm09

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 16, 2023 License: GPL-3.0 Imports: 3 Imported by: 0

README

go-urm09driver

This is a Go module useful for controlling the URM09 ultrasonic ranging sensor on a Raspberry Pi or similar devices. The board is controlled over i2c.

Note: this driver is by no means done or fully tested.

Installation

go get github.com/MrBuggy-Amsterdam/go-urm09driver

Usage

After initializing the sensor on a specific bus (the i2c device used) and address (0x11 by default) you will have access to the ReadDinstance() function and can also enable passive mode as shown below (See the official docs).

package main

import (
    urm09 "github.com/MrBuggy-Amsterdam/go-urm09driver"
)

func main() {
	urm := urm09.Initialize(1, 0x11)

	// Enable passive mode for  on-demand ranging
	err := urm.EnablePassiveMode()
	if err != nil {
		// Do something with the error
	}

	distance, err := urm.ReadDistance()
	if err != nil {
		// Do something with the error
	}
}

Troubleshooting

A good start is to use i2cdetect to scan your i2c bus and confirm that your device is connected. Also make sure to read the official docs.

Open an issue or PR to let us know of any issues you encounter.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type URM09

type URM09 struct {
	// contains filtered or unexported fields
}

Device wraps an I2C connection to a MPU6050 device. based on: https://wiki.dfrobot.com/URM09_Ultrasonic_Sensor_(Gravity-I2C)_(V1.0)_SKU_SEN0304

func Initialize

func Initialize(bus uint, address uint8) *URM09

Initialize a URM09 device on the specified I2C bus and address (default is 0x11)

func (*URM09) EnablePassiveMode

func (u *URM09) EnablePassiveMode() error

func (*URM09) ReadDistance

func (u *URM09) ReadDistance() (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL