mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.3.2 AGS02MA
This commit is contained in:
parent
fdb913bf85
commit
4c15fc1036
@ -1,3 +1,18 @@
|
||||
platforms:
|
||||
rpipico:
|
||||
board: rp2040:rp2040:rpipico
|
||||
package: rp2040:rp2040
|
||||
gcc:
|
||||
features:
|
||||
defines:
|
||||
- ARDUINO_ARCH_RP2040
|
||||
warnings:
|
||||
flags:
|
||||
|
||||
packages:
|
||||
rp2040:rp2040:
|
||||
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
|
||||
|
||||
compile:
|
||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||
platforms:
|
||||
@ -7,5 +22,7 @@ compile:
|
||||
# - leonardo
|
||||
- m4
|
||||
- esp32
|
||||
# - esp8266
|
||||
# - mega2560
|
||||
- esp8266
|
||||
# - mega2560
|
||||
- rpipico
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
// FILE: AGS02MA.cpp
|
||||
// AUTHOR: Rob Tillaart, Viktor Balint, Beanow
|
||||
// DATE: 2021-08-12
|
||||
// VERSION: 0.3.1
|
||||
// VERSION: 0.3.2
|
||||
// PURPOSE: Arduino library for AGS02MA TVOC
|
||||
// URL: https://github.com/RobTillaart/AGS02MA
|
||||
|
||||
@ -234,7 +234,7 @@ bool AGS02MA::getZeroCalibrationData(AGS02MA::ZeroCalibrationData &data) {
|
||||
}
|
||||
|
||||
_error = AGS02MA_OK;
|
||||
// Don't pollute the struct given to us, until we've handled all error cases.
|
||||
// Don't pollute the struct given to us, until we've handled all error cases.
|
||||
data.status = _getDataMSB();
|
||||
data.value = _getDataLSB();
|
||||
return true;
|
||||
@ -244,7 +244,7 @@ bool AGS02MA::getZeroCalibrationData(AGS02MA::ZeroCalibrationData &data) {
|
||||
int AGS02MA::lastError()
|
||||
{
|
||||
int e = _error;
|
||||
_error = AGS02MA_OK; // reset error after read
|
||||
_error = AGS02MA_OK; // reset error after read
|
||||
return e;
|
||||
}
|
||||
|
||||
@ -256,7 +256,7 @@ bool AGS02MA::readRegister(uint8_t address, AGS02MA::RegisterData ®) {
|
||||
}
|
||||
|
||||
_error = AGS02MA_OK;
|
||||
// Don't pollute the struct given to us, until we've handled all error cases.
|
||||
// Don't pollute the struct given to us, until we've handled all error cases.
|
||||
reg.data[0] = _buffer[0];
|
||||
reg.data[1] = _buffer[1];
|
||||
reg.data[2] = _buffer[2];
|
||||
@ -268,7 +268,7 @@ bool AGS02MA::readRegister(uint8_t address, AGS02MA::RegisterData ®) {
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
//
|
||||
// PRIVATE
|
||||
// PRIVATE
|
||||
//
|
||||
uint32_t AGS02MA::_readSensor()
|
||||
{
|
||||
@ -371,7 +371,7 @@ uint16_t AGS02MA::_getDataLSB()
|
||||
|
||||
uint8_t AGS02MA::_CRC8(uint8_t * buf, uint8_t size)
|
||||
{
|
||||
uint8_t crc = 0xFF; // start value
|
||||
uint8_t crc = 0xFF; // start value
|
||||
for (uint8_t b = 0; b < size; b++)
|
||||
{
|
||||
crc ^= buf[b];
|
||||
|
@ -3,7 +3,7 @@
|
||||
// FILE: AGS02MA.h
|
||||
// AUTHOR: Rob Tillaart, Viktor Balint, Beanow
|
||||
// DATE: 2021-08-12
|
||||
// VERSION: 0.3.1
|
||||
// VERSION: 0.3.2
|
||||
// PURPOSE: Arduino library for AGS02MA TVOC
|
||||
// URL: https://github.com/RobTillaart/AGS02MA
|
||||
//
|
||||
@ -13,7 +13,7 @@
|
||||
#include "Wire.h"
|
||||
|
||||
|
||||
#define AGS02MA_LIB_VERSION (F("0.3.1"))
|
||||
#define AGS02MA_LIB_VERSION (F("0.3.2"))
|
||||
|
||||
#define AGS02MA_OK 0
|
||||
#define AGS02MA_ERROR -10
|
||||
@ -38,17 +38,17 @@ public:
|
||||
struct ZeroCalibrationData
|
||||
{
|
||||
/**
|
||||
* Warning, the exact meaning of this status is not fully documented.
|
||||
* It seems like it's a bitmask:
|
||||
* 0000 1100 | 0x0C | 12 | Typical value
|
||||
* 0000 1101 | 0x0D | 13 | Sometimes seen on v117
|
||||
* 0111 1101 | 0x7D | 125 | Seen on v118, after power-off (gives different data than 12!)
|
||||
* Warning, the exact meaning of this status is not fully documented.
|
||||
* It seems like it's a bit mask:
|
||||
* 0000 1100 | 0x0C | 12 | Typical value
|
||||
* 0000 1101 | 0x0D | 13 | Sometimes seen on v117
|
||||
* 0111 1101 | 0x7D | 125 | Seen on v118, after power-off (gives different data than 12!)
|
||||
*/
|
||||
uint16_t status;
|
||||
uint16_t value;
|
||||
};
|
||||
|
||||
// address 26 = 0x1A
|
||||
// address 26 = 0x1A
|
||||
explicit AGS02MA(const uint8_t deviceAddress = 26, TwoWire *wire = &Wire);
|
||||
|
||||
#if defined (ESP8266) || defined(ESP32)
|
||||
@ -61,57 +61,57 @@ public:
|
||||
bool isHeated() { return (millis() - _startTime) > 120000UL; };
|
||||
|
||||
|
||||
// CONFIGURATION
|
||||
// CONFIGURATION
|
||||
bool setAddress(const uint8_t deviceAddress);
|
||||
uint8_t getAddress() { return _address; };
|
||||
uint8_t getSensorVersion();
|
||||
uint32_t getSensorDate();
|
||||
|
||||
// to set the speed the I2C bus should return to
|
||||
// as the device operates at very low bus speed of 30 kHz.
|
||||
// to set the speed the I2C bus should return to
|
||||
// as the device operates at very low bus speed of 30 kHz.
|
||||
void setI2CResetSpeed(uint32_t speed) { _I2CResetSpeed = speed; };
|
||||
uint32_t getI2CResetSpeed() { return _I2CResetSpeed; };
|
||||
|
||||
// to be called after at least 5 minutes in fresh air.
|
||||
// to be called after at least 5 minutes in fresh air.
|
||||
bool zeroCalibration() { return manualZeroCalibration(0); };
|
||||
|
||||
/**
|
||||
* Set the zero calibration value manually.
|
||||
* To be called after at least 5 minutes in fresh air.
|
||||
* For v117: 0-65535 = automatic calibration.
|
||||
* For v118: 0 = automatic calibration, 1-65535 manual calibration.
|
||||
* Set the zero calibration value manually.
|
||||
* To be called after at least 5 minutes in fresh air.
|
||||
* For v117: 0-65535 = automatic calibration.
|
||||
* For v118: 0 = automatic calibration, 1-65535 manual calibration.
|
||||
*/
|
||||
bool manualZeroCalibration(uint16_t value = 0);
|
||||
bool getZeroCalibrationData(ZeroCalibrationData &data);
|
||||
|
||||
|
||||
// MODE
|
||||
// MODE
|
||||
bool setPPBMode();
|
||||
bool setUGM3Mode();
|
||||
uint8_t getMode() { return _mode; };
|
||||
|
||||
|
||||
// READ functions
|
||||
uint32_t readPPB(); // parts per billion 10^9
|
||||
uint32_t readUGM3(); // microgram per cubic meter
|
||||
// READ functions
|
||||
uint32_t readPPB(); // parts per billion 10^9
|
||||
uint32_t readUGM3(); // microgram per cubic meter
|
||||
|
||||
// derived read functions
|
||||
float readPPM() { return readPPB() * 0.001; }; // parts per million
|
||||
float readMGM3() { return readUGM3() * 0.001; }; // milligram per cubic meter
|
||||
float readUGF3() { return readUGM3() * 0.0283168466; }; // microgram per cubic feet
|
||||
// derived read functions
|
||||
float readPPM() { return readPPB() * 0.001; }; // parts per million
|
||||
float readMGM3() { return readUGM3() * 0.001; }; // milligram per cubic meter
|
||||
float readUGF3() { return readUGM3() * 0.0283168466; }; // microgram per cubic feet
|
||||
|
||||
float lastPPM() { return _lastPPB * 0.001; };
|
||||
uint32_t lastPPB() { return _lastPPB; }; // fetch last PPB measurement
|
||||
uint32_t lastPPB() { return _lastPPB; }; // fetch last PPB measurement
|
||||
uint32_t lastUGM3() { return _lastUGM3; }; // fetch last UGM3 measurement
|
||||
|
||||
|
||||
// STATUS
|
||||
uint32_t lastRead() { return _lastRead; }; // timestamp last measurement
|
||||
// STATUS
|
||||
uint32_t lastRead() { return _lastRead; }; // timestamp last measurement
|
||||
int lastError();
|
||||
uint8_t lastStatus() { return _status; };
|
||||
uint8_t dataReady() { return _status & 0x01; };
|
||||
|
||||
// Reading registers
|
||||
// Reading registers
|
||||
bool readRegister(uint8_t address, RegisterData ®);
|
||||
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/AGS02MA.git"
|
||||
},
|
||||
"version": "0.3.1",
|
||||
"version": "0.3.2",
|
||||
"license": "MIT",
|
||||
"frameworks": "arduino",
|
||||
"platforms": "*",
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=AGS02MA
|
||||
version=0.3.1
|
||||
version=0.3.2
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Arduino library for AGS02MA - TVOC sensor
|
||||
|
Loading…
x
Reference in New Issue
Block a user