Skip to content

Commit 3145d7f

Browse files
committed
0.1.0 I2C_ABP2
1 parent 4c83d2a commit 3145d7f

17 files changed

Lines changed: 808 additions & 0 deletions

File tree

libraries/I2C_ABP2/.arduino-ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
platforms:
2+
rpipico:
3+
board: rp2040:rp2040:rpipico
4+
package: rp2040:rp2040
5+
gcc:
6+
features:
7+
defines:
8+
- ARDUINO_ARCH_RP2040
9+
warnings:
10+
flags:
11+
12+
packages:
13+
rp2040:rp2040:
14+
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
15+
16+
compile:
17+
# Choosing to run compilation tests on 2 different Arduino platforms
18+
platforms:
19+
- uno
20+
# - due
21+
# - zero
22+
# - leonardo
23+
- m4
24+
- esp32
25+
- esp8266
26+
# - mega2560
27+
- rpipico
28+
29+
libraries:
30+
- "printHelpers"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# These are supported funding model platforms
2+
3+
github: RobTillaart
4+
custom: "https://www.paypal.me/robtillaart"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Arduino-lint
2+
3+
on: [push, pull_request]
4+
jobs:
5+
lint:
6+
runs-on: ubuntu-latest
7+
timeout-minutes: 5
8+
steps:
9+
- uses: actions/checkout@v6
10+
- uses: arduino/arduino-lint-action@v2
11+
with:
12+
library-manager: update
13+
compliance: strict
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Arduino CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
runTest:
7+
runs-on: ubuntu-latest
8+
timeout-minutes: 20
9+
steps:
10+
- uses: actions/checkout@v6
11+
- uses: ruby/setup-ruby@v1
12+
with:
13+
ruby-version: 2.6
14+
- run: |
15+
gem install arduino_ci
16+
arduino_ci.rb
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: JSON check
2+
3+
on:
4+
push:
5+
paths:
6+
- '**.json'
7+
pull_request:
8+
paths:
9+
- '**.json'
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 5
15+
steps:
16+
- uses: actions/checkout@v6
17+
- name: json-syntax-check
18+
uses: limitusus/json-syntax-check@v2
19+
with:
20+
pattern: "\\.json$"

