Arduino-TWI
Two-Wire Interface (TWI) library for Arduino
Si70XX Class Reference

#include <Si70XX.h>

Inheritance diagram for Si70XX:
Inheritance graph
Collaboration diagram for Si70XX:
Collaboration graph

Public Member Functions

 Si70XX (TWI &twi)
 
bool read_user_register (uint8_t &reg)
 
bool read_electronic_serial_number (uint8_t snr[8])
 
bool read_firmware_revision (uint8_t &rev)
 
bool measure_humidity ()
 
float read_humidity ()
 
float read_humidity_temperature ()
 
bool measure_temperature ()
 
float read_temperature ()
 

Protected Types

enum  Command {
  MEASURE_RH_HOLD = 0xE5, MEASURE_RH_NO_HOLD = 0xF5, MEASURE_TEMP_HOLD = 0xE3, MEASURE_TEMP_NO_HOLD = 0xF3,
  READ_RH_TEMP = 0xE0, RESET = 0xFE, WRITE_RHT_USER_REG_1 = 0xE6, READ_RHT_USER_REG_1 = 0xE7,
  READ_ID_1 = 0x0FFA, READ_ID_2 = 0xC8FC, READ_REV = 0xB884
}
 

Protected Member Functions

bool issue (uint8_t cmd)
 
bool read (uint16_t &value, bool check=true)
 
bool read (uint8_t cmd, uint8_t &value)
 
bool acquire ()
 
bool release ()
 
int read (void *buf, size_t count)
 
int write (const void *buf, size_t count)
 
int write (iovec_t *vp)
 

Static Protected Member Functions

static uint8_t crc_update (uint8_t crc, uint8_t data)
 

Protected Attributes

TWIm_twi
 
uint8_t m_addr
 

Detailed Description

Device Driver for Silicon Labs, Si70XX I2C Humidity and Temperature Sensor. The device driver does not block on measurements.

Circuit

The GY-21 module with pull-up resistors for TWI signals and 3V3 internal voltage converter.

GY-21
+------------+
(VCC)---------------1-|VIN ( ) |
(VCC)---------------2-|GND |
(A5/SCL)------------3-|SCL |
(A4/SDA)------------4-|SDA |
+------------+

References

  1. http://www.silabs.com/products/sensors/humidity-sensors/Pages/si7013-20-21.aspx
  2. https://www.silabs.com/Support%20Documents/TechnicalDocs/Si7020-A20.pdf, Rev. 1.1 6/15.

Definition at line 51 of file Si70XX.h.

Member Enumeration Documentation

enum Si70XX::Command
protected

I2C Command Table (See tab. 11, pp. 19).

Enumerator
MEASURE_RH_HOLD 

Measure Relative Humidity, Hold Master Mode.

MEASURE_RH_NO_HOLD 

Dito, No Hold Master Mode.

MEASURE_TEMP_HOLD 

Measure Temperature, Hold Master Mode.

MEASURE_TEMP_NO_HOLD 

Dito, No Hold Master Mode.

READ_RH_TEMP 

Read Temperature from RH Measurement.

RESET 

Reset.

WRITE_RHT_USER_REG_1 

Write RH/T User Register 1.

READ_RHT_USER_REG_1 

Read RH/T User Register 1.

READ_ID_1 

Read Electronic ID 1.

READ_ID_2 

Read Electronic ID 2.

READ_REV 

Read Firmware Revision.

Definition at line 201 of file Si70XX.h.

Constructor & Destructor Documentation

Si70XX::Si70XX ( TWI twi)
inline

Create device driver instance.

Definition at line 56 of file Si70XX.h.

Member Function Documentation

bool TWI::Device::acquire ( )
inlineinherited

Start transaction. Return true(1) if successful otherwise false(0).

Returns
bool.

Definition at line 52 of file TWI.h.

static uint8_t Si70XX::crc_update ( uint8_t  crc,
uint8_t  data 
)
inlinestaticprotected

Definition at line 278 of file Si70XX.h.

bool Si70XX::issue ( uint8_t  cmd)
inlineprotected

Issue given command. Return true(1) if successful otherwise false(0).

Parameters
[in]cmdcommand.
Returns
bool.

Definition at line 220 of file Si70XX.h.

bool Si70XX::measure_humidity ( )
inline

Issue a humidity measurement. Call read_humidity() for result of measurement. Return true(1) if successful otherwise false(0).

Returns
bool.

Definition at line 144 of file Si70XX.h.

bool Si70XX::measure_temperature ( )
inline

Issue a temperature measurement. Call read_temperature() for result of measurement. Return true(1) if successful otherwise false(0).

Returns
bool.

Definition at line 180 of file Si70XX.h.

int TWI::Device::read ( void *  buf,
size_t  count 
)
inlineinherited

Read data from device to given buffer.

Parameters
[in]bufbuffer pointer.
[in]countbuffer size in bytes.
Returns
number of bytes read or negative error code.

Definition at line 73 of file TWI.h.

bool Si70XX::read ( uint16_t &  value,
bool  check = true 
)
inlineprotected

Read 16-bit value after issued command. Return true(1) if successful otherwise false(0).

Parameters
[out]valueregister value.
[in]checkcrc value (default true).
Returns
bool.

Definition at line 235 of file Si70XX.h.

bool Si70XX::read ( uint8_t  cmd,
uint8_t &  value 
)
inlineprotected

Read 8-bit register value given command. Return true(1) if successful otherwise false(0).

Parameters
[in]cmdcommand.
[out]valueregister value.
Returns
bool.

Definition at line 266 of file Si70XX.h.

bool Si70XX::read_electronic_serial_number ( uint8_t  snr[8])
inline

Read electronic serial number, Return true(1) if successful otherwise false(0).

Parameters
[out]snrserial number register (64-bits).
Returns
bool.

Definition at line 77 of file Si70XX.h.

bool Si70XX::read_firmware_revision ( uint8_t &  rev)
inline

Read firmware revision, Return true(1) if successful otherwise false(0).

Parameters
[out]revrevision code.
Returns
bool.

Definition at line 128 of file Si70XX.h.

float Si70XX::read_humidity ( )
inline

Read humidity value after issued measurement, Return relativ humidity.

Returns
relative humidity.

Definition at line 154 of file Si70XX.h.

float Si70XX::read_humidity_temperature ( )
inline

Read temperature from humidity measurement, Return temperature in Celcius.

Returns
temperature.

Definition at line 166 of file Si70XX.h.

float Si70XX::read_temperature ( )
inline

Read temperature from issued measurement, Return temperature in Celcius.

Returns
temperature.

Definition at line 190 of file Si70XX.h.

bool Si70XX::read_user_register ( uint8_t &  reg)
inline

Read configuration register, Return true(1) if successful otherwise false(0).

Parameters
[out]regvalue.
Returns
bool.

Definition at line 66 of file Si70XX.h.

bool TWI::Device::release ( )
inlineinherited

Stop transaction. Return true(1) if successful otherwise false(0).

Returns
bool.

Definition at line 62 of file TWI.h.

int TWI::Device::write ( const void *  buf,
size_t  count 
)
inlineinherited

Write data from the given buffer to device.

Parameters
[in]bufbuffer pointer.
[in]countbuffer size in bytes.
Returns
number of bytes written or negative error code.

Definition at line 84 of file TWI.h.

int TWI::Device::write ( iovec_t *  vp)
inlineinherited

Write data to device with from given io vector.

Parameters
[in]vpio vector pointer.
Returns
number of bytes written or negative error code.

Definition at line 94 of file TWI.h.

Member Data Documentation

uint8_t TWI::Device::m_addr
protectedinherited

Device address.

Definition at line 104 of file TWI.h.

TWI& TWI::Device::m_twi
protectedinherited

Two-Wire Interface Manager.

Definition at line 101 of file TWI.h.


The documentation for this class was generated from the following file: