Electrochemical Gas Sensor Library 1.0.0
A library for the Electrochemical Gas Sensor breakout board
Loading...
Searching...
No Matches
ElectrochemicalGasSensor Class Reference

#include <Electrochemical-Gas-Sensor-SOLDERED.h>

Public Member Functions

 ElectrochemicalGasSensor (sensorType _t, uint8_t _adcAddr=DEFAULT_ADC_ADDR, int _configPin=-1)
 Constructor on custom address.
bool begin ()
 Init the sensor and begin measuring with the ADC, must be called before using.
bool configureLMP ()
 Configure the LMP91000, has to be done at startup.
double getVoltage ()
 get the voltage which the ADS is currently measuring
double getPPM ()
 Make a measurement with the ADC and calculate the PPM value of the measured gas.
double getPPB ()
 Calcualte PPB values from PPM.
double getAveragedPPM (uint8_t _numMeasurements=5, uint8_t _secondsDelay=2)
 Calculate an averaged PPM measurement from a number of separate measurements.
double getAveragedPPB (uint8_t _numMeasurements=5, uint8_t _secondsDelay=2)
 Calculate an averaged PPB measurement from a number of separate measurements.
void setCustomTiaGain (float _tiaGain)
 Set a custom number of the kOhms in the TIA gain.
void setCustomZeroCalibration (double calibration)
 Set a custom value for the zero calibration.

Private Member Functions

float getTiaGain ()
 Get the actual number of the kOhms in the TIA gain.
float getInternalZeroPercent ()
 Get the internal zero % setting as an actual float.
bool bridgeTransaction (uint8_t cmd, const uint8_t *payload, uint8_t payloadLen, uint8_t *resultHigh, uint8_t *resultLow)
 Send a command to the ATtiny bridge and poll the 3-byte response.
bool pingBridge ()
bool sendConfigureAdc (uint8_t gain, uint8_t dataRate)
bool sendConfigureLmp (uint8_t tiacn, uint8_t refcn, uint8_t modecn)
bool triggerAndReadAdc (int16_t &rawOut)

Private Attributes

LMP91000lmp
ADS1115ads
uint8_t adcAddr
int configPin
sensorType type
TransportMode mode
float tiaGainInKOHms
float internalZeroPercent

Constructor & Destructor Documentation

◆ ElectrochemicalGasSensor()

ElectrochemicalGasSensor::ElectrochemicalGasSensor ( sensorType _t,
uint8_t _adcAddr = DEFAULT_ADC_ADDR,
int _configPin = -1 )

Constructor on custom address.

Parameters
sensorType_t The type of the sensor
uint8_t_adcAddr Legacy board: the ADS1115's own address (0x48-0x4B). ATtiny bridge board: the bridge's easyC address (0x30-0x37). begin() picks the transport based on which range this falls in.

Member Function Documentation

◆ begin()

bool ElectrochemicalGasSensor::begin ( )

Init the sensor and begin measuring with the ADC, must be called before using.

Returns
True if it was successful, false if it failed

◆ bridgeTransaction()

bool ElectrochemicalGasSensor::bridgeTransaction ( uint8_t cmd,
const uint8_t * payload,
uint8_t payloadLen,
uint8_t * resultHigh,
uint8_t * resultLow )
private

Send a command to the ATtiny bridge and poll the 3-byte response.

Note
Blocking - protocol is synchronous, one command in flight at a time. Only used when mode == TransportMode::BRIDGE.
Returns
True if the bridge answered OK before the timeout, false on error/timeout

◆ configureLMP()

bool ElectrochemicalGasSensor::configureLMP ( )

Configure the LMP91000, has to be done at startup.

Returns
True if it was successful, false if it failed

◆ getAveragedPPB()

double ElectrochemicalGasSensor::getAveragedPPB ( uint8_t _numMeasurements = 5,
uint8_t _secondsDelay = 2 )

Calculate an averaged PPB measurement from a number of separate measurements.

Note
This is a blocking function, it won't exit until it's completed
Parameters
uint8_t_numMeasurements How many measurements to do
uint8_t_secondsDelay How many seconds to wait between each measurement
Returns
double value of the calculated averaged PPB

◆ getAveragedPPM()

double ElectrochemicalGasSensor::getAveragedPPM ( uint8_t _numMeasurements = 5,
uint8_t _secondsDelay = 2 )

Calculate an averaged PPM measurement from a number of separate measurements.

Note
This is a blocking function, it won't exit until it's completed
Parameters
uint8_t_numMeasurements How many measurements to do
uint8_t_secondsDelay How many seconds to wait between each measurement
Returns
double value of the calculated averaged PPM

◆ getInternalZeroPercent()

float ElectrochemicalGasSensor::getInternalZeroPercent ( )
private

Get the internal zero % setting as an actual float.

Returns
The internal zero as a float

◆ getPPB()

double ElectrochemicalGasSensor::getPPB ( )

Calcualte PPB values from PPM.

Returns
double value of PPB

◆ getPPM()

double ElectrochemicalGasSensor::getPPM ( )

Make a measurement with the ADC and calculate the PPM value of the measured gas.

Returns
double value of the PPM

◆ getTiaGain()

float ElectrochemicalGasSensor::getTiaGain ( )
private

Get the actual number of the kOhms in the TIA gain.

Note
Only used internally in the class
Returns
float of the TIA gain depending on the config

◆ getVoltage()

double ElectrochemicalGasSensor::getVoltage ( )

get the voltage which the ADS is currently measuring

Returns
double value of the voltage in volts

◆ pingBridge()

bool ElectrochemicalGasSensor::pingBridge ( )
private

◆ sendConfigureAdc()

bool ElectrochemicalGasSensor::sendConfigureAdc ( uint8_t gain,
uint8_t dataRate )
private

◆ sendConfigureLmp()

bool ElectrochemicalGasSensor::sendConfigureLmp ( uint8_t tiacn,
uint8_t refcn,
uint8_t modecn )
private

◆ setCustomTiaGain()

void ElectrochemicalGasSensor::setCustomTiaGain ( float _tiaGain)

Set a custom number of the kOhms in the TIA gain.

Note
This is if you're using an external resistor
Returns
None

◆ setCustomZeroCalibration()

void ElectrochemicalGasSensor::setCustomZeroCalibration ( double calibration)

Set a custom value for the zero calibration.

Parameters
calibrationVoltage level at 0ppm

◆ triggerAndReadAdc()

bool ElectrochemicalGasSensor::triggerAndReadAdc ( int16_t & rawOut)
private

Member Data Documentation

◆ adcAddr

uint8_t ElectrochemicalGasSensor::adcAddr
private

◆ ads

ADS1115* ElectrochemicalGasSensor::ads
private

◆ configPin

int ElectrochemicalGasSensor::configPin
private

◆ internalZeroPercent

float ElectrochemicalGasSensor::internalZeroPercent
private

◆ lmp

LMP91000* ElectrochemicalGasSensor::lmp
private

◆ mode

TransportMode ElectrochemicalGasSensor::mode
private

◆ tiaGainInKOHms

float ElectrochemicalGasSensor::tiaGainInKOHms
private

◆ type

sensorType ElectrochemicalGasSensor::type
private

The documentation for this class was generated from the following files: