LibDriver SGP41
Loading...
Searching...
No Matches
driver_sgp41.c File Reference

driver sgp41 source file More...

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

Go to the source code of this file.

Macros

#define CHIP_NAME   "Sensirion SGP41"
 chip information definition
#define MANUFACTURER_NAME   "Sensirion"
#define SUPPLY_VOLTAGE_MIN   1.70f
#define SUPPLY_VOLTAGE_MAX   3.60f
#define MAX_CURRENT   4.80f
#define TEMPERATURE_MIN   -10.0f
#define TEMPERATURE_MAX   50.0f
#define DRIVER_VERSION   1000
#define SGP41_ADDRESS   (0x59 << 1)
 chip address definition
#define SGP41_COMMAND_EXECUTE_CONDITIONING   0x2612U
 chip command definition
#define SGP41_COMMAND_MEASURE_RAW   0x2619U
#define SGP41_COMMAND_EXECUTE_SELF_TEST   0x280EU
#define SGP41_COMMAND_TURN_HEATER_OFF   0x3615U
#define SGP41_COMMAND_GET_SERIAL_ID   0x3682U
#define SGP41_COMMAND_SOFT_RESET   0x0006U
#define SGP41_CRC8_POLYNOMIAL   0x31
 crc8 definition
#define SGP41_CRC8_INIT   0xFF

Functions

uint8_t sgp41_humidity_convert_to_register (sgp41_handle_t *handle, float rh, uint16_t *reg)
 convert the humidity to the register data
uint8_t sgp41_temperature_convert_to_register (sgp41_handle_t *handle, float temp, uint16_t *reg)
 convert the temperature to the register data
uint8_t sgp41_get_execute_conditioning (sgp41_handle_t *handle, uint16_t *sraw_voc)
 get execute conditioning
uint8_t sgp41_get_measure_raw (sgp41_handle_t *handle, uint16_t raw_humidity, uint16_t raw_temperature, uint16_t *sraw_voc, uint16_t *sraw_nox)
 get the measure raw result
uint8_t sgp41_get_measure_raw_without_compensation (sgp41_handle_t *handle, uint16_t *sraw_voc, uint16_t *sraw_nox)
 get the measure raw result without compensation
uint8_t sgp41_get_measure_test (sgp41_handle_t *handle, uint16_t *result)
 get the chip measure test
uint8_t sgp41_soft_reset (sgp41_handle_t *handle)
 soft reset the chip
uint8_t sgp41_turn_heater_off (sgp41_handle_t *handle)
 turn heater off
uint8_t sgp41_get_serial_id (sgp41_handle_t *handle, uint16_t id[3])
 get the chip serial id
uint8_t sgp41_init (sgp41_handle_t *handle)
 initialize the chip
uint8_t sgp41_deinit (sgp41_handle_t *handle)
 close the chip
uint8_t sgp41_set_reg (sgp41_handle_t *handle, uint16_t reg, uint8_t *buf, uint16_t len)
 set the chip register
uint8_t sgp41_get_reg (sgp41_handle_t *handle, uint16_t reg, uint8_t *buf, uint16_t len)
 get the chip register
uint8_t sgp41_info (sgp41_info_t *info)
 get chip information

Detailed Description

driver sgp41 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
1.0.0
Author
Shifeng Li
Date
2023-08-30

history

Date Version Author Description
2023/08/30 1.0 Shifeng Li first upload

Definition in file driver_sgp41.c.

Macro Definition Documentation

◆ CHIP_NAME

#define CHIP_NAME   "Sensirion SGP41"

chip information definition

chip name

Definition at line 42 of file driver_sgp41.c.

◆ DRIVER_VERSION

#define DRIVER_VERSION   1000

driver version

Definition at line 49 of file driver_sgp41.c.

◆ MANUFACTURER_NAME

#define MANUFACTURER_NAME   "Sensirion"

manufacturer name

Definition at line 43 of file driver_sgp41.c.

◆ MAX_CURRENT

#define MAX_CURRENT   4.80f

chip max current

Definition at line 46 of file driver_sgp41.c.

◆ SGP41_ADDRESS

#define SGP41_ADDRESS   (0x59 << 1)

chip address definition

chip iic address

Definition at line 54 of file driver_sgp41.c.

◆ SGP41_COMMAND_EXECUTE_CONDITIONING

#define SGP41_COMMAND_EXECUTE_CONDITIONING   0x2612U

chip command definition

execute conditioning command

Definition at line 59 of file driver_sgp41.c.

◆ SGP41_COMMAND_EXECUTE_SELF_TEST

#define SGP41_COMMAND_EXECUTE_SELF_TEST   0x280EU

execute self test command

Definition at line 61 of file driver_sgp41.c.

◆ SGP41_COMMAND_GET_SERIAL_ID

#define SGP41_COMMAND_GET_SERIAL_ID   0x3682U

get serial id command

Definition at line 63 of file driver_sgp41.c.

◆ SGP41_COMMAND_MEASURE_RAW

#define SGP41_COMMAND_MEASURE_RAW   0x2619U

measure raw command

Definition at line 60 of file driver_sgp41.c.

◆ SGP41_COMMAND_SOFT_RESET

#define SGP41_COMMAND_SOFT_RESET   0x0006U

soft reset command

Definition at line 64 of file driver_sgp41.c.

◆ SGP41_COMMAND_TURN_HEATER_OFF

#define SGP41_COMMAND_TURN_HEATER_OFF   0x3615U

turn heater off command

Definition at line 62 of file driver_sgp41.c.

◆ SGP41_CRC8_INIT

#define SGP41_CRC8_INIT   0xFF

Definition at line 70 of file driver_sgp41.c.

◆ SGP41_CRC8_POLYNOMIAL

#define SGP41_CRC8_POLYNOMIAL   0x31

crc8 definition

Definition at line 69 of file driver_sgp41.c.

◆ SUPPLY_VOLTAGE_MAX

#define SUPPLY_VOLTAGE_MAX   3.60f

chip max supply voltage

Definition at line 45 of file driver_sgp41.c.

◆ SUPPLY_VOLTAGE_MIN

#define SUPPLY_VOLTAGE_MIN   1.70f

chip min supply voltage

Definition at line 44 of file driver_sgp41.c.

◆ TEMPERATURE_MAX

#define TEMPERATURE_MAX   50.0f

chip max operating temperature

Definition at line 48 of file driver_sgp41.c.

◆ TEMPERATURE_MIN

#define TEMPERATURE_MIN   -10.0f

chip min operating temperature

Definition at line 47 of file driver_sgp41.c.