0.2.1 AM2315

This commit is contained in:
Rob Tillaart 2024-01-26 13:42:07 +01:00
parent aa8b2bed0f
commit 308a710427
12 changed files with 58 additions and 32 deletions

View File

@ -1,7 +1,7 @@
// //
// FILE: AM2315.cpp // FILE: AM2315.cpp
// AUTHOR: Rob Tillaart // AUTHOR: Rob Tillaart
// VERSION: 0.2.0 // VERSION: 0.2.1
// PURPOSE: AM2315 Temperature and Humidity sensor library for Arduino // PURPOSE: AM2315 Temperature and Humidity sensor library for Arduino
// URL: https://github.com/RobTillaart/AM2315 // URL: https://github.com/RobTillaart/AM2315

View File

@ -3,7 +3,7 @@
// FILE: AM2315.h // FILE: AM2315.h
// AUTHOR: Rob Tillaart // AUTHOR: Rob Tillaart
// PURPOSE: AM2315 Temperature and Humidity sensor library for Arduino // PURPOSE: AM2315 Temperature and Humidity sensor library for Arduino
// VERSION: 0.2.0 // VERSION: 0.2.1
// URL: https://github.com/RobTillaart/AM2315 // URL: https://github.com/RobTillaart/AM2315
// //
// AM232X PIN layout AM2315 COLOR // AM232X PIN layout AM2315 COLOR
@ -23,7 +23,7 @@
#include "Wire.h" #include "Wire.h"
#define AM2315_LIB_VERSION (F("0.2.0")) #define AM2315_LIB_VERSION (F("0.2.1"))
#define AM2315_OK 0 #define AM2315_OK 0

View File

@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/). and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.2.1] - 2024-01-26
- update readme.md
- update examples
## [0.2.0] - 2023-10-13 ## [0.2.0] - 2023-10-13
- simplified **begin()** no more Wire pin setting. - simplified **begin()** no more Wire pin setting.
- update examples. - update examples.

View File

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2022-2023 Rob Tillaart Copyright (c) 2022-2024 Rob Tillaart
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -26,6 +26,16 @@ See multiplexing below.
The AM2315 can also be read with the https://github.com/RobTillaart/AM232X library as it uses the same protocol. The AM2315 can also be read with the https://github.com/RobTillaart/AM232X library as it uses the same protocol.
The AM232X library allows to read some internal registers. The AM232X library allows to read some internal registers.
#### 0.2.0 Breaking change
Version 0.2.0 introduced a breaking change.
You cannot set the pins in **begin()** any more.
This reduces the dependency of processor dependent Wire implementations.
The user has to call **Wire.begin()** and can optionally set the Wire pins
before calling **begin()**.
#### AM2315C #### AM2315C
The AM2315C ( note the C ) is a different sensor with a different protocol. The AM2315C ( note the C ) is a different sensor with a different protocol.
@ -58,6 +68,38 @@ The C-version has a fixed address of **0x38** so easy to detect.
// do not forget pull up resistors between SDA, SCL and VDD. // do not forget pull up resistors between SDA, SCL and VDD.
``` ```
## I2C
The AM2315 has a fixed address **0x5C** (92).
#### Multiplexing
Multiplexing the **AM2315** can be done in several ways.
This is not a complete list or tutorial but should get you started.
1. Control the power line by means of an extra pin (+ transistor).
Only switch on the sensor you want to use. Drawback might be time
the sensor takes to boot and to be ready for the first measurement.
2. Use an AND gate between the I2C SCL (clock) line and the I2C SCL
pin of the sensors. This way one can enable / disable communication
per sensor. This will still need an IO pin per sensor but does not
have the "boot time" constraint mentioned above.
You may use a **PCF8574** to control the AND gates.
https://github.com/RobTillaart/PCF8574
3. Use a **TCA9548A** I2C Multiplexer, or similar.
- https://github.com/RobTillaart/TCA9548
Drawback of using a multiplexer is that it takes more administration in
your code e.g. which device is on which channel.
This will slow down the access, which must be taken into account when
deciding which devices are on which channel.
Also note that switching between channels will slow down other devices
too if they are behind the multiplexer.
Which method fit your application depends on your requirements and constraints.
#### I2C clock speed #### I2C clock speed
@ -97,6 +139,7 @@ If performance is mandatory do not go beyond 170 KHz.
- **AM2315(TwoWire \*wire = &Wire)** constructor, default using Wire (I2C bus), optionally set to Wire0 .. WireN. - **AM2315(TwoWire \*wire = &Wire)** constructor, default using Wire (I2C bus), optionally set to Wire0 .. WireN.
- **bool begin()** initializer. - **bool begin()** initializer.
Returns true if device address 0x5C is connected. Returns true if device address 0x5C is connected.
Note the user has to call Wire.begin() before **AM.begin()**.
- **bool isConnected(uint16_t timeout = 3000)** returns true if the device address 0x5C is found on I2C bus. - **bool isConnected(uint16_t timeout = 3000)** returns true if the device address 0x5C 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. 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. minimum = 800 us and maximum = 3000 us according to datasheet.
@ -170,25 +213,6 @@ Note that the AM2315 can go into sleep mode after 3 seconds after last read,
so one might need to call **wakeUp()** before the **read()**. so one might need to call **wakeUp()** before the **read()**.
## Multiplexing
Multiplexing the **AM2315** can be done in several ways.
This is not a complete list or tutorial but should get you started.
1. Control the power line by means of an extra pin (+ transistor).
Only switch on the sensor you want to use. Drawback might be time
the sensor takes to boot and to be ready for the first measurement.
2. Use an AND gate between the I2C SCL (clock) line and the I2C SCL
pin of the sensors. This way one can enable / disable communication
per sensor. This will still need an IO pin per sensor but does not
have the "boot time" constraint mentioned above.
You may use a **PCF8574** to control the AND gates.
https://github.com/RobTillaart/PCF8574
3. Use a **TCA9548A** I2C Multiplexer, or similar. https://github.com/RobTillaart/TCA9548
Which method fit your application depends on your requirements and constraints.
## Future ## Future
#### Must #### Must

