Air_Quality_Sensor.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. Air_Quality_Sensor.h
  3. Header file for Grove - Air Quality Sensor.
  4. Copyright (c) 2019 seeed technology inc.
  5. Author : Lets Blu
  6. Created Time : Jan 2019
  7. Modified Time:
  8. The MIT License (MIT)
  9. Permission is hereby granted, free of charge, to any person obtaining a copy
  10. of this software and associated documentation files (the "Software"), to deal
  11. in the Software without restriction, including without limitation the rights
  12. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. copies of the Software, and to permit persons to whom the Software is
  14. furnished to do so, subject to the following conditions:
  15. The above copyright notice and this permission notice shall be included in
  16. all copies or substantial portions of the Software.
  17. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  23. THE SOFTWARE.
  24. */
  25. #ifndef __AIR_QUALITY_SENSOR_H__
  26. #define __AIR_QUALITY_SENSOR_H__
  27. #include "Arduino.h"
  28. class AirQualitySensor {
  29. public:
  30. AirQualitySensor(int pin);
  31. bool init(void);
  32. int slope(void);
  33. int getValue(void);
  34. static const int FORCE_SIGNAL;
  35. static const int HIGH_POLLUTION;
  36. static const int LOW_POLLUTION;
  37. static const int FRESH_AIR;
  38. protected:
  39. int _pin;
  40. int _lastVoltage;
  41. int _currentVoltage;
  42. int _standardVoltage;
  43. long _voltageSum;
  44. int _volSumCount;
  45. long _lastStdVolUpdated;
  46. void updateStandardVoltage(void);
  47. };
  48. #endif // __AIR_QUALITY_SENSOR_H__