LibDriver SGP30
Loading...
Searching...
No Matches
driver_sgp30.c File Reference

driver sgp30 source file More...

#include "driver_sgp30.h"
Include dependency graph for driver_sgp30.c:

Go to the source code of this file.

Macros

#define CHIP_NAME   "Sensirion SGP30"
 chip information definition
#define MANUFACTURER_NAME   "Sensirion"
#define SUPPLY_VOLTAGE_MIN   1.62f
#define SUPPLY_VOLTAGE_MAX   1.98f
#define MAX_CURRENT   48.8f
#define TEMPERATURE_MIN   -40.0f
#define TEMPERATURE_MAX   85.0f
#define DRIVER_VERSION   2000
#define SGP30_ADDRESS   (0x58 << 1)
 chip address definition
#define SGP30_COMMAND_IAQ_INIT   0x2003U
 chip command definition
#define SGP30_COMMAND_MEASURE_IAQ   0x2008U
#define SGP30_COMMAND_GET_IAQ_BASELINE   0x2015U
#define SGP30_COMMAND_SET_IAQ_BASELINE   0x201EU
#define SGP30_COMMAND_SET_ABSOLUTE_HUMIDITY   0x2061U
#define SGP30_COMMAND_MEASURE_TEST   0x2032U
#define SGP30_COMMAND_GET_FEATURE_SET   0x202FU
#define SGP30_COMMAND_MEASURE_RAW   0x2050U
#define SGP30_COMMAND_GET_TVOC_INCEPTIVE_BASELINE   0x20B3U
#define SGP30_COMMAND_SET_TVOC_BASELINE   0x2077U
#define SGP30_COMMAND_SOFT_RESET   0x0006U
#define SGP30_COMMAND_GET_SERIAL_ID   0x3682U
#define SGP30_CRC8_POLYNOMIAL   0x31
 crc8 definition
#define SGP30_CRC8_INIT   0xFF

Functions

uint8_t sgp30_set_tvoc_baseline (sgp30_handle_t *handle, uint16_t tvoc_baseline)
 set the chip tvoc baseline
uint8_t sgp30_get_tvoc_inceptive_baseline (sgp30_handle_t *handle, uint16_t *tvoc_baseline)
 get the chip tvoc inceptive baseline
uint8_t sgp30_iaq_init (sgp30_handle_t *handle)
 initialize the chip iaq
uint8_t sgp30_soft_reset (sgp30_handle_t *handle)
 soft reset the chip
uint8_t sgp30_get_serial_id (sgp30_handle_t *handle, uint16_t id[3])
 get the chip serial id
uint8_t sgp30_measure_iaq (sgp30_handle_t *handle, uint16_t *co2_eq_ppm, uint16_t *tvoc_ppb)
 get the iaq measure result
uint8_t sgp30_get_iaq_baseline (sgp30_handle_t *handle, uint16_t *tvoc, uint16_t *co2_eq)
 get the chip iaq baseline
uint8_t sgp30_set_iaq_baseline (sgp30_handle_t *handle, uint16_t tvoc, uint16_t co2_eq)
 set the chip iaq baseline
uint8_t sgp30_set_absolute_humidity (sgp30_handle_t *handle, uint16_t humidity)
 set the chip absolute_humidity
uint8_t sgp30_absolute_humidity_convert_to_register (sgp30_handle_t *handle, float temp, float rh, uint16_t *reg)
 convert the absolute humidity to the register data
uint8_t sgp30_measure_test (sgp30_handle_t *handle, uint16_t *result)
 run the chip measure test
uint8_t sgp30_get_feature_set (sgp30_handle_t *handle, uint8_t *product_type, uint8_t *product_version)
 get the chip feature
uint8_t sgp30_get_measure_raw (sgp30_handle_t *handle, uint16_t *tvoc, uint16_t *co2_eq)
 get the iaq measure raw result
uint8_t sgp30_init (sgp30_handle_t *handle)
 initialize the chip
uint8_t sgp30_deinit (sgp30_handle_t *handle)
 close the chip
uint8_t sgp30_read (sgp30_handle_t *handle, uint16_t *co2_eq_ppm, uint16_t *tvoc_ppb)
 read the iaq measure result
uint8_t sgp30_set_reg (sgp30_handle_t *handle, uint16_t reg, uint8_t *buf, uint16_t len)
 set the chip register
uint8_t sgp30_get_reg (sgp30_handle_t *handle, uint16_t reg, uint8_t *buf, uint16_t len)
 get the chip register
uint8_t sgp30_info (sgp30_info_t *info)
 get chip information

Detailed Description

driver sgp30 source file

Copyright (c) 2015 - present LibDriver All rights reserved

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Version
2.0.0
Author
Shifeng Li
Date
2021-03-07

