Added iGas interface

Signed-off-by: Serban Waltter <serban.waltter@rinftech.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Serban Waltter
2018-10-08 16:43:42 +03:00
committed by Mihai Tudor Panu
parent f28a6d2561
commit e4f106a0c7
33 changed files with 267 additions and 21 deletions

View File

@ -5,4 +5,5 @@ upm_mixed_module_init (NAME o2
CPP_HDR o2.hpp
CPP_SRC o2.cxx
FTI_SRC o2_fti.c
IFACE_HDR iGas.hpp
REQUIRES mraa)

View File

@ -54,3 +54,22 @@ float O2::voltageValue()
sensorVoltage = (sensorVoltage/201.0) * 10000.0;
return sensorVoltage;
}
float O2::getConcentration()
{
float value;
/* Read normalized value */
value = mraa_aio_read_float(m_aio);
if (value < 0.0)
return -1;
/* Convert to %oxygen
Datasheet for grove o2 shows a linear response for the sensor. Assuming
20.5% oxygen @ 25 celsius, with an gain = 1 + 12k/100 = 121, a
dynamic range of 0->25% oxygen, and opamp rails of 0->3.3v (the grove o2
sensor uses a high-accuracy 3.3v regulator),
*/
value *= 25 * 5 / 3.3;
return value;
}

View File

@ -26,6 +26,8 @@
#include <string>
#include <mraa/aio.h>
#include <interfaces/iGas.hpp>
namespace upm {
/**
* @brief Oxygen Gas Sensor
@ -50,7 +52,7 @@ namespace upm {
* @image html o2.jpg
* @snippet o2.cxx Interesting
*/
class O2 {
class O2: virtual public iGas {
public:
/**
* Grove O2 Oxygen Gas sensor constructor
@ -69,6 +71,13 @@ namespace upm {
*/
float voltageValue();
/**
* Measures O2 from the sensor
*
* @return Oxygen concentration as PPM
*/
float getConcentration();
private:
mraa_aio_context m_aio;
};