DUDS
Distributed Update of Data from Something
AM2320.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of the DUDS project. It is subject to the BSD-style
3  * license terms in the LICENSE file found in the top-level directory of this
4  * distribution and at https://github.com/jjackowski/duds/blob/master/LICENSE.
5  * No part of DUDS, including this file, may be copied, modified, propagated,
6  * or distributed except according to the terms contained in the LICENSE file.
7  *
8  * Copyright (C) 2018 Jeff Jackowski
9  */
13 #include <duds/data/Quantity.hpp>
14 
15 namespace duds { namespace hardware { namespace devices { namespace instruments {
16 
20 struct AM2320Error : DeviceError { };
21 
25 struct AM2320CrcError : virtual AM2320Error, virtual duds::general::CrcError { };
26 
44 class AM2320 : boost::noncopyable {
48  std::unique_ptr<duds::hardware::interface::I2c> com;
61  std::uint16_t rh;
65  std::int16_t t;
66 public:
71  AM2320(std::unique_ptr<duds::hardware::interface::I2c> &c);
112  void sample();
116  std::uint16_t rawRelHumid() const {
117  return rh;
118  }
122  std::int16_t rawTemp() const {
123  return t;
124  }
128  duds::data::Quantity relHumidity() const;
132  duds::data::Quantity temperature() const;
133 };
134 
135 } } } }
A container for a value and a unit to better describe the value.
Definition: Quantity.hpp:37
std::int16_t rawTemp() const
Ten times Celsius.
Definition: AM2320.hpp:122
The received CRC value was not consistent with the message data.
Definition: AM2320.hpp:25
std::uint16_t rh
Relative humidity.
Definition: AM2320.hpp:61
Support for the AM2320, a temperature and relative humidity sensor with poorly written English docume...
Definition: AM2320.hpp:44
std::unique_ptr< duds::hardware::interface::I2c > com
The I2C communication interface.
Definition: AM2320.hpp:48
Base class for all AM2320 specific errors.
Definition: AM2320.hpp:20
duds::hardware::interface::Conversation wake
Used to awaken the device; needed initially and after 3 or more seconds of not talking to the device...
Definition: AM2320.hpp:53
Header for Conversarion; includes ConversationVector.hpp and ConversationExternal.hpp.
The base type for errors from devices.
std::uint16_t rawRelHumid() const
Ten times precentage.
Definition: AM2320.hpp:116
duds::hardware::interface::Conversation read
Used to read in sampled data from the device.
Definition: AM2320.hpp:57
An incorrect cyclic redundancy code (CRC) value was found.
Definition: Errors.hpp:105
Represents a two-way conversation with a device.