upm  0.8.0
Sensor/Actuator repository for libmraa (v1.1.1)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
cwlsxxa.hpp
1 /*
2  * Author: Jon Trulson <jtrulson@ics.com>
3  * Copyright (c) 2016 Intel Corporation.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 #pragma once
25 
26 #include <string>
27 #include <iostream>
28 
29 #include <mraa/aio.hpp>
30 
31 // Unlikey to be changable without external circuitry (voltage divider)
32 #define CWLSXXA_DEFAULT_AREF 5.0
33 
34 namespace upm {
88  class CWLSXXA {
89  public:
90 
111  CWLSXXA(int gPin, int hPin, int tPin, float rResistor=0.0,
112  float aref=CWLSXXA_DEFAULT_AREF);
113 
117  ~CWLSXXA();
118 
124  void update();
125 
137  float getTemperature(bool fahrenheit=false);
138 
147  float getHumidity();
148 
155  float getCO2();
156 
157 
158  protected:
159  // temperature and humidity are optional features of this transmitter
160  mraa::Aio *m_aioTemp;
161  mraa::Aio *m_aioHum;
162 
163  // CO2 reporting is always supported
164  mraa::Aio m_aioCO2;
165 
166  private:
167  float m_aref;
168  float m_rResistor;
169  int m_aResTemp;
170  int m_aResHum;
171  int m_aResCO2;
172 
173  // does this sensor support temperature and/or humidity reporting?
174  bool m_hasTemp;
175  bool m_hasHum;
176 
177  // in Celsius
178  float m_temperature;
179 
180  float m_humidity;
181 
182  // in PPM
183  float m_co2;
184 
185  int average(mraa::Aio *aio, int samples);
186  };
187 }
188 
189 
float getTemperature(bool fahrenheit=false)
Definition: cwlsxxa.cxx:155
~CWLSXXA()
Definition: cwlsxxa.cxx:76
float getHumidity()
Definition: cwlsxxa.cxx:163
CWLSXXA(int gPin, int hPin, int tPin, float rResistor=0.0, float aref=CWLSXXA_DEFAULT_AREF)
Definition: cwlsxxa.cxx:44
void update()
Definition: cwlsxxa.cxx:84
float getCO2()
Definition: cwlsxxa.cxx:168
API for the Veris CWLSXXA CO2 Sensor Family.
Definition: cwlsxxa.hpp:88