Drivers¶
Device Identifier¶
-
class
Drivers.DeviceIdentifier.
DeviceIdentifier
(serials: dict)[source]¶ The DeviceIdentifier lists all connected USB devices and tries to identify all devices listed in self.serials with their respective serial port, which are subsequently available as self.serial_ports
- Parameters
serials (dict) – Dictionary with USB names as keys and USB serials as values.
Note
If the USB serials are unknown when launching the program first simply supply a dictionary with placeholders. DeviceIdentifier supplies information on all available devices upon failing to find one of the devices in the serials dictionary.
Warning
Windows detects USB serials differently than Linux. As experienced in the creating of this software, a serial read on a Linux system must be appended with the letter ‘A’ to be detected on a Windows system. To offer platform independence the serials must be given in ‘Linux-Form’ and are automatically appended with the letter ‘A’ when the program is run on Windows.
-
open
()[source]¶ Detects the current os. For Windows the letter ‘A’ is appended to the Linux-specific serial of the device. For Linux an additional tty-setup script is executed to allow detection of all USB devices. After that the serials of the available devices are compared and linked to self.serials.
- Returns
Returns True if all devices listed in self.serials could be found, False otherwise.
Platforms¶
Platform Base¶
Shdlc IO Module - The Heater¶
-
class
Drivers.Shdlc_IO.
ShdlcIoModule
(serial_port: str, baudrate=115200, slave_address=0, input_pins=None)[source]¶ Bases:
Drivers.PlatformBase.PlatformBase
The ShdlcIoModule represents the custom Sensirion HDLC IO Box that allows driving the heater with a PWM output.
- Parameters
serial_port (str) – Comport the IO box is connected to
baudrate (int) – Baudrate of the connection
slave_address (int) – Slave address
input_pins (list) – list of integers of the input pins
-
connect
() → bool[source]¶ Attempts to connect the ShdlcIoModule
- Returns
True if connected successifully, False otherwise.
-
get_analog_input
() → float[source]¶ Measures actual voltage on ADC input
- Returns
A voltage between 0-10V
-
get_analog_output
() → float[source]¶ Gets actual voltage for DAC output
- Returns
A voltage between 0-10V
-
get_digital_io
(io_bit: int) → bool[source]¶ Reads a digital io pin.
- Parameters
io_bit (int) – Output bit to read
- Returns
True if digital bit is set.
-
get_pwm
(pwm_bit: int) → int[source]¶ Reads the current pwm setting.
- Parameters
pwm_bit (int) – The index of the PWM channel to be used (0, 1)
- Returns
A duty cycle value between 0 - 65535
-
is_connected
() → bool[source]¶ Attempts to read the serial number of the device to check if it is connected.
- Returns
True if connected, False otherwise.
-
set_analog_output
(value: int) → None[source]¶ Sets the analog output
- Parameters
value (int) – A voltage between 0-10V
Sensirion Sensor Bridge (EKS)¶
-
class
Drivers.SHT.
EKS
(serial_port: str)[source]¶ Bases:
Drivers.PlatformBase.PlatformBase
EKS represents a Sensirion Sensor Bridge which is used to communicate to a range of sensor via I2C.
- Parameters
serial_port (str) – Name of the port to which the EKS is connected.
-
connect
() → bool[source]¶ Attempts to connect to the EKS.
- Returns
True if connected sucessifully, otherwise the encountered exception will be returned.
Sensors¶
Sensor Base¶
Sensirion Humidity Temperature (STH)¶
-
class
Drivers.SHT.
SHT
(device_port: int, shdlc_device: sensirion_shdlc_sensorbridge.device.SensorBridgeShdlcDevice, name='SHT')[source]¶ Bases:
Drivers.SensorBase.SensorBase
SHT represents either an SHT85 or an STH31 of the Sensirion Humidity Temperature (SHT) sensor range, connected via the Sensirion Sensor Bridge (EKS).
- Parameters
device_port (SensorBridgePort) – EKS port, either ONE or TWO.
shdlc_device (SensorBridgeShdlcDevice) – Instance of the controlling EKS.
name (str) – Name of the sensor.
-
_convert_humidity
(data: bytearray) → float[source]¶ Converts the raw sensor data to the actual measured humidity according to the data sheet Sensirion_Humidity_Sensors_SHT3x
- Parameters
data (bytearray) – 2 bytes, namely number 4 (humidity MSB) and 5 (humidity LSB) of the answer delivered by the sensor.
- Returns
The relative humidity measured by the sensor in percent.
-
_convert_temperature
(data: bytearray) → float[source]¶ Converts the raw sensor data to the actual measured temperature according to the data sheet Sensirion_Humidity_Sensors_SHT3x
- Parameters
data (bytearray) – 2 bytes, namely number 1 (temperature MSB) and 2 (humidity LSB) of the answer delivered by the sensor.
- Returns
The temperature measured by the sensor in degrees Celsius.
-
connect
() → bool[source]¶ Attempts to connect the sensor and signals success by blinking the corresponding port’s LEDs.
- Returns
Returns True if connected successifully, False otherwise.
-
connect_sensor
(supply_voltage: float, frequency: int) → None[source]¶ Connection of a sensor attached to the sensirion sensor bridge according to the quick start guide to sensirion-shdlc-sensorbridge.
- Parameters
supply_voltage (float) – Desired supply voltage in Volts.
frequency (int) – I2C frequency in Hz
-
disconnect
() → None[source]¶ Called by SensorBase.close upon deletion of this class. Switches supply off.
-
is_connected
() → bool[source]¶ Check if the sensor operates correctly
- Returns
True if the status register can be read, False otherwise
Sensirion Mass Flow Meter / Controller (SFM / SFC)¶
-
class
Drivers.SFX5400.
SFX5400
(serial_port: str, name='Sfc5400')[source]¶ Bases:
Drivers.SensorBase.SensorBase
SFX5400 represents either a Sensirion Flow Controller (SFC) or a Sensirion Flow Meter (SFM) of type 5400.
- Parameters
serial_port (str) – Name of the comport the SFX is connected to.
name (str) – Name of the device.
-
connect
() → bool[source]¶ Attempts to connect to the SFX and reports success.
- Returns
True if connected successifully, False otherwise.
-
get_device_information
(index: int) → str[source]¶ Retrieves device information depending on the index given.
- Parameters
index (int) –
Integer between 1 and 3 to request on of the data below:
Product Name
Article Code
Serial number
- Returns
String containing the requested information.
-
is_connected
()[source]¶ Checks if the device is connected by reading its serial number.
- Returns
True if connected, False if not.