MicroPython DS1841 Driver

ds1841

MicroPython Driver for the DS1841 Potentiometer

  • Author(s): Bryan Siepert, Jose D. Montoya

class micropython_ds1841.ds1841.DS1841(i2c, address: int = 0x28)[source]

Driver for the DS1841 Sensor connected over I2C.

Parameters:
i2c : I2C

The I2C bus the DS1841 is connected to.

address : int

The I2C device address. Defaults to 0x28

Raises:

RuntimeError – if the sensor is not found

Quickstart: Importing and using the device

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

from machine import Pin, I2C
from micropython_ds1841 import ds1841

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))
ds1841 = ds1841.DS1841(i2c)
property lut_mode_enabled : bool

Enables LUT mode. LUT mode takes sets the value of the Wiper based on the entry in a 72-entry Look Up Table. The LUT entry is selected using the lut_selection property to set an index from 0-71

property lut_selection : int

Choose the entry in the Look Up Table to use to set the wiper. :param value: The index of the entry to use, from 0-71.

property temperature : int

The current temperature in Celsius

property voltage : float

The current voltage between VCC and GND

property wiper : int

The value of the potentionmeter’s wiper. :param wiper_value: The value from 0-127 to set the wiper to.

property wiper_default : int

Sets the wiper’s default value and current value to the given value :param new_default: The value from 0-127 to set as the wiper’s default.