py-opc-ng package

Module contents

opcng.detect(spi)

Try to autodetect a device parsing information string

Parameters:

spi – SPI device instance as returned by SpiDev or USBiss

Returns:

an OPC_(N3,N2,R1,R2) instance, check type() to see if the device was properly detected.

class opcng.OPCN2(spi)

Bases: _OPC

OPC-N2

Experimental support, only tested with firmware 18

Parameters:

spi – a SPI device as returned by SpiDev or USBiss

fwversion()

Query device firmware version

histogram(raw=False)

Query and decode histogram data.

Parameters:

raw – if True do not post process data (e.g. converting raw temperature to degrees etc.) and return raw numbers instead.

Returns:

a dictionary of histogram bins and auxiliary data

info()

Query device information

off()

Power off peripherals.

on()

Power on peripherals (laser and fan).

Wait at least 600ms for the fan speed to settle and power absorption peak to pass before sending more commands.

ping()

Check device status. Returns True if the device is responding.

pm()

Query particle mass loadings.

Returns:

a dictionary containing PM1, PM2.5 and PM10 data.

power_state()

Report peripherals and digital pots state.

Returns:

a dictionary of each peripheral current state.

Example:

>>> o = OPCN2(spi)
>>> o.power_state()
{'FanON': 1, 'LaserON': 1, 'FanDACVal': 255, 'LaserDACVal': 164}
read_config()

Query configuration variables.

Returns:

a dictionary of configuration variables as described

by Alphasense Supplemental SPI Information document.

serial()

Query device serial

update_config(update_dict)

Update configuration variables.

Reads current configuration variables and update selected key/value pairs. Configuration is not stored in non-volatile memory so a power cycle will rset configuration to previously stored state.

Parameters:

update_dict – a dictionary of configuration values to update

Example:

# remap PM2.5 to PM4.5 on OPCN3 >>> o = OPCN3(spi) >>> o.update_config(({ ‘M_B’: 450 });)

class opcng.OPCN3(spi)

Bases: _OPC

OPC-N3

Parameters:

spi – a SPI device as returned by SpiDev or USBiss

fan_off()

Power off fan.

fan_on()

Power on fan.

Wait at least 600ms for the fan speed to settle and power absorption peak to pass before sending more commands.

fwversion()

Query device firmware version

histogram(raw=False)

Query and decode histogram data.

Parameters:

raw – if True do not post process data (e.g. converting raw temperature to degrees etc.) and return raw numbers instead.

Returns:

a dictionary of histogram bins and auxiliary data

info()

Query device information

laser_off()

Power off laser.

laser_on()

Power on laser.

off()

Power off peripherals (both laser and fan).

on()

Power on peripherals (both laser and fan).

Wait at least 600ms for the fan speed to settle and power absorption peak to pass before sending more commands.

ping()

Check device status. Returns True if the device is responding.

pm()

Query particle mass loadings.

Returns:

a dictionary containing PM1, PM2.5 and PM10 data.

power_state()

Report peripherals and digital pots state.

Returns:

a dictionary of each peripheral current state.

Example:

>>> o = OPCN3(spi)
>>> o.power_state()
{'FanON': 0,
 'LaserON': 1,
 'FanDACVal': 255,
 'LaserDACVal': 140,
 'LaserSwitch': 0,
 'GainToggle': 3}
read_config()

Query configuration variables.

Returns:

a dictionary of configuration variables as described

by Alphasense Supplemental SPI Information document.

reset()

Reset device.

Not so clear what it really does, poorly documented in manufacturer docs.

serial()

Query device serial

update_config(update_dict)

Update configuration variables.

Reads current configuration variables and update selected key/value pairs. Configuration is not stored in non-volatile memory so a power cycle will rset configuration to previously stored state.

Parameters:

update_dict – a dictionary of configuration values to update

Example:

# remap PM2.5 to PM4.5 on OPCN3 >>> o = OPCN3(spi) >>> o.update_config(({ ‘M_B’: 450 });)

class opcng.OPCR1(spi)

Bases: _OPC

OPC-R1

Parameters:

spi – a SPI device as returned by SpiDev or USBiss

fwversion()

Query device firmware version

histogram(raw=False)

Query and decode histogram data.

Parameters:

raw – if True do not post process data (e.g. converting raw temperature to degrees etc.) and return raw numbers instead.

Returns:

a dictionary of histogram bins and auxiliary data

info()

Query device information

off()

Power off peripherals (both laser and fan).

on()

Power on peripherals (both laser and fan).

Wait at least 600ms for the fan speed to settle and power absorption peak to pass before sending more commands.

ping()

Check device status. Returns True if the device is responding.

pm()

Query particle mass loadings.

Returns:

a dictionary containing PM1, PM2.5 and PM10 data.

read_config()

Query configuration variables.

Returns:

a dictionary of configuration variables as described

by Alphasense Supplemental SPI Information document.

reset()

Reset device.

Not so clear what it really does, poorly documented in manufacturer docs.

serial()

Query device serial

update_config(update_dict)

Update configuration variables.

Reads current configuration variables and update selected key/value pairs. Configuration is not stored in non-volatile memory so a power cycle will rset configuration to previously stored state.

Parameters:

update_dict – a dictionary of configuration values to update

Example:

# remap PM2.5 to PM4.5 on OPCN3 >>> o = OPCN3(spi) >>> o.update_config(({ ‘M_B’: 450 });)

class opcng.OPCR2(spi)

Bases: OPCR1

fwversion()

Query device firmware version

histogram(raw=False)

Query and decode histogram data.

Parameters:

raw – if True do not post process data (e.g. converting raw temperature to degrees etc.) and return raw numbers instead.

Returns:

a dictionary of histogram bins and auxiliary data

info()

Query device information

off()

Power off peripherals (both laser and fan).

on()

Power on peripherals (both laser and fan).

Wait at least 600ms for the fan speed to settle and power absorption peak to pass before sending more commands.

ping()

Check device status. Returns True if the device is responding.

pm()

Query particle mass readings.

read_config()

Query configuration variables.

Returns:

a dictionary of configuration variables as described

by Alphasense Supplemental SPI Information document.

reset()

Reset device.

Not so clear what it really does, poorly documented in manufacturer docs.

serial()

Query device serial

update_config(update_dict)

Update configuration variables.

Reads current configuration variables and update selected key/value pairs. Configuration is not stored in non-volatile memory so a power cycle will rset configuration to previously stored state.

Parameters:

update_dict – a dictionary of configuration values to update

Example:

# remap PM2.5 to PM4.5 on OPCN3 >>> o = OPCN3(spi) >>> o.update_config(({ ‘M_B’: 450 });)

exception opcng.USBISSError

Bases: BaseException

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

opcng.detect(spi)

Try to autodetect a device parsing information string

Parameters:

spi – SPI device instance as returned by SpiDev or USBiss

Returns:

an OPC_(N3,N2,R1,R2) instance, check type() to see if the device was properly detected.