L14-Click 1.0
STM32WLE5CC LoRaWAN Sensor Platform
Loading...
Searching...
No Matches
scd41.h File Reference
#include "mysensors_def.h"
#include "stm32wlxx_hal.h"
Include dependency graph for scd41.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  scd41_t
 Measurement data produced by the SCD41 CO2 / temperature / humidity sensor. Populated by scd41_Read(); check IsDataValid before using the values. More...

Functions

int8_t scd41_Is (I2C_HandleTypeDef *hi2c, int8_t tryInit)
 
  • check if CO2 sensor is present

HAL_StatusTypeDef scd41_Init (I2C_HandleTypeDef *hi2c)
 initialization of sensor sdc41
HAL_StatusTypeDef scd41_On (I2C_HandleTypeDef *hi2c)
 start reading - turn on sensor, reading mode can be: SCD41_CMD_START_PERIODIC - every 5s - this is probably most accurate SCD41_CMD_START_LOW_POWER_PERIODIC - every 30s
HAL_StatusTypeDef scd41_Off (I2C_HandleTypeDef *hi2c)
 stop reading
HAL_StatusTypeDef scd41_IsDataReady (I2C_HandleTypeDef *hi2c)
 check if data is available
HAL_StatusTypeDef scd41_Read (I2C_HandleTypeDef *hi2c)
 read value from sensor
void scd41_LogData (char *buf)
 log data to buffer

Variables

scd41_t _scd41Data
 Live measurement data from the SCD41 sensor; updated by scd41_Read().
scd41_t _bck_scd41Data
 Snapshot copy of the last completed measurement; used for LoRaWAN transmission.

Function Documentation

◆ scd41_Init()

HAL_StatusTypeDef scd41_Init ( I2C_HandleTypeDef * hi2c)

initialization of sensor sdc41

Return values
HAL_OK- sensor is present, HAL_ERROR - error

Definition at line 99 of file scd41.c.

References _isScd41, _systemParams, HAL_Delay(), I2C_IsDeviceReadyMT(), SCD41_ADDR, SCD41_CMD_REINIT, SCD41_CMD_SET_ALTITUDE, scd41_Off(), and scd41_WriteWithCRC().

Referenced by scd41_Is().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scd41_Is()

int8_t scd41_Is ( I2C_HandleTypeDef * hi2c,
int8_t tryInit )

  • check if CO2 sensor is present

Parameters
tryInit- in case sensor is not yet initialized, 1 - attempt to initialize again, 0 - no
Return values
1- is present, 0 - is not

Definition at line 70 of file scd41.c.

References _isScd41, and scd41_Init().

Here is the call graph for this function:

◆ scd41_IsDataReady()

HAL_StatusTypeDef scd41_IsDataReady ( I2C_HandleTypeDef * hi2c)

check if data is available

Return values
HAL_OK- data is available, can be read, HAL_BUSY - data not yet available, HAL_ERROR - error

Definition at line 143 of file scd41.c.

References _isScd41, HAL_Delay(), SCD41_ADDR, SCD41_CMD_GET_DATA_READY, and systemParams_CalculateCrc().

Referenced by scd41_Read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scd41_LogData()

void scd41_LogData ( char * buf)

log data to buffer

Definition at line 228 of file scd41.c.

References _scd41Data, PRIf_02, and PRIf_02D.

◆ scd41_Off()

HAL_StatusTypeDef scd41_Off ( I2C_HandleTypeDef * hi2c)

stop reading

Definition at line 94 of file scd41.c.

References SCD41_CMD_STOP_PERIODIC, and scd41_onOff().

Referenced by scd41_Init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scd41_On()

HAL_StatusTypeDef scd41_On ( I2C_HandleTypeDef * hi2c)

start reading - turn on sensor, reading mode can be: SCD41_CMD_START_PERIODIC - every 5s - this is probably most accurate SCD41_CMD_START_LOW_POWER_PERIODIC - every 30s

Definition at line 77 of file scd41.c.

References _isScd41, _memsMainBlock, _scd41Data, mems_WriteMainBlock(), SCD41_CMD_START, and scd41_onOff().

Here is the call graph for this function:

◆ scd41_Read()

HAL_StatusTypeDef scd41_Read ( I2C_HandleTypeDef * hi2c)

read value from sensor

Return values
HAL_OK- have data, HAL_BUSY - data not yet available, HAL_ERROR - error

Definition at line 190 of file scd41.c.

References _scd41Data, HAL_Delay(), SCD41_ADDR, SCD41_CMD_READ_MEAS, scd41_IsDataReady(), and systemParams_CalculateCrc().

Here is the call graph for this function:

Variable Documentation

◆ _bck_scd41Data

scd41_t _bck_scd41Data
extern

Snapshot copy of the last completed measurement; used for LoRaWAN transmission.

Definition at line 40 of file scd41.c.

Referenced by sensors_CayennelFromBckData(), sensors_CopyToBck(), sensors_ReadToBckFromDataBlock(), and sensors_WriteFromBckToDataBlock().

◆ _scd41Data

scd41_t _scd41Data
extern

Live measurement data from the SCD41 sensor; updated by scd41_Read().

Definition at line 39 of file scd41.c.

Referenced by scd41_LogData(), scd41_On(), scd41_Read(), and sensors_CopyToBck().