Skip to content

Commit 7c5eb85

Browse files
committed
update readme.md + minor edits
1 parent 78643ea commit 7c5eb85

File tree

23 files changed

+110
-63
lines changed

23 files changed

+110
-63
lines changed

AGS02MA.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// FILE: AGS02MA.cpp
33
// AUTHOR: Rob Tillaart, Viktor Balint, Beanow
44
// DATE: 2021-08-12
5-
// VERSION: 0.4.2
5+
// VERSION: 0.4.3
66
// PURPOSE: Arduino library for AGS02MA TVOC sensor
77
// URL: https://github.com/RobTillaart/AGS02MA
88

AGS02MA.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@
33
// FILE: AGS02MA.h
44
// AUTHOR: Rob Tillaart, Viktor Balint, Beanow
55
// DATE: 2021-08-12
6-
// VERSION: 0.4.2
6+
// VERSION: 0.4.3
77
// PURPOSE: Arduino library for AGS02MA TVOC sensor
88
// URL: https://github.com/RobTillaart/AGS02MA
9-
//
109

1110

1211
#include "Arduino.h"
1312
#include "Wire.h"
1413

1514

16-
#define AGS02MA_LIB_VERSION (F("0.4.2"))
15+
#define AGS02MA_LIB_VERSION (F("0.4.3"))
1716

1817
#define AGS02MA_OK 0
1918
#define AGS02MA_ERROR -10

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

88

9+
10+
## [0.4.3] - 2025-08-15
11+
- update readme.md
12+
- update license
13+
- minor edits
14+
915
## [0.4.2] - 2024-02-03
1016
- update readme.md
1117
- added multiplexer section
@@ -18,7 +24,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1824
- redo **readRegister()**
1925
- minor edits
2026

21-
2227
## [0.4.1] - 2023-12-10
2328
- fix #26, error in readme.
2429

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021-2024 Rob Tillaart
3+
Copyright (c) 2021-2025 Rob Tillaart
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 75 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
Arduino library for AGS02MA TVOC sensor.
1515

1616

17-
#### Description
17+
### Description
1818

19-
This library is still experimental, so please use with care.
19+
**Experimental**
20+
21+
This library is experimental, so please use with care.
2022

2123
The AGS02MA is a sensor that measures the TVOC = Total Volatile Organic Compounds
2224
in the air. It does not measure a specific gas, but several.
@@ -25,36 +27,55 @@ in the air. It does not measure a specific gas, but several.
2527
Note the warning about the I2C low speed, the device works at max 30 KHz.
2628
Since 0.3.1 this library uses 25 KHz.
2729

28-
Note this library is not meant to replace professional monitoring systems.
30+
Feedback as always, is welcome. Please open an issue.
31+
32+
Note this library is **not** meant to replace professional monitoring systems.
2933

3034

31-
#### 0.4.0 Breaking change
35+
### 0.4.0 Breaking change
3236

3337
Version 0.4.0 introduced a breaking change.
3438
You cannot set the pins in **begin()** any more.
3539
This reduces the dependency of processor dependent Wire implementations.
36-
The user has to call **Wire.begin()** and can optionally set the Wire pins
40+
The user has to call **Wire.begin()** and can optionally set the Wire pins
3741
before calling **begin()**.
3842

3943

40-
#### Related
44+
### Related
4145

46+
- https://github.com/RobTillaart/AGS02MA TVOC sensor
47+
- https://github.com/RobTillaart/AGS2616 H2 sensor
48+
- https://github.com/RobTillaart/AGS3870 CH4 sensor
49+
- https://github.com/RobTillaart/AGS3871 CO sensor
4250
- https://www.renesas.com/us/en/document/whp/overview-tvoc-and-indoor-air-quality
43-
51+
- https://github.com/RobTillaart/map2colour
52+
- https://github.com/RobTillaart/SGP30 (experimental)
4453

4554
## I2C
4655

4756
### PIN layout from left to right
4857

4958
| Front L->R | Description |
5059
|:------------:|:--------------|
51-
| pin 1 | VDD + |
60+
| pin 1 | VDD +5V |
5261
| pin 2 | SDA data |
5362
| pin 3 | GND |
5463
| pin 4 | SCL clock |
5564

5665

57-
#### WARNING - LOW SPEED
66+
### Address
67+
68+
The device has a fixed address of 26 or 0x1A.
69+
70+
The device works at 100 kHz I2C bus speed (datasheet).
71+
72+
Note: several AGS devices use the same I2C address 0x1A.
73+
Known are the AGS2616 (H2), AGS3870 (CH4), AGS3871 (CO), AGS02MA (TVOC).
74+
If you want to use them on one I2C bus, you need multiplexing.
75+
See section below.
76+
77+
78+
### WARNING - LOW SPEED
5879

5980
The sensor uses I2C at very low speed <= 30 KHz.
6081
For an Arduino UNO the lowest speed supported is about 30.4KHz (TWBR = 255) which works.
@@ -69,7 +90,7 @@ This is done to minimize interference with the communication of other devices.
6990
The reset clock speed can be changed with **setI2CResetSpeed(speed)** e.g. to 200 or 400 KHz.
7091

7192

72-
#### 0.3.1 fix.
93+
### 0.3.1 fix.
7394

7495
Version 0.3.1 sets the **I2C prescaler TWSR** register of the Arduino UNO to 4 so the lowest
7596
speed possible is reduced to about 8 KHz.
@@ -78,19 +99,19 @@ So the communication speed will be set to 25 KHz, also for other boards, for sta
7899
After communication the clock (+ prescaler) is reset again as before.
79100

80101

81-
#### I2C multiplexing
102+
### I2C multiplexing
82103

83104
Sometimes you need to control more devices than possible with the default
84105
address range the device provides.
85-
This is possible with an I2C multiplexer e.g. TCA9548 which creates up
86-
to eight channels (think of it as I2C subnets) which can use the complete
87-
address range of the device.
106+
This is possible with an I2C multiplexer e.g. TCA9548 which creates up
107+
to eight channels (think of it as I2C subnets) which can use the complete
108+
address range of the device.
88109

89-
Drawback of using a multiplexer is that it takes more administration in
90-
your code e.g. which device is on which channel.
110+
Drawback of using a multiplexer is that it takes more administration in
111+
your code e.g. which device is on which channel.
91112
This will slow down the access, which must be taken into account when
92113
deciding which devices are on which channel.
93-
Also note that switching between channels will slow down other devices
114+
Also note that switching between channels will slow down other devices
94115
too if they are behind the multiplexer.
95116

96117
- https://github.com/RobTillaart/TCA9548
@@ -103,7 +124,7 @@ My devices all report version 117 and this version is used to develop / test thi
103124
There are devices reported with version 118 which behave differently.
104125

105126

106-
#### ugM3 not supported
127+
### ugM3 not supported
107128

108129
See - https://github.com/RobTillaart/AGS02MA/issues/11
109130

@@ -114,7 +135,7 @@ If you encounter similar problems with setting the mode (any version), please le
114135
That will help indicating if this is a "structural change" or incident.
115136

116137

117-
#### Calibrate problem!
138+
### Calibrate problem!
118139

119140
See - https://github.com/RobTillaart/AGS02MA/issues/13
120141

@@ -130,7 +151,7 @@ Note: the version 0.2.0 determines the version in the calibration function so
130151
it won't calibrate any non 117 version.
131152

132153

133-
#### Please report your experiences.
154+
### Please report your experiences.
134155

