0.3.3 AM232X

This commit is contained in:
rob tillaart 2021-10-19 11:51:07 +02:00
parent f23e46f678
commit 357371e67d
12 changed files with 50 additions and 31 deletions

View File

@ -2,6 +2,10 @@ compile:
# Choosing to run compilation tests on 2 different Arduino platforms
platforms:
- uno
- leonardo
- due
- zero
# - due
# - zero
# - leonardo
- m4
- esp32
# - esp8266
# - mega2560

View File

@ -4,11 +4,14 @@ name: Arduino CI
on: [push, pull_request]
jobs:
arduino_ci:
runTest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: Arduino-CI/action@master
# Arduino-CI/action@v0.1.1
# Arduino-CI/action@master
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
- run: |
gem install arduino_ci
arduino_ci.rb

View File

@ -1,7 +1,7 @@
//
// FILE: AM232X.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.3.2
// VERSION: 0.3.3
// PURPOSE: AM232X library for AM2320 for Arduino.
//
// HISTORY:
@ -21,6 +21,7 @@
// 0.3.0 2021-01-12 isConnected() + Wire0..Wire5 support
// 0.3.1 2021-01-28 fix TODO's in code
// 0.3.2 2021-03-30 #13 - timeout to isConnected() + wakeUp() + readme.md
// 0.3.3 2021-10-19 update build-CI
#include "AM232X.h"
@ -259,7 +260,7 @@ int AM232X::_getData(uint8_t length)
case 0x80: return AM232X_ERROR_FUNCTION;
case 0x81: return AM232X_ERROR_ADDRESS;
case 0x82: return AM232X_ERROR_REGISTER;
case 0x83: return AM232X_ERROR_CRC_1; // prev write had a wrong CRC
case 0x83: return AM232X_ERROR_CRC_1; // previous write had a wrong CRC
case 0x84: return AM232X_ERROR_WRITE_DISABLED;
default: return AM232X_ERROR_UNKNOWN;
}

View File

@ -3,7 +3,7 @@
// FILE: AM232X.h
// AUTHOR: Rob Tillaart
// PURPOSE: AM232X library for Arduino
// VERSION: 0.3.2
// VERSION: 0.3.3
// HISTORY: See AM232X.cpp
// URL: https://github.com/RobTillaart/AM232X
//
@ -21,7 +21,7 @@
#include "Wire.h"
#define AM232X_LIB_VERSION (F("0.3.2"))
#define AM232X_LIB_VERSION (F("0.3.3"))

View File

@ -1,11 +1,14 @@
[![Arduino CI](https://github.com/RobTillaart/AM232X/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/AM232X/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/AM232X/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/AM232X/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/AM232X/actions/workflows/jsoncheck.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/AM232X/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/AM232X.svg?maxAge=3600)](https://github.com/RobTillaart/AM232X/releases)
# AM232X
Arduino library for AM2320 AM2321 and AM2322 I2C temperature and humidity sensor
Arduino library for AM2320 AM2321 and AM2322 I2C temperature and humidity sensor.
## Description
@ -19,11 +22,11 @@ See multiplexing below.
Typical parameters
| | range | accuracy | repeatability
|:-------|:------:|:------:|:------:|
| Temperature | -40 - 80 | 0.5°C | ±0.1 |
| Humidity | 0.0 - 99.9 | 3% | ±0.1 |
| Sample time | 2 seconds | | |
| | range | accuracy | repeatability |
|:------------|:----------:|:--------:|:-------------:|
| Temperature | -40 - 80 | 0.5°C | ±0.1 |
| Humidity | 0.0 - 99.9 | 3% | ±0.1 |
| Sample time | 2 seconds | | |
```
@ -39,19 +42,22 @@ Typical parameters
## Interface
### Constructor
- **AM232X(TwoWire \*wire = &Wire)** constructor, optionally set Wire0..WireN.
- **bool begin(uint8_t sda, uint8_t scl)** for ESP32 alike devices, returns true if device is connected
- **bool begin()** for AVR alike devices, returns true if device is connected
- **bool isConnected(uint16_t timeout = 3000)** returns true if device-address is found on I2C bus. As the device can be in sleep modus it will retry for the defined timeout (in micros) with a minimum of 1 try. minimum = 800 us and maximum = 3000 us according to datasheet.
- **bool begin(uint8_t sda, uint8_t scl)** for ESP32 alike devices, returns true if device is connected.
- **bool begin()** for AVR alike devices, returns true if device is connected.
- **bool isConnected(uint16_t timeout = 3000)** returns true if device-address is found on I2C bus.
As the device can be in sleep modus it will retry for the defined timeout (in micros) with a minimum of 1 try.
minimum = 800 us and maximum = 3000 us according to datasheet.
### Base calls
- **int read()** fetches the values from the sensor
- **float getHumidity()** returns the last read humidity
- **float getTemperature()** returns the last read temperature
- **int read()** fetches the values from the sensor.
- **float getHumidity()** returns the last read humidity.
- **float getTemperature()** returns the last read temperature.
### Misc
@ -75,8 +81,7 @@ check datasheet for details.
See examples
In setup() you have to call the **begin()** to initialize
the Wire library and do an initial **read()** to fill the
variables temperature and humidity.
the Wire library and do an initial **read()** to fill the variables temperature and humidity.
To access these values one must use **getTemperature()** and **getHumidity()**.
Note that the sensor can go into sleep mode and one might need to call **wakeUp()**
@ -100,9 +105,10 @@ have the "boot time" constraint mentioned above.
Which method fit your application depends on your requirements and constraints.
## Future
- update documentation
- test more
## Warning

View File

@ -66,4 +66,5 @@ void loop()
delay(2000);
}
// -- END OF FILE --

View File

@ -96,4 +96,5 @@ void loop()
{
}
// -- END OF FILE --

View File

@ -5,7 +5,7 @@
// PURPOSE: demo sketch for AM2322 I2C humidity & temperature sensor
//
// HISTORY:
// 0.1.0 2020-09-01 simple program to dump for plotter.
// 0.1.0 2020-09-01 simple program to dump for plotter.
// 0.1.1 2021-01-28 added begin() ++
//

View File

@ -1,7 +1,7 @@
# Syntax Coloring Map For DHT_I2C
# Syntax Colouring Map For DHT_I2C
# Datatypes (KEYWORD1)
# Data types (KEYWORD1)
AM232X KEYWORD1

View File

@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/AM232X"
},
"version": "0.3.2",
"version": "0.3.3",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*"

View File

@ -1,5 +1,5 @@
name=AM232X
version=0.3.2
version=0.3.3
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for AM2320 AM2321 and AM2323 I2C temperature and humidity sensor.

View File

@ -19,6 +19,7 @@
// assertFalse(actual)
// assertNull(actual)
#include <ArduinoUnitTests.h>
#include "Arduino.h"
@ -33,6 +34,7 @@ unittest_teardown()
{
}
unittest(test_demo)
{
AM232X AM;
@ -44,6 +46,7 @@ unittest(test_demo)
// assertEqual(-10, AM.read());
}
unittest_main()
// --------