upm  1.3.0
Sensor/Actuator repository for libmraa (v1.7.0)
 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  // CO2 reporting is always supported
160  mraa::Aio m_aioCO2;
161 
162  // temperature and humidity are optional features of this transmitter
163  mraa::Aio *m_aioHum;
164  mraa::Aio *m_aioTemp;
165 
166 
167  private:
168  /* Disable implicit copy and assignment operators */
169  CWLSXXA(const CWLSXXA&) = delete;
170  CWLSXXA &operator=(const CWLSXXA&) = delete;
171 
172  float m_aref;
173  float m_rResistor;
174  int m_aResTemp;
175  int m_aResHum;
176  int m_aResCO2;
177 
178  // does this sensor support temperature and/or humidity reporting?
179  bool m_hasTemp;
180  bool m_hasHum;
181 
182  // in Celsius
183  float m_temperature;
184 
185  float m_humidity;
186 
187  // in PPM
188  float m_co2;
189 
190  int average(mraa::Aio *aio, int samples);
191  };
192 }
193 
194 
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