Commit 2016ee2c authored by BuildTools's avatar BuildTools

Replace Old library with new

Air quality sensor library was outdated
parent f9528640
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
#################
## Eclipse
#################
*.pydevproject
.project
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
#################
## Visual Studio
#################
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
*.ncrunch*
.*crunch*.local.xml
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.Publish.xml
*.pubxml
# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/
# Windows Azure Build Output
csx
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
App_Data/*.mdf
App_Data/*.ldf
#############
## Windows detritus
#############
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Mac crap
.DS_Store
#############
## Python
#############
*.py[co]
# Packages
*.egg
*.egg-info
dist/
build/
eggs/
parts/
var/
sdist/
develop-eggs/
.installed.cfg
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
#Translations
*.mo
#Mr Developer
.mr.developer.cfg
build:
tags:
- nas
script:
- wget -c https://files.seeedstudio.com/arduino/seeed-arduino-ci.sh
- chmod +x seeed-arduino-ci.sh
- bash $PWD/seeed-arduino-ci.sh test
language: generic
dist: bionic
sudo: false
cache:
directories:
- ~/arduino_ide
- ~/.arduino15/packages/
before_install:
- wget -c https://files.seeedstudio.com/arduino/seeed-arduino-ci.sh
script:
- chmod +x seeed-arduino-ci.sh
- cat $PWD/seeed-arduino-ci.sh
- bash $PWD/seeed-arduino-ci.sh test
notifications:
email:
on_success: change
on_failure: change
/*
Air_Quality_Sensor.cpp
Source file for Grove - Air Quality Sensor.
Copyright (c) 2019 seeed technology inc.
Author : Lets Blu
Created Time : Jan 2019
Modified Time:
The MIT License (MIT)
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.
*/
#include "Air_Quality_Sensor.h"
const int AirQualitySensor::FORCE_SIGNAL = 0;
const int AirQualitySensor::HIGH_POLLUTION = 1;
const int AirQualitySensor::LOW_POLLUTION = 2;
const int AirQualitySensor::FRESH_AIR = 3;
AirQualitySensor::AirQualitySensor(int pin)
: _pin(pin), _voltageSum(0), _volSumCount(0) {
// do nothing
}
bool AirQualitySensor::init(void) {
int initVoltage = analogRead(_pin);
if (10 < initVoltage && initVoltage < 798) {
_currentVoltage = initVoltage;
_lastVoltage = _currentVoltage;
_standardVoltage = initVoltage;
_lastStdVolUpdated = millis();
return true;
} else {
return false;
}
}
int AirQualitySensor::slope(void) {
_lastVoltage = _currentVoltage;
_currentVoltage = analogRead(_pin);
_voltageSum += _currentVoltage;
_volSumCount += 1;
updateStandardVoltage();
if (_currentVoltage - _lastVoltage > 400 || _currentVoltage > 700) {
return AirQualitySensor::FORCE_SIGNAL;
} else if ((_currentVoltage - _lastVoltage > 400 && _currentVoltage < 700)
|| _currentVoltage - _standardVoltage > 150) {
return AirQualitySensor::HIGH_POLLUTION;
} else if ((_currentVoltage - _lastVoltage > 200 && _currentVoltage < 700)
|| _currentVoltage - _standardVoltage > 50) {
return AirQualitySensor::LOW_POLLUTION;
} else {
return AirQualitySensor::FRESH_AIR;
}
return -1;
}
int AirQualitySensor::getValue(void) {
return _currentVoltage;
}
void AirQualitySensor::updateStandardVoltage(void) {
if (millis() - _lastStdVolUpdated > 500000) {
_standardVoltage = _voltageSum / _volSumCount;
_lastStdVolUpdated = millis();
_voltageSum = 0;
_volSumCount = 0;
}
}
/*
Air_Quality_Sensor.h
Header file for Grove - Air Quality Sensor.
Copyright (c) 2019 seeed technology inc.
Author : Lets Blu
Created Time : Jan 2019
Modified Time:
The MIT License (MIT)
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.
*/
#ifndef __AIR_QUALITY_SENSOR_H__
#define __AIR_QUALITY_SENSOR_H__
#include "Arduino.h"
class AirQualitySensor {
public:
AirQualitySensor(int pin);
bool init(void);
int slope(void);
int getValue(void);
static const int FORCE_SIGNAL;
static const int HIGH_POLLUTION;
static const int LOW_POLLUTION;
static const int FRESH_AIR;
protected:
int _pin;
int _lastVoltage;
int _currentVoltage;
int _standardVoltage;
long _voltageSum;
int _volSumCount;
long _lastStdVolUpdated;
void updateStandardVoltage(void);
};
#endif // __AIR_QUALITY_SENSOR_H__
## Grove Air Quality Sensor [![Build Status](https://travis-ci.com/Seeed-Studio/Grove_Air_quality_Sensor.svg?branch=master)](https://travis-ci.com/Seeed-Studio/Grove_Air_quality_Sensor)
[![Build Status](https://travis-ci.com/Seeed-Studio/Grove_Air_quality_Sensor.svg?branch=master)](https://travis-ci.com/Seeed-Studio/Grove_Air_quality_Sensor)-------------------------------------------------------------
![](https://statics3.seeedstudio.com/images/101020021%201.jpg)
[Grove Air Quality Sensor](https://www.seeedstudio.com/Grove-Air-quality-sensor-p-1065.html)
This sensor is designed for comprehensive monitoring of indoor air conditions.
It's responsive to a wide scope of harmful gases such as carbon monoxide, alcohol, acetone, thinner, formaldehyde and so on.
Due to the measuring mechanism, this sensor can not output specific data to describe target gases' concentrations quantitatively.
But it's still competent enough to be used in applications that require only qualitative results, like auto refresher sprayers and auto air cycling systems.
For more information, please refer to the [wiki page][1]
----
This software is written by Bruce Qin for Seeed Studio<br>
and is licensed under [The MIT License](http://opensource.org/licenses/mit-license.php). Check license.txt for more information.<br>
Contributing to this software is warmly welcomed. You can do this basically by<br>
[forking](https://help.github.com/articles/fork-a-repo), committing modifications and then submitting a [pull request](https://help.github.com/articles/using-pull-requests) (follow the links above<br>
for operating guide). Adding change log and your contact into file header is encouraged.<br>
Thanks for your contribution.
Seeed Studio is an open hardware facilitation company based in Shenzhen, China. <br>
Benefiting from local manufacturing power and a convenient global logistic system, <br>
we integrate resources to serve a new era of innovation. Seeed also works with <br>
global distributors and partners to push the open hardware movement.<br>
[1]:http://wiki.seeedstudio.com/Grove-Air_Quality_Sensor_v1.3
[![Analytics](https://ga-beacon.appspot.com/UA-46589105-3/Grove_Air_quality_Sensor)](https://github.com/igrigorik/ga-beacon)
/*
Grove_Air_Quality_Sensor.ino
Demo for Grove - Air Quality Sensor.
Copyright (c) 2019 seeed technology inc.
Author : Lets Blu
Created Time : Jan 2019
Modified Time:
The MIT License (MIT)
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.
*/
#include "Air_Quality_Sensor.h"
AirQualitySensor sensor(A0);
void setup(void) {
Serial.begin(9600);
while (!Serial);
Serial.println("Waiting sensor to init...");
delay(20000);
if (sensor.init()) {
Serial.println("Sensor ready.");
} else {
Serial.println("Sensor ERROR!");
}
}
void loop(void) {
int quality = sensor.slope();
Serial.print("Sensor value: ");
Serial.println(sensor.getValue());
if (quality == AirQualitySensor::FORCE_SIGNAL) {
Serial.println("High pollution! Force signal active.");
} else if (quality == AirQualitySensor::HIGH_POLLUTION) {
Serial.println("High pollution!");
} else if (quality == AirQualitySensor::LOW_POLLUTION) {
Serial.println("Low pollution!");
} else if (quality == AirQualitySensor::FRESH_AIR) {
Serial.println("Fresh air.");
}
delay(1000);
}
#######################################
# Syntax Coloring Map For
#######################################
#######################################
# Datatypes (KEYWORD1)
#######################################
i KEYWORD1
vol_standard KEYWORD1
init_voltage KEYWORD1
first_vol KEYWORD1
last_vol KEYWORD1
temp KEYWORD1
counter KEYWORD1
timer_index KEYWORD1
error KEYWORD1
#######################################
# Methods and Functions (KEYWORD2)
#######################################
init KEYWORD2
slope KEYWORD2
#######################################
# Constants (LITERAL1)
#######################################
\ No newline at end of file
name=Grove - Air quality sensor
version=1.0.1
author=Seeed Studio
maintainer=Seeed Studio <techsupport@seeed.cc>
sentence=Arduino library to control Grove Air Quality Sensor.
paragraph=Arduino library to control Grove Air Quality Sensor.
category=Sensors
url=https://github.com/Seeed-Studio/Grove_Air_quality_Sensor
architectures=avr
includes=AirQuality.h
The MIT License (MIT)
Copyright (c) 2014 Seeed Technology Inc.
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.
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment