COSA
An Object-Oriented Platform for Arduino Programming
Si70XX.hh
Go to the documentation of this file.
1 
21 #ifndef COSA_Si70XX_HH
22 #define COSA_Si70XX_HH
23 
24 #include "Cosa/TWI.hh"
25 #include <math.h>
26 
49 class Si70XX : private TWI::Driver {
50 public:
54  Si70XX() : TWI::Driver(0x40) {}
55 
62  bool read_user_register(uint8_t &reg)
63  {
64  return (read(READ_RHT_USER_REG_1, reg));
65  }
66 
73  bool read_electronic_serial_number(uint8_t snr[8]);
74 
81  bool read_firmware_revision(uint8_t &rev);
82 
89  {
90  return (issue(MEASURE_RH_NO_HOLD));
91  }
92 
98  float read_humidity()
99  {
100  uint16_t value;
101  if (!read(value)) (NAN);
102  return (((125.00 * value) / 65536) - 6.00);
103  }
104 
111  {
112  uint16_t value;
113  if (!issue(READ_RH_TEMP)) return (NAN);
114  if (!read(value, false)) return (NAN);
115  return (((175.72 * value) / 65536) - 46.85);
116  }
117 
125  {
126  return (issue(MEASURE_TEMP_NO_HOLD));
127  }
128 
135  {
136  uint16_t value;
137  if (!read(value)) return (NAN);
138  return (((175.72 * value) / 65536) - 46.85);
139  }
140 
141 protected:
145  enum Command {
150  READ_RH_TEMP = 0xE0,
151  RESET = 0xFE,
154  READ_ID_1 = 0xFA0F,
155  READ_ID_2 = 0xFCC8,
156  READ_REV = 0x84B8
157  } __attribute__((packed));
158 
164  bool issue(uint8_t cmd);
165 
173  bool read(uint16_t& value, bool check = true);
174 
182  bool read(uint8_t cmd, uint8_t& value);
183 };
184 
185 #endif
Definition: TWI.hh:51
Measure Relative Humidity, Hold Master Mode.
Definition: Si70XX.hh:146
bool read_electronic_serial_number(uint8_t snr[8])
Definition: Si70XX.cpp:87
Write RH/T User Register 1.
Definition: Si70XX.hh:152
bool issue(uint8_t cmd)
Definition: Si70XX.cpp:35
bool read_firmware_revision(uint8_t &rev)
Definition: Si70XX.cpp:135
float read_humidity()
Definition: Si70XX.hh:98
Reset.
Definition: Si70XX.hh:151
Dito, No Hold Master Mode.
Definition: Si70XX.hh:149
Read RH/T User Register 1.
Definition: Si70XX.hh:153
Read Temperature from RH Measurement.
Definition: Si70XX.hh:150
bool measure_humidity()
Definition: Si70XX.hh:88
bool measure_temperature()
Definition: Si70XX.hh:124
Read Firmware Revision.
Definition: Si70XX.hh:156
bool read_user_register(uint8_t &reg)
Definition: Si70XX.hh:62
Command
Definition: Si70XX.hh:145
float read_humidity_temperature()
Definition: Si70XX.hh:110
Read Electronic ID 1.
Definition: Si70XX.hh:154
Dito, No Hold Master Mode.
Definition: Si70XX.hh:147
float read_temperature()
Definition: Si70XX.hh:134
Driver(uint8_t addr)
Definition: TWI.hh:70
bool read(uint16_t &value, bool check=true)
Definition: Si70XX.cpp:46
Definition: Si70XX.hh:49
Read Electronic ID 2.
Definition: Si70XX.hh:155
Si70XX()
Definition: Si70XX.hh:54
Measure Temperature, Hold Master Mode.
Definition: Si70XX.hh:148