Sensor Components

HC-SR04 Ultrasonic Ranging Module

TODO Insert wiring diagram.

class com.diozero.devices.HCSR04 (triggerGpioNum, echoGpioNum) source

Implements support for the HC-SR04 Ultrasonic Ranging Module.

  • triggerGpioNum (int) - GPIO pin connected to the HC-SR04 trigger pin.

  • echoGpioNum (int) - GPIO pin connected to the HC-SR04 echo pin.

float getDistanceCm ()

Get distance in cm.

Bosch BMP180

class com.diozero.devices.BMP180 (mode) source

Implements support for the Bosch Sensortec BMP180 temperature and pressure sensor.

  • mode (BMPMode) - BMP operating mode (Ultra-Low Power, Standard, High Resolution, Ultra-High Resolution).
float getPressure ()

Read the barometric pressure (in hPa) from the device.

float getTemperature ()

Read the temperature (in °C) from the device.

Bosch BME280

class com.diozero.devices.BME280 (bus=1, address=0x76) source

Implements support for the Bosch Sensortec BME280 pressure, humidity and temperature sensor.

  • bus (int) - I2C bus number.

  • address (int) - I2C device address.

setOperatingModes (tempOversampling, pressOversampling, humOversampling, operatingMode)

Set the oversampling and operating modes

  • tempOversampling (TemperatureOversampling) - Temperature oversampling mode (1, 2, 4, 8, 16)

  • pressOversampling (PressureOversampling) - Pressure oversampling mode (1, 2, 4, 8, 16)

  • humOversampling (HumidityOversampling) - Humidity oversampling mode (1, 2, 4, 8, 16)

  • operatingMode (OperatingMode) - Device operating mode (Sleep, Forced, Normal)

setStandbyAndFilterModes (standbyMode, filterMode)

Set the standby and filter modes

  • standbyMode (StandbyMode) - The standby mode (0.5ms, 62.5ms, 125ms, 250ms, 500ms, 1000ms, 10ms, 20ms)

  • filterMode (FilterMode) - The filter mode (Off, 2, 4, 8, 16 samples)

float getTemperature ()

Read the temperature (in °C) from the device.

float getPressure ()

Read the barometric pressure (in hPa) from the device.

float getHumidity ()

Read the humidity from the device.

TSL2561 Digital Luminosity / Lux / Light Sensor

class com.diozero.devices.TSL2561 (tsl2561Package) source

Implements support for the Adafruit Digital Luminosity / Lux / Light Sensor - Datasheet.

  • tsl2561Package (int) - TSL package information (values are CS or T / FN / CL).
setAutoGain (autoGain)

Enable or disable the auto-gain settings when reading data from the sensor.

  • autoGain (boolean) - Auto-gain flag.
setGain (gain)

Adjusts the gain on the TSL2561 (adjusts the sensitivity to light).

  • gain (int) - Gain value.
float getLuminosity ()

Get luminosity in Lux.

STMicroelectronics HTS221 Humidity and Temperature Sensor

class com.diozero.devices.HTS221 source

Implements support for the STMicroelectronics Humidity and Temperature Sensor - Datasheet.

float getHumidity ()

Read the humidity from the device.

float getTemperature ()

Read the temperature (in °C) from the device.

STMicroelectronics LPS25H Pressure and Temperature Sensor

class com.diozero.devices.LPS25H source

Implements support for the STMicroelectronics Pressure and Temperature Sensor - Datasheet.

float getPressure ()

Read the barometric pressure (in hPa) from the device.

float getTemperature ()

Read the temperature (in °C) from the device.

1-Wire Temperature Sensors

class com.diozero.devices.W1ThermSensor source

Support for 1-wire temperature sensors such as the DS18B20. Adafruit has a good article on connecting these to the Raspberry Pi. Currently supported types: DS18S20, DS1822, DS18B20, DS1825, DS28EA00, MAX31850K.

static List<W1ThermSensor> getAvailableSensors (folder="/sys/bus/w1/devices")

Class-level operation to get a list of all supported 1-wire device instances currently connected.

  • folder (String) - System folder containing the devices, defaults to "/sys/bus/w1/devices".
float getTemperature ()

Get the temperature in &#deg;C.

W1TermSensor.Type getType ()

Get the type of this 1-wire sensor instance.

String getSerialNumber ()

Get the serial number for this 1-wire sensor instance.

Sharp GP2Y0A21YK

class com.diozero.devices.GP2Y0A21YK (gpio, vRef) source

Implements support for the Sharp GP2Y0A21YK distance sensor - Datasheet.

  • gpio (int) - GPIO

  • vRef (float) - Reference voltage for the ADC

float getDistanceCm ()

Get the distance in cm.

Mifare RC522 (MFRC522)

class com.diozero.devices.MFRC522 (controller, chipSelect, resetGpio) source

Implements support for RFID cards such as the Mifare MFRC522.

  • controller (int) - SPI controller number

  • chipSelect (int) - SPI CS number

  • resetGpio (int) - Reset pin GPIO number