2021-01-29 06:31:58 -05:00
|
|
|
|
|
|
|
[![Arduino CI](https://github.com/RobTillaart/I2C_ASDX/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
|
2021-12-19 11:54:58 -05:00
|
|
|
[![Arduino-lint](https://github.com/RobTillaart/I2C_ASDX/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/I2C_ASDX/actions/workflows/arduino-lint.yml)
|
|
|
|
[![JSON check](https://github.com/RobTillaart/I2C_ASDX/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/I2C_ASDX/actions/workflows/jsoncheck.yml)
|
2023-09-22 14:53:43 -04:00
|
|
|
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/I2C_ASDX.svg)](https://github.com/RobTillaart/I2C_ASDX/issues)
|
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/I2C_ASDX/blob/master/LICENSE)
|
|
|
|
[![GitHub release](https://img.shields.io/github/release/RobTillaart/I2C_ASDX.svg?maxAge=3600)](https://github.com/RobTillaart/I2C_ASDX/releases)
|
2023-09-22 14:53:43 -04:00
|
|
|
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/I2C_ASDX.svg)](https://registry.platformio.org/libraries/robtillaart/I2C_ASDX)
|
2021-01-29 06:31:58 -05:00
|
|
|
|
|
|
|
|
|
|
|
# I2C_ASDX
|
|
|
|
|
2021-12-19 11:54:58 -05:00
|
|
|
Arduino library for I2C ASDX pressure sensor.
|
2021-01-29 06:31:58 -05:00
|
|
|
|
2021-06-07 05:49:28 -04:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
## Description
|
|
|
|
|
|
|
|
The ASDX sensor of Honeywell exist in many variations.
|
2021-06-06 13:59:53 -04:00
|
|
|
Check the datasheet of your type for all the details.
|
2021-01-29 06:31:58 -05:00
|
|
|
|
2021-12-19 11:54:58 -05:00
|
|
|
The I2C_ASDX library can read the sensor and give the pressure in millibar,
|
|
|
|
bar or PSI or many other units. See below.
|
2021-01-29 06:31:58 -05:00
|
|
|
|
2023-01-12 13:55:08 -05:00
|
|
|
#### Links
|
|
|
|
|
2021-12-19 11:54:58 -05:00
|
|
|
Related library: https://github.com/RobTillaart/pressure
|
|
|
|
|
|
|
|
|
2023-01-12 13:55:08 -05:00
|
|
|
#### Hardware connection
|
|
|
|
|
|
|
|
Always check datasheet for the exact pins.
|
|
|
|
|
|
|
|
```
|
|
|
|
ASDX ARDUINO
|
|
|
|
+----------+ +----------+
|
|
|
|
| | | |
|
|
|
|
| GND o|--------|o GND |
|
|
|
|
| VCC o|--------|o VCC |
|
|
|
|
| SDA o|--------|o SDA |
|
|
|
|
| SCL o|--------|o SCL |
|
|
|
|
| | | |
|
|
|
|
+----------+ +----------+
|
|
|
|
```
|
|
|
|
|
|
|
|
|
2021-12-19 11:54:58 -05:00
|
|
|
## Interface
|
2021-01-29 06:31:58 -05:00
|
|
|
|
2023-09-22 14:53:43 -04:00
|
|
|
```cpp
|
|
|
|
#include "I2C_ASDX.h"
|
|
|
|
```
|
|
|
|
|
2021-06-07 05:49:28 -04:00
|
|
|
|
2021-06-06 13:59:53 -04:00
|
|
|
#### Constructor
|
|
|
|
|
2021-12-19 11:54:58 -05:00
|
|
|
- **I2C_ASDX(uint8_taddress, uint8_t psi, TwoWire \*wire = &Wire)** Constructor,
|
|
|
|
I2C address and maximum pressure. Optional the wire interface can be defined.
|
|
|
|
- **bool begin(uint8_t sda, uint8_t scl)** I2C parameters for ESP32 a.o.
|
|
|
|
Returns true if address can be found on I2C bus.
|
|
|
|
- **bool begin()** for UNO and other boards supporting Wire.
|
|
|
|
Returns true if address can be found on I2C bus.
|
2021-06-07 05:49:28 -04:00
|
|
|
- **void reset()** resets internal variables, including pressure.
|
2021-06-06 13:59:53 -04:00
|
|
|
- **bool isConnected()** tests if address can be found on I2C bus.
|
2023-01-12 13:55:08 -05:00
|
|
|
- **uint8_t getAddress()** returns I2C address used.
|
|
|
|
Mainly for debug message.
|
2021-06-06 13:59:53 -04:00
|
|
|
|
2021-06-07 05:49:28 -04:00
|
|
|
|
2021-06-06 13:59:53 -04:00
|
|
|
#### Read
|
|
|
|
|
|
|
|
Before any call to **getPressure()** one need to call **read()** unless one wants the last value read.
|
|
|
|
|
2021-12-19 11:54:58 -05:00
|
|
|
- **int read()** actually reads the sensor, checks for errors,
|
|
|
|
calculates the pressure and set the lastRead timestamp.
|
|
|
|
Returns **I2C_ASDX_OK** or an error code.
|
2021-06-06 13:59:53 -04:00
|
|
|
|
|
|
|
|
|
|
|
#### Units
|
|
|
|
|
2023-01-12 13:55:08 -05:00
|
|
|
- **int getPressure()** returns pressure in milliBar.
|
|
|
|
(rounded integer!).
|
|
|
|
Returns 0 after a reset() and no read() done yet.
|
2023-09-22 14:53:43 -04:00
|
|
|
Calling **getPressure()** (Or any of the other pressure functions) multiple times
|
|
|
|
without read() will return the same value again.
|
2023-01-12 13:55:08 -05:00
|
|
|
- **float getMilliBar()** returns pressure in milliBar (float).
|
2021-06-07 05:49:28 -04:00
|
|
|
- **float getBar()** returns pressure in bar.
|
2021-06-06 13:59:53 -04:00
|
|
|
- **float getPSI()** returns pressure in PSI = Pounds per Square Inch.
|
|
|
|
- **float getATM()** returns pressure in Atmosphere.
|
|
|
|
- **float getDynes()** returns pressure in Dynes.
|
|
|
|
- **float getInchHg()** returns pressure in inches mercury.
|
|
|
|
- **float getInchH2O()** returns pressure in inches water.
|
|
|
|
- **float getPascal()** returns pressure in Pascal. Note this is the SI unit.
|
|
|
|
- **float getTORR()** returns pressure in TORR.
|
2021-06-07 05:49:28 -04:00
|
|
|
- **float getCmHg()** returns pressure in centimetre mercury.
|
|
|
|
- **float getCmH2O()** returns pressure in centimetre water.
|
2021-06-06 13:59:53 -04:00
|
|
|
- **float getMSW()** returns pressure in Meters of Sea Water. (under water pressure unit).
|
|
|
|
|
2021-12-19 11:54:58 -05:00
|
|
|
Related library: https://github.com/RobTillaart/pressure
|
|
|
|
|
2021-06-07 05:49:28 -04:00
|
|
|
|
2021-06-06 13:59:53 -04:00
|
|
|
#### State
|
|
|
|
|
2021-06-07 05:49:28 -04:00
|
|
|
- **uint16_t errorCount()** total counter for the number of errors occurred.
|
|
|
|
- **uint32_t lastRead()** time in milliseconds of last successful read of the sensor.
|
2021-06-06 13:59:53 -04:00
|
|
|
- **int state()** last known state of read, also returned by **read()**
|
2021-01-29 06:31:58 -05:00
|
|
|
|
2023-09-22 14:53:43 -04:00
|
|
|
| state | meaning |
|
|
|
|
|:-------------------------|:---------------------|
|
|
|
|
| I2C_ASDX_OK | no error |
|
|
|
|
| I2C_ASDX_INIT | begin() not called |
|
|
|
|
| I2C_ASDX_READ_ERROR | I2C error |
|
|
|
|
| I2C_ASDX_C000_ERROR | sensor error |
|
|
|
|
| I2C_ASDX_CONNECT_ERROR | I2C error |
|
2023-01-12 13:55:08 -05:00
|
|
|
|
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
## Testing
|
|
|
|
|
|
|
|
The library is tested with only 3 different sensors, all of the PG type.
|
2021-06-06 13:59:53 -04:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
Code is prepared but not tested for 15, 5 and 1 PSI too.
|
|
|
|
|
|
|
|
```
|
|
|
|
ID UNIT TYPE DESCRIPTION
|
2021-06-07 05:49:28 -04:00
|
|
|
output is proportional to difference
|
2021-01-29 06:31:58 -05:00
|
|
|
PG PSI Gage * between applied pressure and atmospheric pressure
|
|
|
|
MG mBar Gage * idem
|
|
|
|
BG Bar Gage * idem
|
|
|
|
KG KiloPascal Gage * idem
|
|
|
|
D Differential * between pressure applied to each of the ports.
|
|
|
|
A Absolute * between applied pressure and built-in reference to vacuum.
|
|
|
|
|
|
|
|
|
|
|
|
ADDRESS PRESSURE RANGE TYPE P A T V
|
|
|
|
0x58 100 psi 0..6895 mBar SSCDANN 100PG 5 A 5
|
|
|
|
0x38 60 psi 0..4137 mbar SSCDANN 060PG 3 A 5
|
|
|
|
0x28 30 psi 0..2068 mbar SSCDANN 030PG 2 A 5
|
|
|
|
|
|
|
|
P = pressure range
|
|
|
|
A = I2C address indicator
|
|
|
|
T = accuracy range
|
|
|
|
V = voltage (3 volt also supported, not tested)
|
|
|
|
```
|
|
|
|
|
2021-06-07 05:49:28 -04:00
|
|
|
That said it is expected that the library is modifiable to support many
|
2021-01-29 06:31:58 -05:00
|
|
|
more as long as they have the following raw read values.
|
|
|
|
|
|
|
|
```
|
|
|
|
1638 = 0 PSI
|
|
|
|
14746 = max PSI
|
|
|
|
```
|
|
|
|
|
2021-06-07 05:49:28 -04:00
|
|
|
|
2023-01-12 13:55:08 -05:00
|
|
|
## Tested types
|
|
|
|
|
2023-09-22 14:53:43 -04:00
|
|
|
| Type number | result | notes |
|
|
|
|
|:--------------------|:--------:|:--------|
|
|
|
|
| SSCDANN 100PG 5A5 | OK | type A 10% - 90% only
|
|
|
|
| SSCDANN 060PG 3A5 | OK |
|
|
|
|
| SSCDANN 030PG 2A5 | OK |
|
2021-01-29 06:31:58 -05:00
|
|
|
|
2023-01-12 13:55:08 -05:00
|
|
|
(elaborate test table)
|
2021-01-29 06:31:58 -05:00
|
|
|
|
|
|
|
|
2021-12-19 11:54:58 -05:00
|
|
|
## Operation
|
2021-06-06 13:59:53 -04:00
|
|
|
|
2021-12-19 11:54:58 -05:00
|
|
|
See examples
|
2021-06-06 13:59:53 -04:00
|
|
|
|
|
|
|
|
2021-12-19 11:54:58 -05:00
|
|
|
## Future
|
2021-01-29 06:31:58 -05:00
|
|
|
|
2023-01-12 13:55:08 -05:00
|
|
|
#### Must
|
2023-09-22 14:53:43 -04:00
|
|
|
|
|
|
|
- update documentation.
|
|
|
|
|
2023-01-12 13:55:08 -05:00
|
|
|
|
|
|
|
#### Should
|
2023-09-22 14:53:43 -04:00
|
|
|
|
|
|
|
- add real life examples if possible.
|
2023-01-12 13:55:08 -05:00
|
|
|
- add error/state code for after reset() and before read()
|
|
|
|
- I2C_ASDX_NO_READ or I2C_ASDX_RESET
|
|
|
|
|
2023-09-22 14:53:43 -04:00
|
|
|
|
2023-01-12 13:55:08 -05:00
|
|
|
#### Could
|
2023-09-22 14:53:43 -04:00
|
|
|
|
|
|
|
- remove less common pressure formats from lib (0.4.0 ?)
|
2023-01-12 13:55:08 -05:00
|
|
|
- are covered in pressure lib.
|
2023-09-22 14:53:43 -04:00
|
|
|
- but they do no harm either.
|
2023-01-12 13:55:08 -05:00
|
|
|
- move code from .h to .cpp
|
|
|
|
- **getPressure()** obsolete ?
|
|
|
|
- **getMillibar()** ==> 0.4.0 ??
|
2023-09-22 14:53:43 -04:00
|
|
|
- find a good reference for conversion formula constants.
|
2023-01-12 13:55:08 -05:00
|
|
|
|
|
|
|
|
|
|
|
#### Wont
|
2023-09-22 14:53:43 -04:00
|
|
|
|
|
|
|
|
|
|
|
## Support
|
|
|
|
|
|
|
|
If you appreciate my libraries, you can support the development and maintenance.
|
|
|
|
Improve the quality of the libraries by providing issues and Pull Requests, or
|
|
|
|
donate through PayPal or GitHub sponsors.
|
|
|
|
|
|
|
|
Thank you,
|
2021-01-29 06:31:58 -05:00
|
|
|
|