libraries/I2C_ABP2/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Change Log I2C_ABP2
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](http://keepachangelog.com/)
6+
and this project adheres to [Semantic Versioning](http://semver.org/).
7+
8+
9+
## [0.1.0] - 2026-05-27
10+
- initial version
11+

libraries/I2C_ABP2/I2C_ABP2.cpp

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
//
2+
// FILE: I2C_ABP2.cpp
3+
// AUTHOR: Rob Tillaart
4+
// VERSION: 0.1.0
5+
// DATE: 2026-05-27
6+
// PURPOSE: Arduino library for the Honeywell I2C ABP2 pressure sensors.
7+
// URL: https://github.com/RobTillaart/I2C_ABP2
8+
// https://github.com/RobTillaart/pressure (conversions)
9+
10+
11+
12+
#include "I2C_ABP2.h"
13+
14+
15+
I2C_ABP2::I2C_ABP2(uint8_t address, TwoWire *wire)
16+
{
17+
_address = address;
18+
_wire = wire;
19+
_error = 0;
20+
_lastRead = 0;
21+
_Bar = 0;
22+
_celsius = 0;
23+
}
24+
25+
26+
bool I2C_ABP2::begin(float minBar, float maxBar)
27+
{
28+
_minBar = minBar;
29+
_maxBar = maxBar;
30+
// reset variables
31+
_error = 0;
32+
_lastRead = 0;
33+
_Bar = 0;
34+
_celsius = 0;
35+
36+
if (! isConnected())
37+
{
38+
return false;
39+
}
40+
return true;
41+
}
42+
43+
44+
bool I2C_ABP2::isConnected()
45+
{
46+
_wire->beginTransmission(_address);
47+
return (_wire->endTransmission() == 0);
48+
}
49+
50+
51+
uint8_t I2C_ABP2::getAddress()
52+
{
53+
return _address;
54+
}
55+
56+
57+
/////////////////////////////////////////////
58+
//
59+
// ASYNC INTERFACE
60+
//
61+
// par 6.8 datasheet
62+
// split into an ASYNC interface
63+
//
64+
int I2C_ABP2::request()
65+
{
66+
uint8_t readCommand[3] = { 0xAA, 0x00, 0x00 };
67+
_wire->beginTransmission(_address);
68+
_wire->write(readCommand, 3);
69+
_error = _wire->endTransmission();
70+
if (_error != 0) return _error;
71+
72+
_error = I2C_ABP2_OK;
73+
return _error;
74+
}
75+
76+
int I2C_ABP2::read()
77+
{
78+
// read data
79+
if (7 != _wire->requestFrom((uint8_t)_address, (uint8_t)7))
80+
{
81+
return I2C_ABP2_REQUEST_ERROR;
82+
}
83+
// get state
84+
_state = _wire->read();
85+
// get pressure
86+
uint32_t rawP = 0;
87+
for (int i = 0; i < 3; i++)
88+
{
89+
rawP <<= 8;
90+
rawP += _wire->read();
91+
}
92+
const float maxCnt = 15099494.0;
93+
const float minCnt = 1677722.0;
94+
_Bar = ((rawP - minCnt) * (_maxBar - _minBar)) / (maxCnt - minCnt) + _minBar;
95+
// get temperature
96+
uint32_t rawT = 0;
97+
for (int i = 0; i < 3; i++)
98+
{
99+
rawT <<= 8;
100+
rawT += _wire->read();
101+
}
102+
_celsius = rawT * (200.0 / 16777215.0) - 50;
103+
_lastRead = millis();
104+
_error = I2C_ABP2_OK;
105+
return _error;
106+
}
107+
108+
109+
/////////////////////////////////////////////
110+
//
111+
// DEBUG
112+
//
113+
int I2C_ABP2::getLastError()
114+
{
115+
int e = _error;
116+
_error = 0;
117+
return e;
118+
}
119+
120+
121+
///////////////////////////////////////////////
122+
//
123+
// PRIVATE
124+
//
125+
126+
127+
// -- END OF FILE --
128+

libraries/I2C_ABP2/I2C_ABP2.h

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#pragma once
2+
//
3+
// FILE: I2C_ABP2.h
4+
// AUTHOR: Rob Tillaart
5+
// VERSION: 0.1.0
6+
// DATE: 2026-05-27
7+
// PURPOSE: Arduino library for the Honeywell I2C ABP2 pressure sensors.
8+
// URL: https://github.com/RobTillaart/I2C_ABP2
9+
// https://github.com/RobTillaart/pressure (conversions)
10+
//
11+
// https://forum.arduino.cc/t/honeywell-abp2-sensor-is-not-responding/1446097
12+
13+
14+
#include "Arduino.h"
15+
#include "Wire.h"
16+
17+
18+
#define I2C_ABP2_LIB_VERSION (F("0.1.0"))
19+
20+
// ERROR CODES
21+
// values <> 0 are errors.
22+
constexpr int I2C_ABP2_OK = 0;
23+
constexpr int I2C_ABP2_NOT_READY = -100;
24+
constexpr int I2C_ABP2_REQUEST_ERROR = -101;
25+
26+
// TODO state fields.
27+
28+
29+
class I2C_ABP2
30+
{
31+
public:
32+
I2C_ABP2(uint8_t address, TwoWire *wire = &Wire);
33+
34+
bool begin(float minBar, float maxBar);
35+
bool isConnected();
36+
uint8_t getAddress();
37+
38+
// async interface
39+
int request();
40+
int read();
41+
// timestamp of last good read
42+
uint32_t lastRead() { return _lastRead; };
43+
44+
// access last good read values.
45+
uint8_t getState() { return _state; };
46+
float getBar() { return _Bar; };
47+
float getMilliBar() { return _Bar * 1e3; };
48+
float getCelsius() { return _celsius; };
49+
50+
// DEBUG
51+
int getLastError();
52+
53+
54+
private:
55+
uint8_t _address;
56+
TwoWire* _wire;
57+
58+
uint32_t _lastRead;
59+
float _minBar = 0;
60+
float _maxBar = 1;
61+
float _Bar;
62+
uint8_t _state;
63+
float _celsius;
64+
65+
int _error;
66+
};
67+
68+
69+
// -- END OF FILE --
70+
71+
72+
73+
74+

libraries/I2C_ABP2/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026-2026 Rob Tillaart
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)