history

Date Version Author Description
2021/03/07 2.0 Shifeng Li format the code
2020/11/05 1.0 Shifeng Li first upload

Definition in file driver_sgp30.c.

Macro Definition Documentation

◆ CHIP_NAME

#define CHIP_NAME   "Sensirion SGP30"

chip information definition

chip name

Definition at line 43 of file driver_sgp30.c.

◆ DRIVER_VERSION

#define DRIVER_VERSION   2000

driver version

Definition at line 50 of file driver_sgp30.c.

◆ MANUFACTURER_NAME

#define MANUFACTURER_NAME   "Sensirion"

manufacturer name

Definition at line 44 of file driver_sgp30.c.

◆ MAX_CURRENT

#define MAX_CURRENT   48.8f

chip max current

Definition at line 47 of file driver_sgp30.c.

◆ SGP30_ADDRESS

#define SGP30_ADDRESS   (0x58 << 1)

chip address definition

chip iic address

Definition at line 55 of file driver_sgp30.c.

◆ SGP30_COMMAND_GET_FEATURE_SET

#define SGP30_COMMAND_GET_FEATURE_SET   0x202FU

get feature set command

Definition at line 66 of file driver_sgp30.c.

◆ SGP30_COMMAND_GET_IAQ_BASELINE

#define SGP30_COMMAND_GET_IAQ_BASELINE   0x2015U

get iaq baseline command

Definition at line 62 of file driver_sgp30.c.

◆ SGP30_COMMAND_GET_SERIAL_ID

#define SGP30_COMMAND_GET_SERIAL_ID   0x3682U

get serial id command

Definition at line 71 of file driver_sgp30.c.

◆ SGP30_COMMAND_GET_TVOC_INCEPTIVE_BASELINE

#define SGP30_COMMAND_GET_TVOC_INCEPTIVE_BASELINE   0x20B3U

get tvoc inceptive baseline command

Definition at line 68 of file driver_sgp30.c.

◆ SGP30_COMMAND_IAQ_INIT

#define SGP30_COMMAND_IAQ_INIT   0x2003U

chip command definition

iaq init command

Definition at line 60 of file driver_sgp30.c.

◆ SGP30_COMMAND_MEASURE_IAQ

#define SGP30_COMMAND_MEASURE_IAQ   0x2008U

measure iaq command

Definition at line 61 of file driver_sgp30.c.

◆ SGP30_COMMAND_MEASURE_RAW

#define SGP30_COMMAND_MEASURE_RAW   0x2050U

measure raw command

Definition at line 67 of file driver_sgp30.c.

◆ SGP30_COMMAND_MEASURE_TEST

#define SGP30_COMMAND_MEASURE_TEST   0x2032U

measure test command

Definition at line 65 of file driver_sgp30.c.

◆ SGP30_COMMAND_SET_ABSOLUTE_HUMIDITY

#define SGP30_COMMAND_SET_ABSOLUTE_HUMIDITY   0x2061U

set absolute humidity command

Definition at line 64 of file driver_sgp30.c.

◆ SGP30_COMMAND_SET_IAQ_BASELINE

#define SGP30_COMMAND_SET_IAQ_BASELINE   0x201EU

set iaq baseline command

Definition at line 63 of file driver_sgp30.c.

◆ SGP30_COMMAND_SET_TVOC_BASELINE

#define SGP30_COMMAND_SET_TVOC_BASELINE   0x2077U

set tvoc baseline command

Definition at line 69 of file driver_sgp30.c.

◆ SGP30_COMMAND_SOFT_RESET

#define SGP30_COMMAND_SOFT_RESET   0x0006U

soft reset command

Definition at line 70 of file driver_sgp30.c.

◆ SGP30_CRC8_INIT

#define SGP30_CRC8_INIT   0xFF

Definition at line 77 of file driver_sgp30.c.

◆ SGP30_CRC8_POLYNOMIAL

#define SGP30_CRC8_POLYNOMIAL   0x31

crc8 definition

Definition at line 76 of file driver_sgp30.c.

◆ SUPPLY_VOLTAGE_MAX

#define SUPPLY_VOLTAGE_MAX   1.98f

chip max supply voltage

Definition at line 46 of file driver_sgp30.c.

◆ SUPPLY_VOLTAGE_MIN

#define SUPPLY_VOLTAGE_MIN   1.62f

chip min supply voltage

Definition at line 45 of file driver_sgp30.c.

◆ TEMPERATURE_MAX

#define TEMPERATURE_MAX   85.0f

chip max operating temperature

Definition at line 49 of file driver_sgp30.c.

◆ TEMPERATURE_MIN

#define TEMPERATURE_MIN   -40.0f

chip min operating temperature

Definition at line 48 of file driver_sgp30.c.