L14-Click 1.0
STM32WLE5CC LoRaWAN Sensor Platform
Loading...
Searching...
No Matches
tmphm_sht45.c File Reference
#include "tmphm_sht45.h"
#include "i2c.h"
#include "utils/mydefs.h"
#include "mymems.h"
#include <stdio.h>
Include dependency graph for tmphm_sht45.c:

Go to the source code of this file.

Functions

static HAL_StatusTypeDef tempHum_onOff (I2C_HandleTypeDef *hi2c, uint8_t onOff)
int8_t tmphm_sht45_Is (I2C_HandleTypeDef *hi2c, int8_t tryInit)
 
  • check if tempHum sensor is present

HAL_StatusTypeDef tmphm_sht45_IsOn (I2C_HandleTypeDef *hi2c, uint8_t *onOff)
 get state - sensor does not have on/off state - only for compatibility with others
HAL_StatusTypeDef tmphm_sht45_On (I2C_HandleTypeDef *hi2c)
 Zapnutie sensora dummy.
HAL_StatusTypeDef tmphm_sht45_Off (I2C_HandleTypeDef *hi2c)
 turn off sensor - dummy
HAL_StatusTypeDef tmphm_sht45_Init (I2C_HandleTypeDef *hi2c)
 
  • initialization, check if sensor is present or not. Checks main (0x44) and alternative address (0x45) If sensor is present, fnc tempHum_Is() returns 1

uint8_t tempHum_CheckCrc (uint8_t *data, uint8_t len, uint8_t checksum)
HAL_StatusTypeDef tmphm_sht45_Read (I2C_HandleTypeDef *hi2c)
 
  • read temperature and humidity from sensor, values are in _tempHumData

void tmphm_sht45_LogData (char *buf)
 log data to buffer

Variables

static uint16_t _tempHumAddr = 0x44
static int8_t _isTempHumSensor = 0
static int8_t _isOnOff = 0
tmphm_sht45_t _tmphm_sht45Data = { }
 Live measurement data from the SHT45 sensor; updated by tmphm_sht45_Read().
tmphm_sht45_t _bck_tmphm_sht45Data = {}
 Snapshot copy of the last completed SHT45 measurement; used for LoRaWAN transmission.

Function Documentation

◆ tempHum_CheckCrc()

uint8_t tempHum_CheckCrc ( uint8_t * data,
uint8_t len,
uint8_t checksum )

Definition at line 94 of file tmphm_sht45.c.

Referenced by tmphm_sht45_Read().

Here is the caller graph for this function:

◆ tempHum_onOff()

HAL_StatusTypeDef tempHum_onOff ( I2C_HandleTypeDef * hi2c,
uint8_t onOff )
static

Definition at line 30 of file tmphm_sht45.c.

References _isOnOff, _isTempHumSensor, _tempHumAddr, and I2C_IsDeviceReadyMT().

Referenced by tmphm_sht45_Off(), and tmphm_sht45_On().

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

◆ tmphm_sht45_Init()

HAL_StatusTypeDef tmphm_sht45_Init ( I2C_HandleTypeDef * hi2c)

  • initialization, check if sensor is present or not. Checks main (0x44) and alternative address (0x45) If sensor is present, fnc tempHum_Is() returns 1

Return values
-HAL_OK - sensor was found, HAL_ERROR - sensor is not present

Definition at line 76 of file tmphm_sht45.c.

References _isTempHumSensor, _tempHumAddr, and I2C_IsDeviceReadyMT().

Referenced by tmphm_sht45_Is().

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

◆ tmphm_sht45_Is()

int8_t tmphm_sht45_Is ( I2C_HandleTypeDef * hi2c,
int8_t tryInit )

  • check if tempHum 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 40 of file tmphm_sht45.c.

References _isTempHumSensor, and tmphm_sht45_Init().

Here is the call graph for this function:

◆ tmphm_sht45_IsOn()

HAL_StatusTypeDef tmphm_sht45_IsOn ( I2C_HandleTypeDef * hi2c,
uint8_t * onOff )

get state - sensor does not have on/off state - only for compatibility with others

Definition at line 47 of file tmphm_sht45.c.

References _isOnOff, and _isTempHumSensor.

◆ tmphm_sht45_LogData()

void tmphm_sht45_LogData ( char * buf)

log data to buffer

Definition at line 166 of file tmphm_sht45.c.

References _tmphm_sht45Data, PRIf_02, and PRIf_02D.

◆ tmphm_sht45_Off()

HAL_StatusTypeDef tmphm_sht45_Off ( I2C_HandleTypeDef * hi2c)

turn off sensor - dummy

Definition at line 70 of file tmphm_sht45.c.

References tempHum_onOff().

Here is the call graph for this function:

◆ tmphm_sht45_On()

HAL_StatusTypeDef tmphm_sht45_On ( I2C_HandleTypeDef * hi2c)

Zapnutie sensora dummy.

Definition at line 57 of file tmphm_sht45.c.

References _memsMainBlock, _tmphm_sht45Data, mems_WriteMainBlock(), and tempHum_onOff().

Here is the call graph for this function:

◆ tmphm_sht45_Read()

HAL_StatusTypeDef tmphm_sht45_Read ( I2C_HandleTypeDef * hi2c)

  • read temperature and humidity from sensor, values are in _tempHumData

Returns
- HAL_OK, HAL_ERROR, HAL_TIMEOUT - if sensor is off

Definition at line 110 of file tmphm_sht45.c.

References _isOnOff, _isTempHumSensor, _tempHumAddr, _tmphm_sht45Data, HAL_Delay(), and tempHum_CheckCrc().

Here is the call graph for this function:

Variable Documentation

◆ _bck_tmphm_sht45Data

tmphm_sht45_t _bck_tmphm_sht45Data = {}

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

Definition at line 28 of file tmphm_sht45.c.

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

◆ _isOnOff

int8_t _isOnOff = 0
static

Definition at line 25 of file tmphm_sht45.c.

◆ _isTempHumSensor

int8_t _isTempHumSensor = 0
static

◆ _tempHumAddr

uint16_t _tempHumAddr = 0x44
static

Definition at line 23 of file tmphm_sht45.c.

Referenced by tempHum_onOff(), tmphm_sht45_Init(), and tmphm_sht45_Read().

◆ _tmphm_sht45Data

tmphm_sht45_t _tmphm_sht45Data = { }

Live measurement data from the SHT45 sensor; updated by tmphm_sht45_Read().

Definition at line 27 of file tmphm_sht45.c.

Referenced by bar_bmp585_Read(), bar_ils22qs_Read(), sensors_CopyToBck(), tmphm_sht45_LogData(), tmphm_sht45_On(), and tmphm_sht45_Read().