GP2Y0E02B Library

gp2y0e02b

Driver for the GP2Y0E02B distance sensor

  • Author(s): Jose D. Montoya

Implementation Notes

Software and Dependencies:

class gp2y0e02b.GP2Y0E02B(i2c_bus: I2C, address: int = _I2C_ADDR)

Driver for the GP2Y0E02B Sensor connected over I2C.

Parameters:
  • i2c_bus (I2C) – The I2C bus the GP2Y0E02B is connected to.

  • address (int) – The I2C device address. Defaults to 0x40

Raises:

RuntimeError – if the sensor is not found

Quickstart: Importing and using the device

Here is an example of using the GP2Y0E02B class. First you will need to import the libraries to use the sensor

import board
import gp2y0e02b as GP2Y0E02B

Once this is done you can define your board.I2C object and define your sensor object

i2c = board.I2C()  # Uses board.SCL and board.SDA
gpy = GP2Y0E02B.GP2Y0E02B(i2c)

Now you have access to the attributes

distance = gpy.distance