EFM32 Happy Gecko Software Documentation  efm32hg-doc-5.1.2
si7021.h File Reference

Detailed Description

Driver for the Si7021 I2C Humidity and Temperature Sensor.

Version
5.1.1

License

Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com

This file is licensed under the Silicon Labs License Agreement. See the file "Silabs_License_Agreement.txt" for details. Before using this software for any purpose, you must agree to the terms of that agreement.

Definition in file si7021.h.

#include <stdlib.h>
#include <stdint.h>
#include "si7021_config.h"

Go to the source code of this file.

Macros

#define SI7021_CMD_MEASURE_RH   0xE5
 
#define SI7021_CMD_MEASURE_RH_NO_HOLD   0xF5
 
#define SI7021_CMD_MEASURE_TEMP   0xE3
 
#define SI7021_CMD_MEASURE_TEMP_NO_HOLD   0xF3
 
#define SI7021_CMD_READ_FW_REV   {0x84, 0xB8}
 
#define SI7021_CMD_READ_HEATER_CTRL   0x11
 
#define SI7021_CMD_READ_ID_BYTE1   {0xFA, 0x0F}
 
#define SI7021_CMD_READ_ID_BYTE2   {0xFC, 0xC9}
 
#define SI7021_CMD_READ_TEMP   0xE0
 
#define SI7021_CMD_READ_USER_REG1   0xE7
 
#define SI7021_CMD_RESET   0xFE
 
#define SI7021_CMD_WRITE_HEATER_CTRL   0x51
 
#define SI7021_CMD_WRITE_USER_REG1   0xE6
 
#define SI7021_CONFIG_DEVICE_ID   0x21
 
#define SI7021_CONFIG_I2C_BUS_ADDRESS   0x40
 
#define SI7021_CONFIG_I2C_DEVICE   (I2C0)
 
#define SI7021_DEVICE_ID   SI7021_CONFIG_DEVICE_ID
 
#define SI7021_ERROR_I2C_TRANSFER_FAILED   0x0002
 
#define SI7021_ERROR_I2C_TRANSFER_NACK   0x0001
 
#define SI7021_ERROR_INVALID_DEVICE_ID   0x0003
 
#define SI7021_ERROR_TIMEOUT   0x0004
 
#define SI7021_I2C_BUS_ADDRESS   SI7021_CONFIG_I2C_BUS_ADDRESS
 
#define SI7021_I2C_DEVICE   SI7021_CONFIG_I2C_DEVICE
 
#define SI7021_OK   0
 

Functions

uint32_t SI7021_cmdRead (uint8_t *cmd, size_t cmdLen, uint8_t *result, size_t resultLen)
 Sends a command and reads the result byte(s) over the I2C bus. More...
 
uint32_t SI7021_cmdWrite (uint8_t *cmd, size_t cmdLen, uint8_t *data, size_t dataLen)
 Sends a command and data to the chip over the I2C bus. More...
 
void SI7021_deInit (void)
 De-initializes the Si7021 chip. Disables the sensor power domain, this also disables other sensors. More...
 
uint32_t SI7021_getFwRev (uint8_t *fwRev)
 Reads the firmware revision of the Si7021 chip. More...
 
uint32_t SI7021_init (void)
 Initializes the Si7021 chip. More...
 
uint32_t SI7021_measure (uint32_t *rhData, int32_t *tData)
 Performs relative humidity and temperature measurements. More...