robtillaart / ags02ma Goto Github PK
View Code? Open in Web Editor NEWArduino library for AGS02MA TVOC sensor
License: MIT License
Arduino library for AGS02MA TVOC sensor
License: MIT License
As per the source stated in the README, the safe TVOC levels shown are stated in ppb.
The README shows the same numbers with the units being ppm, which is incorrect.
I used the manualZeroCalibration() and passed the previous calibration value i got from automatic calibration sketch after That sensor values constantly decreases and gets to 0.
After applying the kolibrovochny sketch. My sensor started showing values in ppm like this: 12002000020
See: adafruit/Adafruit_BusIO#104
If the prescaler was not 0 just setting the TWBR register low is not always enough.
Need to explicitly set prescaler too.
And set the prescaler back too.
Or at least, the datasheet and output don't seem to match up. Is this how your (v117) devices behave as well?
I've got three (v118) AGS02MA here, that I wasn't able to get into UGM3 measurements on some custom ESP IDF code. Thought I was going mad so I tried an Arduino uno with your library and see the same results, not really changing modes apparently.
Looking at the datasheet, I'd expect the status value to change.
b0000
(decimal 0) for ready + PPB mode.b0010
(decimal 2) for ready + UGM3 mode.Using an adaptation of the library example code, I set up one that alternates modes every 10 measurements. Except that it doesn't? Here's some output I'm seeing with the status being 0 throughout. And no noticeable change in measured value either (other than going down as it warms up).
/home/beanow/duino/AGS02MA_PPB/AGS02MA_PPB.ino
AGS02MA_LIB_VERSION: 0.1.3
BEGIN: 1
VERSION: 118
VERS: 118
MODE: 1 0
PPB: 85 0 0
PPB: 85 0 0
PPB: 85 0 0
PPB: 85 0 0
PPB: 85 0 0
PPB: 85 0 0
PPB: 85 0 0
PPB: 85 0 0
PPB: 85 0 0
PPB: 85 0 0
MODE: 1 1
UGM3: 85 0 0
UGM3: 85 0 0
UGM3: 85 0 0
UGM3: 85 0 0
UGM3: 85 0 0
UGM3: 85 0 0
UGM3: 84 0 0
UGM3: 84 0 0
UGM3: 84 0 0
UGM3: 84 0 0
MODE: 1 0
PPB: 84 0 0
PPB: 84 0 0
PPB: 84 0 0
PPB: 84 0 0
PPB: 84 0 0
PPB: 84 0 0
PPB: 84 0 0
PPB: 84 0 0
PPB: 84 0 0
PPB: 84 0 0
MODE: 1 1
UGM3: 83 0 0
UGM3: 83 0 0
UGM3: 83 0 0
//
// FILE: AGS02MA_PPB.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: test application
// DATE: 2021-08-12
// URL: https://github.com/RobTillaart/AGS02MA
//
#include "AGS02MA.h"
AGS02MA AGS(26);
uint32_t rounds = 0;
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Wire.begin();
Serial.print("AGS02MA_LIB_VERSION: ");
Serial.println(AGS02MA_LIB_VERSION);
Serial.println();
bool b = AGS.begin();
Serial.print("BEGIN:\t");
Serial.println(b);
Serial.print("VERSION:\t");
Serial.println(AGS.getSensorVersion());
// pre-heating improves measurement quality
// can be skipped
// Serial.println("\nWarming up (120 seconds = 24 dots)");
// while (AGS.isHeated() == false)
// {
// delay(5000);
// Serial.print(".");
// }
// Serial.println();
uint8_t version = AGS.getSensorVersion();
Serial.print("VERS:\t");
Serial.println(version);
}
void loop()
{
delay(3000);
uint8_t kind = rounds % 20;
// Switch mode every 10 and 20 rounds.
bool b;
if (kind == 0) {
b = AGS.setPPBMode();
uint8_t m = AGS.getMode();
Serial.print("MODE:\t");
Serial.print(b);
Serial.print("\t");
Serial.println(m);
} else if (kind == 10) {
b = AGS.setUGM3Mode();
uint8_t m = AGS.getMode();
Serial.print("MODE:\t");
Serial.print(b);
Serial.print("\t");
Serial.println(m);
}
// Read PPB in first half of a 20-round cycle.
if (kind < 10) {
uint32_t value = AGS.readPPB();
Serial.print("PPB:\t");
Serial.print(value);
Serial.print("\t");
Serial.print(AGS.lastStatus(), HEX);
Serial.print("\t");
Serial.print(AGS.lastError(), HEX);
Serial.println();
} else {
uint32_t value = AGS.readUGM3();
Serial.print("UGM3:\t");
Serial.print(value);
Serial.print("\t");
Serial.print(AGS.lastStatus(), HEX);
Serial.print("\t");
Serial.print(AGS.lastError(), HEX);
Serial.println();
}
rounds++;
}
// -- END OF FILE --
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.