Skip to content

Commit 04e0a0f

Browse files
authored
add Wire1 support ESP32 (#24)
- add Wire1 support for ESP32 - update readme.md - minor edits
1 parent 66db30b commit 04e0a0f

File tree

7 files changed

+40
-19
lines changed

7 files changed

+40
-19
lines changed

AGS02MA.cpp

Lines changed: 10 additions & 11 deletions
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.3.3
5+
// VERSION: 0.3.4
66
// PURPOSE: Arduino library for AGS02MA TVOC sensor
77
// URL: https://github.com/RobTillaart/AGS02MA
88

@@ -29,8 +29,7 @@ AGS02MA::AGS02MA(const uint8_t deviceAddress, TwoWire *wire)
2929
#if defined (ESP8266) || defined(ESP32)
3030
bool AGS02MA::begin(uint8_t dataPin, uint8_t clockPin)
3131
{
32-
_startTime = millis(); // PREHEAT
33-
_wire = &Wire;
32+
_startTime = millis(); // PREHEAT
3433
if ((dataPin < 255) && (clockPin < 255))
3534
{
3635
_wire->begin(dataPin, clockPin);
@@ -54,8 +53,8 @@ bool AGS02MA::isConnected()
5453
{
5554
#if defined (__AVR__)
5655
// TWBR = 255; // == 30.4 KHz with TWSR = 0x00
57-
TWBR = 78; // == 25.0 KHZ
58-
TWSR = 0x01; // prescaler = 4
56+
TWBR = 78; // == 25.0 KHZ
57+
TWSR = 0x01; // pre-scaler = 4
5958
#else
6059
_wire->setClock(AGS02MA_I2C_CLOCK);
6160
#endif
@@ -303,8 +302,8 @@ bool AGS02MA::_readRegister(uint8_t reg)
303302

304303
#if defined (__AVR__)
305304
// TWBR = 255; // == 30.4 KHz with TWSR = 0x00
306-
TWBR = 78; // == 25.0 KHZ
307-
TWSR = 0x01; // prescaler = 4
305+
TWBR = 78; // == 25.0 KHZ
306+
TWSR = 0x01; // pre-scaler = 4
308307
#else
309308
_wire->setClock(AGS02MA_I2C_CLOCK);
310309
#endif
@@ -320,7 +319,7 @@ bool AGS02MA::_readRegister(uint8_t reg)
320319
{
321320
_error = AGS02MA_ERROR_READ;
322321
#if defined (__AVR__)
323-
TWSR = 0x00; // reset prescaler = 1
322+
TWSR = 0x00; // reset pre-scaler = 1
324323
#endif
325324
_wire->setClock(_I2CResetSpeed);
326325
return false;
@@ -330,7 +329,7 @@ bool AGS02MA::_readRegister(uint8_t reg)
330329
_buffer[i] = _wire->read();
331330
}
332331
#if defined (__AVR__)
333-
TWSR = 0x00; // reset prescaler = 1
332+
TWSR = 0x00; // reset pre-scaler = 1
334333
#endif
335334
_wire->setClock(_I2CResetSpeed);
336335
return true;
@@ -344,8 +343,8 @@ bool AGS02MA::_writeRegister(uint8_t reg)
344343

345344
#if defined (__AVR__)
346345
// TWBR = 255; // == 30.4 KHz with TWSR = 0x00
347-
TWBR = 78; // == 25.0 KHZ
348-
TWSR = 0x01; // prescaler = 4
346+
TWBR = 78; // == 25.0 KHZ
347+
TWSR = 0x01; // pre-scaler = 4
349348
#else
350349
_wire->setClock(AGS02MA_I2C_CLOCK);
351350
#endif

AGS02MA.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// FILE: AGS02MA.h
44
// AUTHOR: Rob Tillaart, Viktor Balint, Beanow
55
// DATE: 2021-08-12
6-
// VERSION: 0.3.3
6+
// VERSION: 0.3.4
77
// PURPOSE: Arduino library for AGS02MA TVOC sensor
88
// URL: https://github.com/RobTillaart/AGS02MA
99
//
@@ -13,7 +13,7 @@
1313
#include "Wire.h"
1414

1515

16-
#define AGS02MA_LIB_VERSION (F("0.3.3"))
16+
#define AGS02MA_LIB_VERSION (F("0.3.4"))
1717

1818
#define AGS02MA_OK 0
1919
#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+
## [0.3.4] - 2023-09-25
10+
- add Wire1 support for ESP32
11+
- update readme.md
12+
- minor edits
13+
14+
915
## [0.3.3] - 2023-01-21
1016
- update GitHub actions
1117
- update license 2023
@@ -14,7 +20,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1420
- minor edit code
1521
- add CHANGELOG.md (for real)
1622

17-
1823
## [0.3.2] - 2022-10-26
1924
- add CHANGELOG.md
2025
- add RP2040 in build

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
[![Arduino CI](https://github.com/RobTillaart/AGS02MA/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
33
[![Arduino-lint](https://github.com/RobTillaart/AGS02MA/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/AGS02MA/actions/workflows/arduino-lint.yml)
44
[![JSON check](https://github.com/RobTillaart/AGS02MA/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/AGS02MA/actions/workflows/jsoncheck.yml)
5+
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/AGS02MA.svg)](https://github.com/RobTillaart/AGS02MA/issues)
6+
57
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/AGS02MA/blob/master/LICENSE)
68
[![GitHub release](https://img.shields.io/github/release/RobTillaart/AGS02MA.svg?maxAge=3600)](https://github.com/RobTillaart/AGS02MA/releases)
9+
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/AGS02MA.svg)](https://registry.platformio.org/libraries/robtillaart/AGS02MA)
710

811

912
# AGS02MA
@@ -94,6 +97,10 @@ with the sensor and this (or other) library.
9497

9598
## Interface
9699

100+
```cpp
101+
#include "AGS02MA.h"
102+
```
103+
97104

98105
#### Constructor
99106

@@ -269,11 +276,11 @@ Read datasheet or table below for details. A new read is needed to update this.
269276

270277
#### Must
271278

279+
- improve documentation
280+
- add indicative table for PPB health zone (source)
272281

273282
#### Should
274283

275-
- improve documentation
276-
- add indicative table for PPB health zone (source)
277284
- put the I2C speed code in 2 inline functions
278285
- less repeating conditional code places
279286
- setLowSpeed() + setNormalSpeed()
@@ -292,3 +299,12 @@ Read datasheet or table below for details. A new read is needed to update this.
292299

293300
#### Wont
294301

302+
303+
## Support
304+
305+
If you appreciate my libraries, you can support the development and maintenance.
306+
Improve the quality of the libraries by providing issues and Pull Requests, or
307+
donate through PayPal or GitHub sponsors.
308+
309+
Thank you,
310+

keywords.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ dataReady KEYWORD2
4747

4848
readRegister KEYWORD2
4949

50+
5051
# Constants ( LITERAL1)
5152
AGS02MA_LIB_VERSION LITERAL1
5253

library.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
"type": "git",
2222
"url": "https://github.com/RobTillaart/AGS02MA.git"
2323
},
24-
"version": "0.3.3",
24+
"version": "0.3.4",
2525
"license": "MIT",
26-
"frameworks": "arduino",
26+
"frameworks": "*",
2727
"platforms": "*",
2828
"headers": "AGS02MA.h"
2929
}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=AGS02MA
2-
version=0.3.3
2+
version=0.3.4
33
author=Rob Tillaart <[email protected]>
44
maintainer=Rob Tillaart <[email protected]>
55
sentence=Arduino library for AGS02MA - TVOC sensor

0 commit comments

Comments
 (0)