MicroPython WSENTIDS Library

wsentids

MicroPython library for the WSEN WSEN-TIDS temperature Sensor

  • Author(s): Jose D. Montoya

class micropython_wsentids.wsentids.AlertStatus(high_alert, low_alert)

Create new instance of AlertStatus(high_alert, low_alert)

high_alert

Alias for field number 0

low_alert

Alias for field number 1

class micropython_wsentids.wsentids.WSENTIDS(i2c, address: int = 0x3F)[source]

Driver for the WSENTIDS Sensor connected over I2C.

Parameters:
i2c : I2C

The I2C bus the WSENTIDS is connected to.

address : int

The I2C device address. Defaults to 0x69

Raises:

RuntimeError – if the sensor is not found

Quickstart: Importing and using the device

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

from machine import Pin, I2C
from micropython_wsentids import wsentids

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

i2c = I2C(1, sda=Pin(2), scl=Pin(3))
wsentids = wsentids.WSENTIDS(i2c)

Now you have access to the attributes

temp = wsentids.temperature
property alert_status

The current triggered status of the high and low temperature alerts as a AlertStatus named tuple with attributes for the triggered status of each alert.

import time
from machine import Pin, I2C
from micropython_wsentids import wsentids

i2c = I2C(1, sda=Pin(2), scl=Pin(3))  # Correct I2C pins for RP2040
wsen = wsentids.WSENTIDS(i2c)

wsen.low_limit = 20
wsen.high_limit = 23

print("High limit", wsen.high_limit)
print("Low limit", wsen.low_limit)


while True:
    print("Temperature: {:.1f}C".format(wsen.temperature))
    alert_status = tmp.alert_status
    if alert_status.high_alert:
        print("Temperature above high set limit!")
    if alert_status.low_alert:
        print("Temperature below low set limit!")
    print("Low alert:", alert_status.low_alert)
    time.sleep(1)
property block_data_update : str

Sensor block_data_update used to inhibit the output register update between the reading of the upper and lower register parts. In default mode (BDU = ‘0’), the lower and upper register parts are updated continuously. it is recommended to set the BDU bit to ‘1’. In this way, after the reading of the lower (upper) register part, the content of that output register is not updated until the upper (lower) part is read also.

Mode

Value

wsentids.BDU_DISABLED

0b0

wsentids.BDU_ENABLED

0b1

property continuous_mode : str

Sensor continuous_mode

The continuous mode constantly samples new temperature measurements and writes the data to the temperature data registers.

The power-down mode can be configured by disabling continuous_mode In power-down mode, New measurements are not performed during this mode. The temperature contains the last sampled temperature value before going into power-down mode. Sensor is in power-down mode by default after the power-up sequence.

Mode

Value

wsentids.CONTINUOUS_DISABLED

0b0

wsentids.CONTINUOUS_ENABLED

0b1

property data_rate : str

Sensor data_rate

Mode

Value

wsentids.RATE_25_HZ

0b00

wsentids.RATE_50_HZ

0b01

wsentids.RATE_100_HZ

0b10

wsentids.RATE_200_HZ

0b11

property high_limit : int

The high temperature limit in Celsius. When the measured temperature exceeds this value, the high_alert attribute of the alert_status property will be True.

property low_limit : int

The low temperature limit in Celsius. When the measured temperature goes below this value, the low_alert attribute of the alert_status property will be True.

reset() None[source]

Resets the sensor

property temperature : float

Return the sensor temperature