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¶
- Raises¶
RuntimeError – if the sensor is not found
Quickstart: Importing and using the device
Here is an example of using the
WSENTIDSclass. First you will need to import the libraries to use the sensorfrom machine import Pin, I2C from micropython_wsentids import wsentidsOnce this is done you can define your
machine.I2Cobject and define your sensor objecti2c = I2C(1, sda=Pin(2), scl=Pin(3)) wsentids = wsentids.WSENTIDS(i2c)Now you have access to the attributes
- 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_DISABLED0b0wsentids.BDU_ENABLED0b1
- 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_modeIn power-down mode, New measurements are not performed during this mode. Thetemperaturecontains 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_DISABLED0b0wsentids.CONTINUOUS_ENABLED0b1
- property data_rate : str¶
Sensor data_rate
Mode
Value
wsentids.RATE_25_HZ0b00wsentids.RATE_50_HZ0b01wsentids.RATE_100_HZ0b10wsentids.RATE_200_HZ0b11
- property high_limit : int¶
The high temperature limit in Celsius. When the measured temperature exceeds this value, the
high_alertattribute of thealert_statusproperty will be True.
- property low_limit : int¶
The low temperature limit in Celsius. When the measured temperature goes below this value, the
low_alertattribute of thealert_statusproperty will be True.