You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: libraries/AGS02MA/README.md
+67-28Lines changed: 67 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,22 +4,28 @@
4
4
5
5
# AGS02MA
6
6
7
-
Arduino library for AGS02MA TVOC sensor.
7
+
Arduino library for AGS02MA TVOC sensor.
8
8
9
-
This library is experimental, so please use with care.
10
-
Please note the warning about the I2C speed.
9
+
This library is experimental, so please use with care.
10
+
Note the warning about the I2C speed, the device works at 30 KHz.
11
11
12
12
13
13
## I2C - warning low speed
14
14
15
-
The sensor uses I2C at very low speed < 30KHz. For an Arduino UNO the lowest speed is about 30.4KHz (TWBR = 255) which works sometimes. During tests roughly 1 in 20 reads of the sensor was successful.
16
-
Tests with ESP32, which can go as low as ~5 KHZ are underway and expected to work.
15
+
The sensor uses I2C at very low speed <= 30 KHz.
16
+
For an Arduino UNO the lowest speed possible is about 30.4KHz (TWBR = 255) which works.
17
+
Tests with ESP32 / ESP8266 at 30 KHz look good, tests with lower clock speeds are to be done but expected to work.
18
+
First runs indicate 2 failed reads in > 500 Reads, so less than 1%
19
+
20
+
The library sets the clock speed to 30 KHz (for non AVR) during operation and resets it to 100 KHz after operation.
21
+
This is done to minimize interference with the communication of other devices. The reset clock speed can be changed with **setI2CResetSpeed()** e.g. to 200 or 400 KHz.
17
22
18
-
The library sets the clock speed to 25KHz (for non AVR) during operation and resets it to 100 KHz
19
-
after operation. This is done to minimize interference with the communication with other devices.
20
23
21
24
## Interface
22
25
26
+
27
+
### Constructor
28
+
23
29
-**AGS02MA(uint8_t deviceAddress = 26, TwoWire \*wire = &Wire)** constructor, with default address and default I2C interface.
24
30
-**bool begin(uint8_t sda, uint8_t scl)** begin for ESP32 and ESP8266.
25
31
-**bool begin()** initializer for Arduino UNO a.o.
@@ -28,58 +34,91 @@ after operation. This is done to minimize interference with the communication wi
28
34
29
35
### Timing
30
36
31
-
-**bool isHeated()** returns true if 2 minutes have passed after startup.
32
-
Otherwise the device is not ready.
33
-
-**uint32_t lastRead()** last time the device is read, timestamp in milliseconds since start.
37
+
-**bool isHeated()** returns true if 2 minutes have passed after startup (call of **begin()** ).
38
+
Otherwise the device is not optimal ready.
39
+
According to the datasheet the preheating will improve the quality
40
+
of the measurements.
41
+
-**uint32_t lastRead()** last time the device is read, timestamp is in milliseconds since start.
42
+
Returns 0 if **readPPB()** or **readUGM3()** is not called yet.
43
+
This function allows to implement sort of asynchronous wait.
44
+
One must keep reads ~3 seconds apart according to the datasheet.
-**bool setAddress(const uint8_t deviceAddress)**sets a new addres for the sensor. If function succeeds the address changes immediately and will be persistent over a reboot.
50
+
-**uint8_t getAddress()** returns the set address. Default the function will return 26 or 0x1A.
40
51
-**uint8_t getSensorVersion()** reads sensor version from device.
52
+
If the version cannot be read the function will return 255.
41
53
42
-
The library sets the clock speed to 25KHz (for non AVR) during operation and resets it to 100 KHz
43
-
after operation. This is done to minimize interference with the communication with other devices.
44
-
The following function can change this reset speed.
54
+
The library sets the clock speed to 30 KHz (for non AVR) during operation and resets it to 100 KHz after operation.
55
+
This is done to minimize interference with the communication of other devices.
56
+
The following function can change the I2C reset speed to e.g. 200 or 400 KHz.
45
57
46
58
-**setI2CResetSpeed(uint32_t s)** sets the I2C speed the library need to reset the I2C speed to.
47
-
-**getI2CResetSpeed()** returns the set value above. Default is 100KHz.
59
+
-**getI2CResetSpeed()** returns the set value above. Default is 100 KHz.
48
60
49
61
50
62
### setMode
51
63
64
+
The default mode at startup of the sensor is PPB = parts per billion.
65
+
52
66
-**bool setPPBMode()** sets device in PartPerBillion mode. Returns true on success.
53
67
-**bool setUGM3Mode()** sets device in micro gram per cubic meter mode. Returns true on success.
0 commit comments