mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.1.3 AGS02MA
This commit is contained in:
parent
971e7bcb99
commit
73ca1cccbb
@ -2,7 +2,7 @@
|
||||
// FILE: AGS02MA.cpp
|
||||
// AUTHOR: Rob Tillaart, Viktor Balint
|
||||
// DATE: 2021-08-12
|
||||
// VERSION: 0.1.2
|
||||
// VERSION: 0.1.3
|
||||
// PURPOSE: Arduino library for AGS02MA TVOC
|
||||
// URL: https://github.com/RobTillaart/AGS02MA
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
// FILE: AGS02MA.h
|
||||
// AUTHOR: Rob Tillaart, Viktor Balint
|
||||
// DATE: 2021-08-12
|
||||
// VERSION: 0.1.2
|
||||
// VERSION: 0.1.3
|
||||
// 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.1.2"))
|
||||
#define AGS02MA_LIB_VERSION (F("0.1.3"))
|
||||
|
||||
#define AGS02MA_OK 0
|
||||
#define AGS02MA_ERROR -10
|
||||
@ -47,7 +47,7 @@ public:
|
||||
|
||||
// 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 s) { _I2CResetSpeed = s; };
|
||||
void setI2CResetSpeed(uint32_t speed) { _I2CResetSpeed = speed; };
|
||||
uint32_t getI2CResetSpeed() { return _I2CResetSpeed; };
|
||||
|
||||
// to be called after at least 5 minutes in fresh air.
|
||||
|
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021-2021 Rob Tillaart
|
||||
Copyright (c) 2021-2022 Rob Tillaart
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
[![Arduino CI](https://github.com/RobTillaart/AGS02MA/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
|
||||
[![Arduino-lint](https://github.com/RobTillaart/AGS02MA/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/AGS02MA/actions/workflows/arduino-lint.yml)
|
||||
[![JSON check](https://github.com/RobTillaart/AGS02MA/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/AGS02MA/actions/workflows/jsoncheck.yml)
|
||||
@ -10,7 +11,7 @@
|
||||
Arduino library for AGS02MA TVOC sensor.
|
||||
|
||||
This library is experimental, so please use with care.
|
||||
Note the warning about the I2C speed, the device works at 30 KHz.
|
||||
Note the warning about the I2C speed, the device works at only 30 KHz.
|
||||
|
||||
|
||||
## I2C - warning low speed
|
||||
@ -43,8 +44,7 @@ The reset clock speed can be changed with **setI2CResetSpeed()** e.g. to 200 or
|
||||
|
||||
- **bool isHeated()** returns true if 2 minutes have passed after startup (call of **begin()** ).
|
||||
Otherwise the device is not optimal ready.
|
||||
According to the datasheet the preheating will improve the quality
|
||||
of the measurements.
|
||||
According to the datasheet the preheating will improve the quality of the measurements.
|
||||
- **uint32_t lastRead()** last time the device is read, timestamp is in milliseconds since start.
|
||||
Returns 0 if **readPPB()** or **readUGM3()** is not called yet.
|
||||
This function allows to implement sort of asynchronous wait.
|
||||
@ -58,14 +58,14 @@ If function succeeds the address changes immediately and will be persistent over
|
||||
- **uint8_t getAddress()** returns the set address. Default the function will return 26 or 0x1A.
|
||||
- **uint8_t getSensorVersion()** reads sensor version from device.
|
||||
If the version cannot be read the function will return 255.
|
||||
(My test sensors all return 117)
|
||||
(My test sensors all return version 117)
|
||||
|
||||
The library sets the clock speed to 30 KHz (for non AVR) during operation
|
||||
and resets it to 100 KHz after operation.
|
||||
This is done to minimize interference with the communication of other devices.
|
||||
The following function can change the I2C reset speed to e.g. 200 or 400 KHz.
|
||||
|
||||
- **void setI2CResetSpeed(uint32_t s)** sets the I2C speed the library need to reset the I2C speed to.
|
||||
- **void setI2CResetSpeed(uint32_t speed)** sets the I2C speed the library need to reset the I2C speed to.
|
||||
- **uint32_t getI2CResetSpeed()** returns the value set. Default is 100 KHz.
|
||||
|
||||
|
||||
@ -97,14 +97,14 @@ Simplified formula for 1 atm @ 25°C:
|
||||
|
||||
Some known gasses
|
||||
|
||||
| gas | ratio | molecular weight M |
|
||||
|:--------|:--------------------|:------------------:|
|
||||
| SO2 | 1 ppb = 2.62 μg/m3 | 64 |
|
||||
| NO2 | 1 ppb = 1.88 μg/m3 | 46 |
|
||||
| NO | 1 ppb = 1.25 μg/m3 | 30 |
|
||||
| O3 | 1 ppb = 2.00 μg/m3 | 48 |
|
||||
| CO | 1 ppb = 1.145 μg/m3 | 28 |
|
||||
| Benzene | 1 ppb = 3.19 μg/m3 | 78 | C6H6 |
|
||||
| gas | Common name | ratio | molecular weight M |
|
||||
|:-----|:--------------|:--------------------|:------------------:|
|
||||
| SO2 | | 1 ppb = 2.62 μg/m3 | 64 |
|
||||
| NO2 | | 1 ppb = 1.88 μg/m3 | 46 |
|
||||
| NO | | 1 ppb = 1.25 μg/m3 | 30 |
|
||||
| O3 | | 1 ppb = 2.00 μg/m3 | 48 |
|
||||
| CO | | 1 ppb = 1.145 μg/m3 | 28 |
|
||||
| C6H6 | Benzene | 1 ppb = 3.19 μg/m3 | 78 |
|
||||
|
||||
|
||||
### Reading
|
||||
@ -147,10 +147,10 @@ Read datasheet or table below for details.
|
||||
|
||||
#### Status bits.
|
||||
|
||||
| bit | description |
|
||||
|:----:|:-----------------------|
|
||||
| 7-4 | internal use |
|
||||
| 3-1 | 000 = PPB 001 = uG/M3 |
|
||||
| bit | description |
|
||||
|:----:|:----------------------------------|
|
||||
| 7-4 | internal use |
|
||||
| 3-1 | 000 = PPB 001 = uG/M3 |
|
||||
| 0 | RDY bit 0 = ready 1 = not ready |
|
||||
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
// URL: https://github.com/RobTillaart/AGS02MA
|
||||
//
|
||||
|
||||
|
||||
#include "AGS02MA.h"
|
||||
|
||||
|
||||
@ -51,7 +52,6 @@ void setup()
|
||||
uint8_t version = AGS.getSensorVersion();
|
||||
Serial.print("VERS:\t");
|
||||
Serial.println(version);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
AGS02MA AGS(26);
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
@ -67,4 +68,6 @@ void loop()
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -62,8 +62,8 @@ void loop()
|
||||
Serial.print("\t");
|
||||
Serial.print(AGS.lastError(), HEX);
|
||||
Serial.println();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -49,7 +49,6 @@ void setup()
|
||||
uint8_t version = AGS.getSensorVersion();
|
||||
Serial.print("VERS:\t");
|
||||
Serial.println(version);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -47,7 +47,7 @@ void loop()
|
||||
Serial.print("CRC:\t");
|
||||
Serial.println(buffer[4]);
|
||||
Serial.println();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// FILE: AGS02MA_minimal_plotter.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: test application
|
||||
// PURPOSE: test application not using the library
|
||||
// DATE: 2021-09-23
|
||||
// URL: https://github.com/RobTillaart/AGS02MA
|
||||
//
|
||||
@ -18,6 +18,7 @@ uint8_t buffer[5];
|
||||
|
||||
uint8_t cnt = 0;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
@ -57,4 +58,5 @@ void loop()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
@ -7,6 +7,7 @@
|
||||
// URL: https://github.com/RobTillaart/AGS02MA
|
||||
//
|
||||
|
||||
|
||||
#include "AGS02MA.h"
|
||||
|
||||
|
||||
|
@ -39,7 +39,6 @@ void setup()
|
||||
uint8_t version = AGS.getSensorVersion();
|
||||
Serial.print("VERS:\t");
|
||||
Serial.println(version);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -70,4 +70,6 @@ void dump(char * str)
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
// just for develop scratch pad
|
||||
// need to make the CRC function public in the library
|
||||
|
||||
|
||||
#include "AGS02MA.h"
|
||||
|
||||
|
||||
@ -74,7 +75,6 @@ void setup()
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -37,6 +37,7 @@ dataReady KEYWORD2
|
||||
|
||||
# Constants ( LITERAL1)
|
||||
AGS02MA_LIB_VERSION LITERAL1
|
||||
|
||||
AGS02MA_OK LITERAL1
|
||||
AGS02MA_ERROR LITERAL1
|
||||
AGS02MA_ERROR_CRC LITERAL1
|
||||
|
@ -18,8 +18,9 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/AGS02MA.git"
|
||||
},
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.3",
|
||||
"license": "MIT",
|
||||
"frameworks": "arduino",
|
||||
"platforms": "*"
|
||||
"platforms": "*",
|
||||
"headers": "AGS02MA.h"
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=AGS02MA
|
||||
version=0.1.2
|
||||
version=0.1.3
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Arduino library for AGS02MA - TVOC sensor
|
||||
|
@ -33,17 +33,31 @@ unittest_setup()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
unittest_teardown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
unittest(test_constants)
|
||||
{
|
||||
fprintf(stderr, "AGS02MA_LIB_VERSION: %s\n", (char *) AGS02MA_LIB_VERSION);
|
||||
|
||||
assertEqual( 0, AGS02MA_OK);
|
||||
assertEqual(-10, AGS02MA_ERROR);
|
||||
assertEqual(-11, AGS02MA_ERROR_CRC);
|
||||
assertEqual(-12, AGS02MA_ERROR_READ);
|
||||
|
||||
assertEqual(30000, AGS02MA_I2C_CLOCK);
|
||||
}
|
||||
|
||||
|
||||
unittest(test_base)
|
||||
{
|
||||
AGS02MA AGS(26);
|
||||
Wire.begin();
|
||||
|
||||
fprintf(stderr, "AGS02MA_LIB_VERSION: %s\n", AGS02MA_LIB_VERSION);
|
||||
fprintf(stderr, "AGS02MA_LIB_VERSION: %s\n", (char *) AGS02MA_LIB_VERSION);
|
||||
|
||||
assertTrue(AGS.begin());
|
||||
assertTrue(AGS.isConnected()); // TODO - GODMODE
|
||||
@ -69,7 +83,7 @@ unittest(test_mode)
|
||||
AGS02MA AGS(26);
|
||||
Wire.begin();
|
||||
|
||||
fprintf(stderr, "AGS02MA_LIB_VERSION: %s\n", AGS02MA_LIB_VERSION);
|
||||
fprintf(stderr, "AGS02MA_LIB_VERSION: %s\n", (char *) AGS02MA_LIB_VERSION);
|
||||
|
||||
assertTrue(AGS.begin());
|
||||
assertTrue(AGS.isConnected()); // TODO - GODMODE
|
||||
|
Loading…
Reference in New Issue
Block a user