1-Wire and ENS210 driver stack
ENS210.hpp
Go to the documentation of this file.
1 /**
2  * @file ENS210.hpp
3  * @brief Public C++ interface for the ENS210 temperature and humidity sensor driver.
4  *
5  * @par Update history
6  * - 27-October-2023 Dave Nadler Initial version.
7  */
8 
9 #ifndef ENS210_HPP_INCLUDED
10 #define ENS210_HPP_INCLUDED
11 
12 #include <stdint.h>
13 
14 #include "ENS210_Result.hpp"
15 #include "1wire/one_wire_address.h"
16 
17 class ENS210_T {
18  bool initOK = false;
19  uint8_t soldercorrection = 0; // Correction due to soldering (in 1/64K); subtracted from rawTemperature by measure function.
20  uint32_t crc7( uint32_t val ); // calculate ENS210 checksum for a raw temperature or humidity value
21  // *** Following members are specific to the DS28E18 controlling this ENS210 on a 1-Wire bus ***
22  OneWire_ROM_ID_T OneWireAddress; ///< Address of the DS28E18 controlling this ENS210 on the 1-Wire bus.
23  // Append a write to the command sequence under construction
24  // dataStream first byte is starting register, followed by register value(s)
25  void writeRegisters(const uint8_t *dataStream, int len);
26  // Append a read to the command sequence under construction
27  // Return value is the index of the result in the readback command sequence
28  int readRegisters(uint8_t firstRegister, int len);
29 public:
30  uint16_t PART_ID; // looking for 0x0210
31  bool PART_ID_Valid() const { return PART_ID == 0x0210; };
32  uint8_t SYS_STAT; // must be 1 in active state
33  bool SYS_STAT_Valid() const { return SYS_STAT == 1; };
34  uint16_t dieRevision = 0;
35  uint64_t uniqueDeviceID = 0;
36  ENS210_T() : OneWireAddress() {}; // ctor does NOT do device initialization; permits static allocation...
37  bool Init();
38  bool InitOK() const { return initOK; };
39  unsigned long QwikTest(); // returns elapsed mSec
40  ENS210_Result_T Measure();
41 };
42 
43 #endif /* ENS210_HPP_INCLUDED */
Address of a device on a 1-Wire bus.
Measurement result from ENS210.
OneWire_ROM_ID_T type stores a 1-Wire address.
ENS210 measurement-result types and conversion helpers.