135156
If you have a AGS20MA device, version 117 or 118 or other,
136157
please let me know your experiences
@@ -143,43 +164,49 @@ with the sensor and this (or other) library.
143164
#include "AGS02MA.h"
144165
```
145166

146-
#### Constructor
167+
### Constructor
147168

148-
- **AGS02MA(uint8_t deviceAddress = 26, TwoWire \*wire = &Wire)** constructor,
169+
- **AGS02MA(uint8_t deviceAddress = 26, TwoWire \*wire = &Wire)** constructor,
149170
with default address and default I2C interface.
150-
- **bool begin()** initialize the library.
151-
- **bool isConnected()** returns true if device address can be seen on I2C.
152-
- **void reset()** reset internal variables.
171+
- **bool begin()** initialize the library.
172+
Returns false if deviceAddress cannot be seen on the I2C bus.
173+
- **bool isConnected()** returns true if deviceAddress can be seen on I2C, false otherwise.
174+
- **void reset()** resets the internal variables.
153175

154176

155-
#### Timing
177+
### Heating
156178

157-
- **bool isHeated()** returns true if 2 minutes have passed after startup (call of **begin()** ).
179+
- **bool isHeated()** returns true if 2 minutes have passed after call of **begin()**.
158180
Otherwise the device is not optimal ready.
159-
According to the datasheet the preheating will improve the quality of the measurements.
160-
- **uint32_t lastRead()** last time the device is read, timestamp is in milliseconds since start.
181+
According to the datasheet, preheating will improve the quality of the measurements.
182+
Note: if begin() is not called, isHeated() might be incorrect.
183+
- **uint32_t lastRead()** returns the last time the device is read,
184+
timestamp is in milliseconds since start.
161185
Returns 0 if **readPPB()** or **readUGM3()** is not called yet.
162186
This function allows to implement sort of asynchronous wait.
163-
One must keep reads at least 1.5 seconds but preferred 3 seconds apart according to the datasheet.
187+
One must keep reads / measurements at least 1.5 seconds but preferred 3 seconds
188+
apart according to the datasheet.
164189

165190

166-
#### Administration
191+
### Administration
167192

168193
- **bool setAddress(const uint8_t deviceAddress)** sets a new address for the sensor.
169194
If function succeeds the address changes immediately and will be persistent over a reboot.
170195
- **uint8_t getAddress()** returns the set address. Default the function will return 26 or 0x1A.
171-
- **uint8_t getSensorVersion()** reads sensor version from device.
196+
- **uint8_t getSensorVersion()** reads sensor version from the device.
172197
If the version cannot be read the function will return 255.
173-
(My test sensors all return version 117, version 118 is reported)
174-
- **uint32_t getSensorDate()** (experimental) reads bytes from the sensor that seem to indicate the production date(?). This date is encoded in an uint32_t to minimize footprint as it is a debug function.
198+
My test sensors all return version 117, version 118 is reported to exist too.
199+
- **uint32_t getSensorDate()** (experimental) reads bytes from the sensor that seem
200+
to indicate the production date(?).
201+
This date is encoded in an uint32_t to minimize footprint as it is a debug function.
175202

176203
```cpp
177204
uint32_t dd = sensor.getSensorDate();
178205
Serial.println(dd, HEX); // prints YYYYMMDD e.g. 20210203
179206
```
180207

181208

182-
#### I2C clock speed
209+
### I2C clock speed
183210

184211
The library sets the clock speed to 25 KHz during operation
185212
and resets it to 100 KHz after operation.
@@ -190,7 +217,7 @@ The following function can change the I2C reset speed to e.g. 200 or 400 KHz.
190217
- **uint32_t getI2CResetSpeed()** returns the value set. Default is 100 KHz.
191218

192219

193-
#### setMode
220+
### setMode
194221

195222
The default mode at startup of the sensor is PPB = parts per billion.
196223

@@ -199,7 +226,7 @@ The default mode at startup of the sensor is PPB = parts per billion.
199226
- **uint8_t getMode()** returns mode set. 0 = PPB, 1 = UGm3, 255 = not set.
200227

201228

202-
#### Air quality classification
229+
### Air quality classification
203230

204231
Indicative
205232

@@ -220,7 +247,7 @@ Indicative
220247
- https://github.com/RobTillaart/map2colour for continuous scale.
221248

222249

223-
#### PPB versus UGM3
250+
### PPB versus UGM3
224251

225252
There is no 1 to 1 relation between the PPB and the uG/m3 readings as this relation depends
226253
on the weight of the individual molecules.
@@ -252,7 +279,7 @@ Some known gasses
252279
- https://github.com/RobTillaart/AtomicWeight (determine M from chemical formula)
253280

254281

255-
#### Read the sensor
282+
### Read the sensor
256283

257284
WARNING: The datasheet advises to take 3 seconds between reads.
258285
Tests gave stable results at 1.5 second intervals.
@@ -273,7 +300,7 @@ Typical value should be between 0.01 .. 999.99
273300
- **float readUGF3()** returns microgram per cubic feet.
274301

275302

276-
#### Error Codes
303+
### Error Codes
277304

278305
| ERROR_CODES | value |
279306
|:----------------------------|:-------:|
@@ -284,40 +311,40 @@ Typical value should be between 0.01 .. 999.99
284311
| AGS02MA_ERROR_NOT_READY | -13 |
285312

286313

287-
#### Cached values
314+
### Cached values
288315

289316
- **float lastPPM()** returns last readPPM (parts per million) value (cached).
290317
- **uint32_t lastPPB()** returns last read PPB (parts per billion) value (cached). Should be between 1..999999.
291318
- **uint32_t lastUGM3()** returns last read UGM3 (microgram per cubic meter) value (cached).
292319

293320

294-
#### Calibration
321+
### Calibration
295322

296323
- **bool zeroCalibration()** to be called after at least 5 minutes in fresh air.
297324
See example sketch.
298325
- **bool manualZeroCalibration(uint16_t value = 0)** Set the zero calibration value manually.
299326
To be called after at least 5 minutes in fresh air.
300327
- For v117: 0-65535 = automatic calibration.
301328
- For v118: 0 = automatic calibration, 1-65535 manual calibration.
302-
- **bool getZeroCalibrationData(ZeroCalibrationData &data)** fills a data struct with the
303-
current zero calibration status and value.
329+
- **bool getZeroCalibrationData(ZeroCalibrationData &data)** fills a data struct with the
330+
current zero calibration status and value.
304331
Returns true on success.
305332

306333

307-
#### Other
334+
### Other
308335

309336
- **bool readRegister(uint8_t address, RegisterData &reg)** fills a data struct with the chip's register data at that address.
310337
Primarily intended for troubleshooting and analysis of the sensor. Not recommended to build applications on top of this method's raw data.
311338
Returns true when the **RegisterData** is filled, false when the data could not be read.
312-
Note: unlike other public methods, CRC errors don't return false or show up in `lastError()`,
339+
Note: unlike other public methods, CRC errors don't return false or show up in `lastError()`,
313340
instead the CRC result is stored in `RegisterData.crcValid`.
314341
- **int lastError()** returns last error.
315342
- **uint8_t lastStatus()** returns status byte from last read.
316343
Read datasheet or table below for details. A new read is needed to update this.
317344
- **uint8_t dataReady()** returns RDY bit from last read.
318345

319346

320-
#### Status bits.
347+
### Status bits.
321348

322349
| bit | description | notes |
323350
|:-----:|:------------------------------------|:--------|
@@ -340,6 +367,7 @@ Read datasheet or table below for details. A new read is needed to update this.
340367
- test with hardware
341368
- different gasses ? indoor / outdoor?
342369
- test with different processors
370+
- isHeated() bugs if begin() is not called before...
343371

344372
#### Could
345373

examples/AGS02MA_PPB/AGS02MA_PPB.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ void setup()
1818
delay(1000);
1919

2020
Serial.begin(115200);
21+
Serial.println();
2122
Serial.println(__FILE__);
2223
Serial.print("AGS02MA_LIB_VERSION: ");
2324
Serial.println(AGS02MA_LIB_VERSION);

examples/AGS02MA_PPB_TIMING/AGS02MA_PPB_TIMING.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ void setup()
1818
delay(1000);
1919

2020
Serial.begin(115200);
21+
Serial.println();
2122
Serial.println(__FILE__);
2223
Serial.print("AGS02MA_LIB_VERSION: ");
2324
Serial.println(AGS02MA_LIB_VERSION);

examples/AGS02MA_PPM/AGS02MA_PPM.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ void setup()
1818
delay(1000);
1919

2020
Serial.begin(115200);
21+
Serial.println();
2122
Serial.println(__FILE__);
2223
Serial.print("AGS02MA_LIB_VERSION: ");
2324
Serial.println(AGS02MA_LIB_VERSION);

0 commit comments

Comments
 (0)