mirror of
				https://github.com/eclipse/upm.git
				synced 2025-11-04 17:14:54 +03:00 
			
		
		
		
	Added iGas interface
Signed-off-by: Serban Waltter <serban.waltter@rinftech.com>
This commit is contained in:
		@@ -92,7 +92,7 @@ add_example(Button_intr_Example "button;interfaces")
 | 
			
		||||
add_example(Buzzer_Example buzzer)
 | 
			
		||||
add_example(CJQ4435_Example cjq4435)
 | 
			
		||||
add_example(Collision_Example "collision;interfaces")
 | 
			
		||||
add_example(CWLSXXA_Example cwlsxxa)
 | 
			
		||||
add_example(CWLSXXA_Example "cwlsxxa;interfaces")
 | 
			
		||||
add_example(DFREC_Example "dfrec;interfaces")
 | 
			
		||||
add_example(DFRORP_Example "dfrorp;interfaces")
 | 
			
		||||
add_example(DS1307_Example ds1307)
 | 
			
		||||
@@ -116,9 +116,9 @@ add_example(GroveLight_Example "grove;interfaces")
 | 
			
		||||
add_example(GroveLineFinder_Example "grovelinefinder;interfaces")
 | 
			
		||||
add_example(GroveMD_Example grovemd)
 | 
			
		||||
add_example(GroveMoisture_Example "grovemoisture;interfaces")
 | 
			
		||||
add_example(GroveMQ3_Example gas)
 | 
			
		||||
add_example(GroveMQ9_Example gas)
 | 
			
		||||
add_example(GroveO2_Example groveo2)
 | 
			
		||||
add_example(GroveMQ3_Example "gas;interfaces")
 | 
			
		||||
add_example(GroveMQ9_Example "gas;interfaces")
 | 
			
		||||
add_example(GroveO2_Example "groveo2;interfaces")
 | 
			
		||||
add_example(GroveQTouch_Example at42qt1070)
 | 
			
		||||
add_example(GroveRelay_Example grove)
 | 
			
		||||
add_example(GroveRotary_Example "grove;interfaces")
 | 
			
		||||
@@ -169,7 +169,7 @@ add_example(MB704X_Example "mb704x;interfaces")
 | 
			
		||||
add_example(MCP2515_Example mcp2515)
 | 
			
		||||
add_example(MCP2515_TXRX_Example mcp2515)
 | 
			
		||||
add_example(MD_Example md)
 | 
			
		||||
add_example(MHZ16_Example mhz16)
 | 
			
		||||
add_example(MHZ16_Example "mhz16;interfaces")
 | 
			
		||||
add_example(Microphone_Example mic)
 | 
			
		||||
add_example(MMA7361_Example mma7361)
 | 
			
		||||
add_example(MMA7455_Example "mma7455;interfaces")
 | 
			
		||||
@@ -178,16 +178,16 @@ add_example(Moisture_Example "moisture;interfaces")
 | 
			
		||||
add_example(MPL3115A2_Example "mpl3115a2;interfaces")
 | 
			
		||||
add_example(MPR121_Example mpr121)
 | 
			
		||||
add_example(MPU9150_Example "mpu9150;interfaces")
 | 
			
		||||
add_example(MQ2_Example gas)
 | 
			
		||||
add_example(MQ2_Example "gas;interfaces")
 | 
			
		||||
add_example(MQ303A_Example mq303a)
 | 
			
		||||
add_example(MQ5_Example gas)
 | 
			
		||||
add_example(MQ5_Example "gas;interfaces")
 | 
			
		||||
add_example(MS5803_Example "ms5803;interfaces")
 | 
			
		||||
add_example(NMEAGPS_Example nmea_gps)
 | 
			
		||||
add_example(NMEAGPS_I2C_Example nmea_gps)
 | 
			
		||||
add_example(NRF24L01_receiver_Example nrf24l01)
 | 
			
		||||
add_example(NRF24L01_transmitter_Example nrf24l01)
 | 
			
		||||
add_example(NUNCHUCK_Example nunchuck)
 | 
			
		||||
add_example(O2_Example o2)
 | 
			
		||||
add_example(O2_Example "o2;interfaces")
 | 
			
		||||
add_example(OTP538U_Example "otp538u;interfaces")
 | 
			
		||||
add_example(P9813_Example p9813)
 | 
			
		||||
