LibDriver SCD30
Loading...
Searching...
No Matches
driver_scd30.c File Reference

driver scd30 source file More...

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

Go to the source code of this file.

Macros

#define CHIP_NAME   "Sensirion SCD30"
 chip information definition
#define MANUFACTURER_NAME   "Sensirion"
#define SUPPLY_VOLTAGE_MIN   3.3f
#define SUPPLY_VOLTAGE_MAX   5.5f
#define MAX_CURRENT   75.0f
#define TEMPERATURE_MIN   -40.0f
#define TEMPERATURE_MAX   70.0f
#define DRIVER_VERSION   1000
#define SCD30_ADDRESS   0xC2
 chip address definition
#define SCD30_IIC_COMMAND_START_PERIODIC_MEASUREMENT   0x0010U
 chip command definition
#define SCD30_IIC_COMMAND_STOP_PERIODIC_MEASUREMENT   0x0104U
#define SCD30_IIC_COMMAND_SET_MEASUREMENT_INTERVAL   0x4600U
#define SCD30_IIC_COMMAND_GET_DATA_READY_STATUS   0x0202U
#define SCD30_IIC_COMMAND_READ_MEASUREMENT   0x0300U
#define SCD30_IIC_COMMAND_AUTO_SELF_CALIBRATION   0x5306U
#define SCD30_IIC_COMMAND_SET_FORCED_RECALIBRATION   0x5204U
#define SCD30_IIC_COMMAND_SET_TEMPERATURE_OFFSET   0x5403U
#define SCD30_IIC_COMMAND_SET_ALTITUDE   0x5102U
#define SCD30_IIC_COMMAND_READ_FIRMWARE_VERSION   0xD100U
#define SCD30_IIC_COMMAND_SOFT_RESET   0xD304U
#define SCD30_UART_ADDRESS_START_PERIODIC_MEASUREMENT   0x0036U
#define SCD30_UART_ADDRESS_STOP_PERIODIC_MEASUREMENT   0x0037U
#define SCD30_UART_ADDRESS_SET_MEASUREMENT_INTERVAL   0x0025U
#define SCD30_UART_ADDRESS_GET_DATA_READY_STATUS   0x0027U
#define SCD30_UART_ADDRESS_READ_MEASUREMENT   0x0028U
#define SCD30_UART_ADDRESS_AUTO_SELF_CALIBRATION   0x003AU
#define SCD30_UART_ADDRESS_SET_FORCED_RECALIBRATION   0x0039U
#define SCD30_UART_ADDRESS_SET_TEMPERATURE_OFFSET   0x003BU
#define SCD30_UART_ADDRESS_SET_ALTITUDE   0x0038U
#define SCD30_UART_ADDRESS_READ_FIRMWARE_VERSION   0x0020U
#define SCD30_UART_ADDRESS_SOFT_RESET   0x0034U

Functions

uint8_t scd30_set_interface (scd30_handle_t *handle, scd30_interface_t interface)
 set the chip interface
uint8_t scd30_get_interface (scd30_handle_t *handle, scd30_interface_t *interface)
 get the chip interface
uint8_t scd30_start_measurement_with_pressure_compensation (scd30_handle_t *handle, uint16_t mbar)
 start the measurement with pressure compensation
uint8_t scd30_start_measurement (scd30_handle_t *handle)
 start the measurement
uint8_t scd30_stop_measurement (scd30_handle_t *handle)
 stop the measurement
uint8_t scd30_set_measurement_interval (scd30_handle_t *handle, uint16_t second)
 set the measurement interval
uint8_t scd30_get_measurement_interval (scd30_handle_t *handle, uint16_t *second)
 get the measurement interval
uint8_t scd30_get_data_ready_status (scd30_handle_t *handle, uint16_t *status)
 get data ready status
uint8_t scd30_set_automatic_self_calibration (scd30_handle_t *handle, scd30_bool_t enable)
 set automatic self calibration
uint8_t scd30_get_automatic_self_calibration (scd30_handle_t *handle, scd30_bool_t *enable)
 get automatic self calibration
uint8_t scd30_set_forced_recalibration (scd30_handle_t *handle, uint16_t co2_ppm)
 set forced recalibration
uint8_t scd30_get_forced_recalibration (scd30_handle_t *handle, uint16_t *co2_ppm)
 get forced recalibration
uint8_t scd30_set_temperature_offset (scd30_handle_t *handle, uint16_t deg)
 set temperature offset