View File

@ -3,10 +3,10 @@
// AUTHOR: Rob Tillaart // AUTHOR: Rob Tillaart
// PURPOSE: Demo for AM2315 I2C humidity & temperature sensor // PURPOSE: Demo for AM2315 I2C humidity & temperature sensor
// Wire1 on ESP32 (et al) // Wire1 on ESP32 (et al)
// URL: https://github.com/RobTillaart/AM2315
#include "AM2315.h" #include "AM2315.h"
#include "Wire.h"
AM2315 sensor(&Wire1); AM2315 sensor(&Wire1);

View File

@ -2,10 +2,10 @@
// FILE: AM2315_offset.ino // FILE: AM2315_offset.ino
// AUTHOR: Rob Tillaart // AUTHOR: Rob Tillaart
// PURPOSE: Demo for AM2315 I2C humidity & temperature sensor // PURPOSE: Demo for AM2315 I2C humidity & temperature sensor
// URL: https://github.com/RobTillaart/AM2315
#include "AM2315.h" #include "AM2315.h"
#include "Wire.h"
AM2315 sensor(&Wire); AM2315 sensor(&Wire);

View File

@ -2,11 +2,10 @@
// FILE: AM2315_performance.ino // FILE: AM2315_performance.ino
// AUTHOR: Rob Tillaart // AUTHOR: Rob Tillaart
// PURPOSE: Demo for AM2315 I2C humidity & temperature sensor // PURPOSE: Demo for AM2315 I2C humidity & temperature sensor
// // URL: https://github.com/RobTillaart/AM2315
#include "AM2315.h" #include "AM2315.h"
#include "Wire.h"
AM2315 sensor; AM2315 sensor;

View File

@ -2,11 +2,10 @@
// FILE: AM2315_test.ino // FILE: AM2315_test.ino
// AUTHOR: Rob Tillaart // AUTHOR: Rob Tillaart
// PURPOSE: Demo for AM2315 I2C humidity & temperature sensor // PURPOSE: Demo for AM2315 I2C humidity & temperature sensor
// // URL: https://github.com/RobTillaart/AM2315
#include "AM2315.h" #include "AM2315.h"
#include "Wire.h"
AM2315 sensor(&Wire); AM2315 sensor(&Wire);

View File

@ -15,7 +15,7 @@
"type": "git", "type": "git",
"url": "https://github.com/RobTillaart/AM2315.git" "url": "https://github.com/RobTillaart/AM2315.git"
}, },
"version": "0.2.0", "version": "0.2.1",
"license": "MIT", "license": "MIT",
"frameworks": "*", "frameworks": "*",
"platforms": "*", "platforms": "*",

View File

@ -1,5 +1,5 @@
name=AM2315 name=AM2315
version=0.2.0 version=0.2.1
author=Rob Tillaart <rob.tillaart@gmail.com> author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com> maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for I2C AM2315 temperature and humidity sensor. sentence=Arduino library for I2C AM2315 temperature and humidity sensor.

View File

@ -25,7 +25,6 @@
#include <ArduinoUnitTests.h> #include <ArduinoUnitTests.h>
#include "Wire.h"
#include "AM2315.h" #include "AM2315.h"