add_example(PPD42NS_Example ppd42ns)
 | 
			
		||||
@@ -216,7 +216,7 @@ add_example(Temperature_Example "temperature;interfaces")
 | 
			
		||||
add_example(TEX00_Example "tex00;interfaces")
 | 
			
		||||
add_example(Th02_Example "th02;interfaces")
 | 
			
		||||
add_example(TM1637_Example tm1637)
 | 
			
		||||
add_example(TP401_Example gas)
 | 
			
		||||
add_example(TP401_Example "gas;interfaces")
 | 
			
		||||
add_example(TSL2561_Example "tsl2561;interfaces")
 | 
			
		||||
add_example(TTP223_Example "ttp223;interfaces")
 | 
			
		||||
add_example(ULN200XA_Example uln200xa)
 | 
			
		||||
 
 | 
			
		||||
@@ -18,6 +18,7 @@ set (module_hpp iClock.hpp
 | 
			
		||||
                iHallEffect.hpp
 | 
			
		||||
                iHeartRate.hpp
 | 
			
		||||
                iHumidity.hpp
 | 
			
		||||
                iGas.hpp
 | 
			
		||||
                iGyroscope.hpp
 | 
			
		||||
                iLight.hpp
 | 
			
		||||
                iLineFinder.hpp
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										46
									
								
								include/interfaces/iGas.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								include/interfaces/iGas.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,46 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Author: Serban Waltter <serban.waltter@rinftech.com>
 | 
			
		||||
 * Copyright (c) 2018 Intel Corporation.
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining
 | 
			
		||||
 * a copy of this software and associated documentation files (the
 | 
			
		||||
 * "Software"), to deal in the Software without restriction, including
 | 
			
		||||
 * without limitation the rights to use, copy, modify, merge, publish,
 | 
			
		||||
 * distribute, sublicense, and/or sell copies of the Software, and to
 | 
			
		||||
 * permit persons to whom the Software is furnished to do so, subject to
 | 
			
		||||
 * the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be
 | 
			
		||||
 * included in all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 | 
			
		||||
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 | 
			
		||||
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 | 
			
		||||
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 | 
			
		||||
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 | 
			
		||||
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 | 
			
		||||
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include <vector>
 | 
			
		||||
 | 
			
		||||
namespace upm
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @brief Interface for acceleration sensors
 | 
			
		||||
     */
 | 
			
		||||
    class iGas
 | 
			
		||||
    {
 | 
			
		||||
        public:
 | 
			
		||||
            virtual ~iGas() {}
 | 
			
		||||
 | 
			
		||||
            /**
 | 
			
		||||
             * Return gas concentration in PPM
 | 
			
		||||
             *
 | 
			
		||||
             * @return gas concentration in float
 | 
			
		||||
             */
 | 
			
		||||
            virtual float getConcentration() = 0;
 | 
			
		||||
    };
 | 
			
		||||
} // upm
 | 
			
		||||
@@ -8,6 +8,7 @@
 | 
			
		||||
#include "iEC.hpp"
 | 
			
		||||
#include "iElectromagnet.hpp"
 | 
			
		||||
#include "iEmg.hpp"
 | 
			
		||||
#include "iGas.hpp"
 | 
			
		||||
#include "iGps.hpp"
 | 
			
		||||
#include "iGyroscope.hpp"
 | 
			
		||||
#include "iHallEffect.hpp"
 | 
			
		||||
 
 | 
			
		||||
@@ -49,6 +49,7 @@ import java.lang.Float;
 | 
			
		||||
    %interface_impl (upm::iEC);
 | 
			
		||||
    %interface_impl (upm::iElectromagnet);
 | 
			
		||||
    %interface_impl (upm::iEmg);
 | 
			
		||||
    %interface_impl (upm::iGas);
 | 
			
		||||
    %interface_impl (upm::iGps);
 | 
			
		||||
    %interface_impl (upm::iGyroscope);
 | 
			
		||||
    %interface_impl (upm::iHallEffect);
 | 
			
		||||
@@ -79,6 +80,7 @@ import java.lang.Float;
 | 
			
		||||
    #include "iEC.hpp"
 | 
			
		||||
    #include "iElectromagnet.hpp"
 | 
			
		||||
    #include "iEmg.hpp"
 | 
			
		||||
    #include "iGas.hpp"
 | 
			
		||||
    #include "iGps.hpp"
 | 
			
		||||
    #include "iGyroscope.hpp"
 | 
			
		||||
    #include "iHallEffect.hpp"
 | 
			
		||||
