|
DUDS
|
Distributed Update of Data from Something
|
Support for the AM2320, a temperature and relative humidity sensor with poorly written English documentation. More...
#include <AM2320.hpp>
Public Member Functions | |
| AM2320 (std::unique_ptr< duds::hardware::interface::I2c > &c) | |
| Only address is 0x5C. More... | |
| std::uint16_t | rawRelHumid () const |
| Ten times precentage. More... | |
| std::int16_t | rawTemp () const |
| Ten times Celsius. More... | |
| duds::data::Quantity | relHumidity () const |
| Returns the unitless relative humidity quantity. More... | |
| void | sample () |
| Reads in the last sample and causes the device to start another sample. More... | |
| duds::data::Quantity | temperature () const |
| Returns the temperature in Kelvin. More... | |
Private Attributes | |
| std::unique_ptr< duds::hardware::interface::I2c > | com |
| The I2C communication interface. More... | |
| duds::hardware::interface::Conversation | read |
| Used to read in sampled data from the device. More... | |
| std::uint16_t | rh |
| Relative humidity. More... | |
| std::int16_t | t |
| Temperature. More... | |
| duds::hardware::interface::Conversation | wake |
| Used to awaken the device; needed initially and after 3 or more seconds of not talking to the device. More... | |
Support for the AM2320, a temperature and relative humidity sensor with poorly written English documentation.
High processor loads on single-core systems prevents this code from successfully reading data from a AM2320. This doesn't happen with other I2C connected instruments on the same system. Not sure how to fix this.
This part occasionally fails during reads. To mitigate the problem, sample() will make multiple read attempts after it sends the wake message.
Definition at line 44 of file AM2320.hpp.
| duds::hardware::devices::instruments::AM2320::AM2320 | ( | std::unique_ptr< duds::hardware::interface::I2c > & | c | ) |
Only address is 0x5C.
Calls sample(); the received data will be either old or invalid.
Definition at line 22 of file AM2320.cpp.
|
inline |
Ten times precentage.
Definition at line 116 of file AM2320.hpp.
|
inline |
Ten times Celsius.
Definition at line 122 of file AM2320.hpp.
| duds::data::Quantity duds::hardware::devices::instruments::AM2320::relHumidity | ( | ) | const |
Returns the unitless relative humidity quantity.
Definition at line 119 of file AM2320.cpp.
| void duds::hardware::devices::instruments::AM2320::sample | ( | ) |
Reads in the last sample and causes the device to start another sample.
About two seconds after this function is done, the new sample will be available for reading by another call to sample(). This function's results are always a sample behind the most current data. Sampling takes two seconds to complete, so calling this function more often is not helpful.
These devices can fail on read for no clear reason. To mitigate the issue, up to three attempst are made at reading in the sample. Each attempt takes a little more than 10ms.
| duds::hardware::interface::I2cError | This occurs too often on parts that should be good. The first two such errors on read attempts are ignored; the next is thrown. |
| DeviceMisidentified | The device's response did not properly echo the command byte and requested data length. This likely means the device is not an AM2320. |
| AM2320CrcError | The data and the CRC received are not consistent with each other. |
Definition at line 42 of file AM2320.cpp.
Referenced by AM2320().
| duds::data::Quantity duds::hardware::devices::instruments::AM2320::temperature | ( | ) | const |
Returns the temperature in Kelvin.
Definition at line 123 of file AM2320.cpp.
|
private |
The I2C communication interface.
Definition at line 48 of file AM2320.hpp.
|
private |
Used to read in sampled data from the device.
Definition at line 57 of file AM2320.hpp.
|
private |
Relative humidity.
Definition at line 61 of file AM2320.hpp.
Referenced by relHumidity(), and sample().
|
private |
|
private |
Used to awaken the device; needed initially and after 3 or more seconds of not talking to the device.
Definition at line 53 of file AM2320.hpp.