uint8_t scd30_get_temperature_offset (scd30_handle_t *handle, uint16_t *deg)
 get temperature offset
uint8_t scd30_temperature_offset_convert_to_register (scd30_handle_t *handle, float deg, uint16_t *reg)
 convert the temperature offset to the register raw data
uint8_t scd30_temperature_offset_convert_to_data (scd30_handle_t *handle, uint16_t reg, float *deg)
 convert the register raw data to the temperature offset
uint8_t scd30_set_altitude_compensation (scd30_handle_t *handle, uint16_t m)
 set altitude compensation
uint8_t scd30_get_altitude_compensation (scd30_handle_t *handle, uint16_t *m)
 get altitude compensation
uint8_t scd30_get_firmware_version (scd30_handle_t *handle, uint16_t *version)
 get firmware version
uint8_t scd30_soft_reset (scd30_handle_t *handle)
 soft reset
uint8_t scd30_read (scd30_handle_t *handle, scd30_data_t *data)
 read the result
uint8_t scd30_init (scd30_handle_t *handle)
 initialize the chip
uint8_t scd30_deinit (scd30_handle_t *handle)
 close the chip
uint8_t scd30_set_get_reg_uart (scd30_handle_t *handle, uint8_t *input, uint16_t in_len, uint8_t *output, uint16_t out_len)
 set and get the chip register with uart interface
uint8_t scd30_set_reg_iic (scd30_handle_t *handle, uint16_t reg, uint8_t *buf, uint16_t len)
 set the chip register with iic interface
uint8_t scd30_get_reg_iic (scd30_handle_t *handle, uint16_t reg, uint8_t *buf, uint16_t len)
 get the chip register with iic interface
uint8_t scd30_info (scd30_info_t *info)
 get chip information

Detailed Description

driver scd30 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
2024-08-30

history

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

Definition in file driver_scd30.c.

Macro Definition Documentation

◆ CHIP_NAME

#define CHIP_NAME   "Sensirion SCD30"

chip information definition

chip name

Definition at line 42 of file driver_scd30.c.

◆ DRIVER_VERSION

#define DRIVER_VERSION   1000

driver version

Definition at line 49 of file driver_scd30.c.

◆ MANUFACTURER_NAME

#define MANUFACTURER_NAME   "Sensirion"

manufacturer name

Definition at line 43 of file driver_scd30.c.

◆ MAX_CURRENT

#define MAX_CURRENT   75.0f

chip max current

Definition at line 46 of file driver_scd30.c.

◆ SCD30_ADDRESS

#define SCD30_ADDRESS   0xC2

chip address definition

chip iic address

Definition at line 54 of file driver_scd30.c.

◆ SCD30_IIC_COMMAND_AUTO_SELF_CALIBRATION

#define SCD30_IIC_COMMAND_AUTO_SELF_CALIBRATION   0x5306U

auto self calibration

Definition at line 64 of file driver_scd30.c.

◆ SCD30_IIC_COMMAND_GET_DATA_READY_STATUS

#define SCD30_IIC_COMMAND_GET_DATA_READY_STATUS   0x0202U

get data ready status

Definition at line 62 of file driver_scd30.c.

◆ SCD30_IIC_COMMAND_READ_FIRMWARE_VERSION

#define SCD30_IIC_COMMAND_READ_FIRMWARE_VERSION   0xD100U

read firmware version

Definition at line 68 of file driver_scd30.c.

◆ SCD30_IIC_COMMAND_READ_MEASUREMENT

#define SCD30_IIC_COMMAND_READ_MEASUREMENT   0x0300U

read measurement

Definition at line 63 of file driver_scd30.c.

◆ SCD30_IIC_COMMAND_SET_ALTITUDE

#define SCD30_IIC_COMMAND_SET_ALTITUDE   0x5102U

set altitude

Definition at line 67 of file driver_scd30.c.

◆ SCD30_IIC_COMMAND_SET_FORCED_RECALIBRATION

#define SCD30_IIC_COMMAND_SET_FORCED_RECALIBRATION   0x5204U

set forced recalibration

Definition at line 65 of file driver_scd30.c.

◆ SCD30_IIC_COMMAND_SET_MEASUREMENT_INTERVAL

#define SCD30_IIC_COMMAND_SET_MEASUREMENT_INTERVAL   0x4600U

set measurement interval

Definition at line 61 of file driver_scd30.c.

◆ SCD30_IIC_COMMAND_SET_TEMPERATURE_OFFSET