@@ -108,6 +110,7 @@ import java.lang.Float;
 | 
			
		||||
%include "iEC.hpp"
 | 
			
		||||
%include "iElectromagnet.hpp"
 | 
			
		||||
%include "iEmg.hpp"
 | 
			
		||||
%include "iGas.hpp"
 | 
			
		||||
%include "iGps.hpp"
 | 
			
		||||
%include "iGyroscope.hpp"
 | 
			
		||||
%include "iHallEffect.hpp"
 | 
			
		||||
 
 | 
			
		||||
@@ -2,4 +2,5 @@ set (libname "cwlsxxa")
 | 
			
		||||
set (libdescription "Veris CWLSXXA CO2/Temperature/Humidity Transmitter")
 | 
			
		||||
set (module_src ${libname}.cxx)
 | 
			
		||||
set (module_hpp ${libname}.hpp)
 | 
			
		||||
set (module_iface iGas.hpp iHumidity.hpp iTemperature.hpp)
 | 
			
		||||
upm_module_init(mraa)
 | 
			
		||||
 
 | 
			
		||||
@@ -160,8 +160,15 @@ float CWLSXXA::getTemperature(bool fahrenheit)
 | 
			
		||||
    return m_temperature;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
float CWLSXXA::getTemperature()
 | 
			
		||||
{
 | 
			
		||||
  update();
 | 
			
		||||
  return m_temperature;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
float CWLSXXA::getHumidity()
 | 
			
		||||
{
 | 
			
		||||
  update();
 | 
			
		||||
  return m_humidity;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -170,6 +177,12 @@ float CWLSXXA::getCO2()
 | 
			
		||||
  return m_co2;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
float CWLSXXA::getConcentration()
 | 
			
		||||
{
 | 
			
		||||
  update();
 | 
			
		||||
  return m_co2;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int CWLSXXA::average(mraa::Aio *aio, int samples)
 | 
			
		||||
{
 | 
			
		||||
  if (samples <= 0)
 | 
			
		||||
 
 | 
			
		||||
@@ -26,6 +26,10 @@
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <iostream>
 | 
			
		||||
 | 
			
		||||
#include <interfaces/iGas.hpp>
 | 
			
		||||
#include <interfaces/iHumidity.hpp>
 | 
			
		||||
#include <interfaces/iTemperature.hpp>
 | 
			
		||||
 | 
			
		||||
#include <mraa/aio.hpp>
 | 
			
		||||
 | 
			
		||||
// Unlikey to be changable without external circuitry (voltage divider)
 | 
			
		||||
@@ -85,7 +89,7 @@ namespace upm {
 | 
			
		||||
     * @snippet cwlsxxa.cxx Interesting
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
  class CWLSXXA {
 | 
			
		||||
  class CWLSXXA: virtual public iGas, virtual public iHumidity, virtual public iTemperature {
 | 
			
		||||
  public:
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -134,7 +138,8 @@ namespace upm {
 | 
			
		||||
     * The default is false (degrees Celsius).
 | 
			
		||||
     * @return The last temperature reading in Celsius or Fahrenheit
 | 
			
		||||
     */
 | 
			
		||||
    float getTemperature(bool fahrenheit=false);
 | 
			
		||||
    float getTemperature(bool fahrenheit);
 | 
			
		||||
    float getTemperature();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the current relative humidity.  update() must have been called
 | 
			
		||||
@@ -154,6 +159,14 @@ namespace upm {
 | 
			
		||||
     */
 | 
			
		||||
    float getCO2();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the current CO2 concentration in Parts Per Million (PPM).
 | 
			
		||||
     * update() must have been called prior to calling this method.
 | 
			
		||||
     *
 | 
			
		||||
     * @return The last CO2 reading
 | 
			
		||||
     */
 | 
			
		||||
    float getConcentration();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  protected:
 | 
			
		||||
    // CO2 reporting is always supported
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,17 @@
 | 
			
		||||
#ifdef SWIGPYTHON
 | 
			
		||||
%module (package="upm") cwlsxxa
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
%import "interfaces/interfaces.i"
 | 
			
		||||
 | 
			
		||||
%include "../common_top.i"
 | 
			
		||||
 | 
			
		||||
/* BEGIN Java syntax  ------------------------------------------------------- */
 | 
			
		||||
#ifdef SWIGJAVA
 | 
			
		||||
%typemap(javaimports) SWIGTYPE %{
 | 
			
		||||
import upm_interfaces.*;
 | 
			
		||||
%}
 | 
			
		||||
 | 
			
		||||
JAVA_JNI_LOADLIBRARY(javaupm_cwlsxxa)
 | 
			
		||||
#endif
 | 
			
		||||
/* END Java syntax */
 | 
			
		||||
 
 | 
			
		||||
@@ -4,5 +4,6 @@ upm_mixed_module_init (NAME gas
 | 
			
		||||
    C_SRC mqx.c
 | 
			
		||||
    CPP_HDR gas.hpp mq2.hpp mq3.hpp mq4.hpp mq5.hpp mq6.hpp mq7.hpp mq8.hpp mq9.hpp tp401.hpp
 | 
			
		||||
    CPP_SRC gas.cxx mq2.cxx mq3.cxx mq4.cxx mq5.cxx mq6.cxx mq7.cxx mq8.cxx mq9.cxx tp401.cxx
 | 
			
		||||
    IFACE_HDR iGas.hpp
 | 
			
		||||
    FTI_SRC mqx_fti.c
 | 
			
		||||
    REQUIRES mraa)
 | 
			
		||||
 
 | 
			
		||||
@@ -89,6 +89,11 @@ Gas::getSample () {
 | 
			
		||||
    return m_aio.read();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
float
 | 
			
		||||
Gas::getConcentration() {
 | 
			
		||||
    return m_aio.read();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
Gas::printGraph (thresholdContext* ctx, uint8_t resolution) {
 | 
			
		||||
    std::cout << "(" << ctx->runningAverage << ") | ";
 | 
			
		||||
 
 | 
			
		||||
@@ -25,6 +25,7 @@
 | 
			
		||||
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <mraa/aio.hpp>
 | 
			
		||||
#include <interfaces/iGas.hpp>
 | 
			
		||||
 | 
			
		||||
struct thresholdContext {
 | 
			
		||||
    long averageReading;
 | 
			
		||||
@@ -42,7 +43,7 @@ namespace upm {
 | 
			
		||||
 * @defgroup gas libupm-gas
 | 
			
		||||
 * @ingroup seeed analog gaseous eak hak
 | 
			
		||||
 */
 | 
			
		||||
class Gas {
 | 
			
		||||
class Gas: virtual public iGas {
 | 
			
		||||
    public:
 | 
			
		||||
        /**
 | 
			
		||||
         * Instantiates a Gas object
 | 
			
		||||
@@ -89,6 +90,11 @@ class Gas {
 | 
			
		||||
         */
 | 
			
		||||
        virtual int getSample ();
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * Returns one sample from the sensor
 | 
			
		||||
         */
 | 
			
		||||
        virtual float getConcentration ();
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         *
 | 
			
		||||
         * Prints a running average of the threshold context
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,17 @@
 | 
			
		||||
#ifdef SWIGPYTHON
 | 
			
		||||
%module (package="upm") cwlsxxa
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
%import "interfaces/interfaces.i"
 | 
			
		||||
 | 
			
		||||
%include "../common_top.i"
 | 
			
		||||
 | 
			
		||||
/* BEGIN Java syntax  ------------------------------------------------------- */
 | 
			
		||||
#ifdef SWIGJAVA
 | 
			
		||||
%typemap(javaimports) SWIGTYPE %{
 | 
			
		||||
import upm_interfaces.*;
 | 
			
		||||
%}
 | 
			
		||||
 | 
			
		||||
%typemap(jni) (uint16_t *buffer, int len) "jshortArray";
 | 
			
		||||
%typemap(jtype) (uint16_t *buffer, int len) "short[]";
 | 
			
		||||
%typemap(jstype) (uint16_t *buffer, int len) "short[]";
 | 
			
		||||
 
 | 
			
		||||
@@ -2,4 +2,5 @@ set (libname "groveo2")
 | 
			
		||||
set (libdescription "Oxygen (O2) Concentration Sensor")
 | 
			
		||||
set (module_src ${libname}.cxx)
 | 
			
		||||
set (module_hpp ${libname}.hpp)
 | 
			
		||||
set (module_iface iGas.hpp)
 | 
			
		||||
upm_module_init(mraa)
 | 
			
		||||
 
 | 
			
		||||
@@ -54,3 +54,23 @@ float GroveO2::voltageValue()
 | 
			
		||||
	sensorVoltage = (sensorVoltage/201.0) * 10000.0;
 | 
			
		||||
	return sensorVoltage;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
float GroveO2::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;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -25,6 +25,7 @@
 | 
			
		||||
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <mraa/aio.h>
 | 
			
		||||
#include <interfaces/iGas.hpp>
 | 
			
		||||
 | 
			
		||||
namespace upm {
 | 
			
		||||
  /**
 | 
			
		||||
@@ -50,7 +51,7 @@ namespace upm {
 | 
			
		||||
   * @image html groveo2.jpg
 | 
			
		||||
   * @snippet groveo2.cxx Interesting
 | 
			
		||||
   */
 | 
			
		||||
  class GroveO2 {
 | 
			
		||||
  class GroveO2: virtual public iGas {
 | 
			
		||||
  public:
 | 
			
		||||
    /**
 | 
			
		||||
     * Grove O2 Oxygen Gas sensor constructor
 | 
			
		||||
@@ -69,6 +70,13 @@ namespace upm {
 | 
			
		||||
     */
 | 
			
		||||
    float voltageValue();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Measures O2 from the sensor
 | 
			
		||||
     *
 | 
			
		||||
     * @return Oxygen concentration as PPM
 | 
			
		||||
     */
 | 
			
		||||
    float getConcentration();
 | 
			
		||||
 | 
			
		||||
  private:
 | 
			
		||||
    mraa_aio_context m_aio;
 | 
			
		||||
  };
 | 
			
		||||
 
 | 
			
		||||
@@ -2,4 +2,5 @@ set (libname "mg811")
 | 
			
		||||
set (libdescription "CO2 Sensor")
 | 
			
		||||
set (module_src ${libname}.cxx)
 | 
			
		||||
set (module_hpp ${libname}.hpp)
 | 
			
		||||
set (module_iface iGas.hpp)
 | 
			
		||||
upm_module_init(mraa)
 | 
			
		||||
 
 | 
			
		||||
@@ -88,6 +88,20 @@ float MG811::ppm()
 | 
			
		||||
                      (m_reactionValue / (log400-log1000))+log400);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
float MG811::getConcentration()
 | 
			
		||||
{
 | 
			
		||||
  static const float log400 = log10f(400);
 | 
			
		||||
  static const float log1000 = log10f(1000);
 | 
			
		||||
 | 
			
		||||
  float val = volts();
 | 
			
		||||
 | 
			
		||||
  if ((val / dcGain) >= m_zeroPointValue)
 | 
			
		||||
    return 0.0;
 | 
			
		||||
  else
 | 
			
		||||
    return powf(10.0, ((val/dcGain)-m_zeroPointValue) / 
 | 
			
		||||
                      (m_reactionValue / (log400-log1000))+log400);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool MG811::thresholdReached()
 | 
			
		||||
{
 | 
			
		||||
  return (m_gpio.read() ? true : false);
 | 
			
		||||
 
 | 
			
		||||
@@ -28,6 +28,8 @@
 | 
			
		||||
#include <mraa/aio.hpp>
 | 
			
		||||
#include <mraa/gpio.hpp>
 | 
			
		||||
 | 
			
		||||
#include <interfaces/iGas.hpp>
 | 
			
		||||
 | 
			
		||||
namespace upm {
 | 
			
		||||
  /**
 | 
			
		||||
   * @brief MG811 CO2 Sensor
 | 
			
		||||
@@ -68,7 +70,7 @@ namespace upm {
 | 
			
		||||
   * @snippet mg811.cxx Interesting
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  class MG811 {
 | 
			
		||||
  class MG811: virtual public iGas {
 | 
			
		||||
  public:
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -83,7 +85,7 @@ namespace upm {
 | 
			
		||||
    /**
 | 
			
		||||
     * MG811 destructor
 | 
			
		||||
     */
 | 
			
		||||
    ~MG811();
 | 
			
		||||
    virtual ~MG811();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Return a cumputed reference voltage to be used in calibration.
 | 
			
		||||
@@ -118,6 +120,7 @@ namespace upm {
 | 
			
		||||
     * @return The computed CO2 concentration in ppm
 | 
			
		||||
     */
 | 
			
		||||
    float ppm();
 | 
			
		||||
    float getConcentration();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Read the digital pin and return true if the set threshold has
 | 
			
		||||
 
 | 
			
		||||
@@ -2,4 +2,5 @@ set (libname "mhz16")
 | 
			
		||||
set (libdescription "CO2 Sensor")
 | 
			
		||||
set (module_src ${libname}.cxx)
 | 
			
		||||
set (module_hpp ${libname}.hpp)
 | 
			
		||||
set (module_iface iGas.hpp)
 | 
			
		||||
upm_module_init(mraa)
 | 
			
		||||
 
 | 
			
		||||
@@ -244,8 +244,15 @@ int MHZ16::getGas()
 | 
			
		||||
  return gas;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int MHZ16::getTemperature()
 | 
			
		||||
float MHZ16::getConcentration()
 | 
			
		||||
{
 | 
			
		||||
  getData();
 | 
			
		||||
  return gas;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
float MHZ16::getTemperature()
 | 
			
		||||
{
 | 
			
		||||
  getData();
 | 
			
		||||
  return temp;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -38,6 +38,9 @@
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#include <sys/stat.h>
 | 
			
		||||
 | 
			
		||||
#include <interfaces/iTemperature.hpp>
 | 
			
		||||
#include <interfaces/iGas.hpp>
 | 
			
		||||
 | 
			
		||||
#include <mraa/uart.h>
 | 
			
		||||
 | 
			
		||||
namespace upm {
 | 
			
		||||
@@ -67,7 +70,7 @@ namespace upm {
 | 
			
		||||
     * @image html mhz16.jpg
 | 
			
		||||
     * @snippet mhz16.cxx Interesting
 | 
			
		||||
     */
 | 
			
		||||
  class MHZ16 {
 | 
			
		||||
  class MHZ16: virtual public iGas, virtual public iTemperature {
 | 
			
		||||
  public:
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -151,13 +154,14 @@ namespace upm {
 | 
			
		||||
     * @return Gas concentration
 | 
			
		||||
     */
 | 
			
		||||
    int getGas();
 | 
			
		||||
    float getConcentration();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns the temperature data.
 | 
			
		||||
     *
 | 
			
		||||
     * @return Temperature in Celsius
 | 
			
		||||
     */
 | 
			
		||||
    int getTemperature();
 | 
			
		||||
    float getTemperature();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Sets the zero point of the sensor
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,17 @@
 | 
			
		||||
#ifdef SWIGPYTHON
 | 
			
		||||
%module (package="upm") cwlsxxa
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
%import "interfaces/interfaces.i"
 | 
			
		||||
 | 
			
		||||
%include "../common_top.i"
 | 
			
		||||
 | 
			
		||||
/* BEGIN Java syntax  ------------------------------------------------------- */
 | 
			
		||||
#ifdef SWIGJAVA
 | 
			
		||||
%typemap(javaimports) SWIGTYPE %{
 | 
			
		||||
import upm_interfaces.*;
 | 
			
		||||
%}
 | 
			
		||||
 | 
			
		||||
%include "arrays_java.i";
 | 
			
		||||
%include "../java_buffer.i"
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,4 +2,5 @@ set (libname "micsv89")
 | 
			
		||||
set (libdescription "Low-power Air Quality Sensor")
 | 
			
		||||
set (module_src ${libname}.cxx)
 | 
			
		||||
set (module_hpp ${libname}.hpp)
 | 
			
		||||
set (module_iface iGas.hpp)
 | 
			
		||||
upm_module_init(mraa)
 | 
			
		||||
 
 | 
			
		||||
@@ -66,6 +66,11 @@ float MICSV89::co2equ() {
 | 
			
		||||
    return ((rx_buf[0] - 13) * (1600/229) + 400);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
float MICSV89::getConcentration() {
 | 
			
		||||
    update();
 | 
			
		||||
    return ((rx_buf[0] - 13) * (1600/229) + 400);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int MICSV89::vocshort() {
 | 
			
		||||
    return rx_buf[1];
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,8 @@
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#include <string>
 | 
			
		||||
 | 
			
		||||
#include <interfaces/iGas.hpp>
 | 
			
		||||
 | 
			
		||||
namespace mraa { class I2c;}
 | 
			
		||||
 | 
			
		||||
namespace upm {
 | 
			
		||||
@@ -59,7 +61,7 @@ namespace upm {
 | 
			
		||||
   * @image html micsv89.jpg
 | 
			
		||||
   * @snippet micsv89.cxx Interesting
 | 
			
		||||
   */
 | 
			
		||||
    class MICSV89 {
 | 
			
		||||
    class MICSV89: virtual public iGas {
 | 
			
		||||
        public:
 | 
			
		||||
            /**
 | 
			
		||||
             * MICSV89 constructor
 | 
			
		||||
@@ -87,6 +89,11 @@ namespace upm {
 | 
			
		||||
             */
 | 
			
		||||
            float co2equ();
 | 
			
		||||
 | 
			
		||||
            /**
 | 
			
		||||
             * Returns the  CO2 equivalent value.
 | 
			
		||||
             */
 | 
			
		||||
            float getConcentration();
 | 
			
		||||
 | 
			
		||||
            /**
 | 
			
		||||
             * Returns VOC Short value.
 | 
			
		||||
             */
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
  };
 | 
			
		||||
 
 | 
			
		||||
@@ -2,4 +2,5 @@ set (libname "t6713")
 | 
			
		||||
set (libdescription "I2C/UART High Accuracy CO2 Sensor")
 | 
			
		||||
set (module_src ${libname}.cxx)
 | 
			
		||||
set (module_hpp ${libname}.hpp)
 | 
			
		||||
set (module_iface iGas.hpp)
 | 
			
		||||
upm_module_init(mraa)
 | 
			
		||||
 
 | 
			
		||||
@@ -69,6 +69,11 @@ uint16_t T6713::getPpm ()
 | 
			
		||||
    return(getSensorData(T6713_COMMAND_GET_GAS_PPM));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
float T6713::getConcentration ()
 | 
			
		||||
{
 | 
			
		||||
    return(getSensorData(T6713_COMMAND_GET_GAS_PPM));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint16_t T6713::getSensorData (MODBUS_COMMANDS cmd)
 | 
			
		||||
{
 | 
			
		||||
    uint16_t data ,readBytes ;
 | 
			
		||||
 
 | 
			
		||||
@@ -25,6 +25,8 @@
 | 
			
		||||
 | 
			
		||||
#include "mraa/i2c.hpp"
 | 
			
		||||
 | 
			
		||||
#include <interfaces/iGas.hpp>
 | 
			
		||||
 | 
			
		||||
namespace upm {
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Amphenol Telaire 6713 Series CO2 Module
 | 
			
		||||
@@ -105,7 +107,7 @@ namespace t6713_co2
 | 
			
		||||
    }FUNCTION_CODES;
 | 
			
		||||
}//namespace t6713_co2
 | 
			
		||||
 | 
			
		||||
class T6713 {
 | 
			
		||||
class T6713: virtual public iGas {
 | 
			
		||||
    public:
 | 
			
		||||
        /**
 | 
			
		||||
        * Instantiates a T6713 object
 | 
			
		||||
@@ -128,6 +130,12 @@ class T6713 {
 | 
			
		||||
        * Get relative humidity measurement.
 | 
			
		||||
        */
 | 
			
		||||
        uint16_t getPpm ();
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
        * Get relative humidity measurement.
 | 
			
		||||
        */
 | 
			
		||||
        float getConcentration ();
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
        * Get the firmware version
 | 
			
		||||
        */
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,9 @@
 | 
			
		||||
#ifdef SWIGPYTHON
 | 
			
		||||
%module (package="upm") cwlsxxa
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
%import "interfaces/interfaces.i"
 | 
			
		||||
 | 
			
		||||
%include "../common_top.i"
 | 
			
		||||
 | 
			
		||||
/* BEGIN Java syntax  ------------------------------------------------------- */
 | 
			
		||||
@@ -5,6 +11,11 @@
 | 
			
		||||
%include "arrays_java.i";
 | 
			
		||||
%include "../java_buffer.i"
 | 
			
		||||
 | 
			
		||||
%typemap(javaimports) SWIGTYPE %{
 | 
			
		||||
import upm_interfaces.*;
 | 
			
		||||
%}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
JAVA_JNI_LOADLIBRARY(javaupm_t6713)
 | 
			
		||||
#endif
 | 
			
		||||
/* END Java syntax */
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user