#define SCD30_IIC_COMMAND_SET_TEMPERATURE_OFFSET   0x5403U

set temperature offset

Definition at line 66 of file driver_scd30.c.

◆ SCD30_IIC_COMMAND_SOFT_RESET

#define SCD30_IIC_COMMAND_SOFT_RESET   0xD304U

soft reset

Definition at line 69 of file driver_scd30.c.

◆ SCD30_IIC_COMMAND_START_PERIODIC_MEASUREMENT

#define SCD30_IIC_COMMAND_START_PERIODIC_MEASUREMENT   0x0010U

chip command definition

start periodic measurement

Definition at line 59 of file driver_scd30.c.

◆ SCD30_IIC_COMMAND_STOP_PERIODIC_MEASUREMENT

#define SCD30_IIC_COMMAND_STOP_PERIODIC_MEASUREMENT   0x0104U

stop periodic measurement

Definition at line 60 of file driver_scd30.c.

◆ SCD30_UART_ADDRESS_AUTO_SELF_CALIBRATION

#define SCD30_UART_ADDRESS_AUTO_SELF_CALIBRATION   0x003AU

auto self calibration

Definition at line 75 of file driver_scd30.c.

◆ SCD30_UART_ADDRESS_GET_DATA_READY_STATUS

#define SCD30_UART_ADDRESS_GET_DATA_READY_STATUS   0x0027U

get data ready status

Definition at line 73 of file driver_scd30.c.

◆ SCD30_UART_ADDRESS_READ_FIRMWARE_VERSION

#define SCD30_UART_ADDRESS_READ_FIRMWARE_VERSION   0x0020U

read firmware version

Definition at line 79 of file driver_scd30.c.

◆ SCD30_UART_ADDRESS_READ_MEASUREMENT

#define SCD30_UART_ADDRESS_READ_MEASUREMENT   0x0028U

read measurement

Definition at line 74 of file driver_scd30.c.

◆ SCD30_UART_ADDRESS_SET_ALTITUDE

#define SCD30_UART_ADDRESS_SET_ALTITUDE   0x0038U

set altitude

Definition at line 78 of file driver_scd30.c.

◆ SCD30_UART_ADDRESS_SET_FORCED_RECALIBRATION

#define SCD30_UART_ADDRESS_SET_FORCED_RECALIBRATION   0x0039U

set forced recalibration

Definition at line 76 of file driver_scd30.c.

◆ SCD30_UART_ADDRESS_SET_MEASUREMENT_INTERVAL

#define SCD30_UART_ADDRESS_SET_MEASUREMENT_INTERVAL   0x0025U

set measurement interval

Definition at line 72 of file driver_scd30.c.

◆ SCD30_UART_ADDRESS_SET_TEMPERATURE_OFFSET

#define SCD30_UART_ADDRESS_SET_TEMPERATURE_OFFSET   0x003BU

set temperature offset

Definition at line 77 of file driver_scd30.c.

◆ SCD30_UART_ADDRESS_SOFT_RESET

#define SCD30_UART_ADDRESS_SOFT_RESET   0x0034U

soft reset

Definition at line 80 of file driver_scd30.c.

◆ SCD30_UART_ADDRESS_START_PERIODIC_MEASUREMENT

#define SCD30_UART_ADDRESS_START_PERIODIC_MEASUREMENT   0x0036U

start periodic measurement

Definition at line 70 of file driver_scd30.c.

◆ SCD30_UART_ADDRESS_STOP_PERIODIC_MEASUREMENT

#define SCD30_UART_ADDRESS_STOP_PERIODIC_MEASUREMENT   0x0037U

stop periodic measurement

Definition at line 71 of file driver_scd30.c.

◆ SUPPLY_VOLTAGE_MAX

#define SUPPLY_VOLTAGE_MAX   5.5f

chip max supply voltage

Definition at line 45 of file driver_scd30.c.

◆ SUPPLY_VOLTAGE_MIN

#define SUPPLY_VOLTAGE_MIN   3.3f

chip min supply voltage

Definition at line 44 of file driver_scd30.c.

◆ TEMPERATURE_MAX

#define TEMPERATURE_MAX   70.0f

chip max operating temperature

Definition at line 48 of file driver_scd30.c.

◆ TEMPERATURE_MIN

#define TEMPERATURE_MIN   -40.0f

chip min operating temperature

Definition at line 47 of file driver_scd30.c.