L14-Click 1.0
STM32WLE5CC LoRaWAN Sensor Platform
Loading...
Searching...
No Matches
tmphm_sht45.h
Go to the documentation of this file.
1#ifndef __TEMP_HUMP_23__
2#define __TEMP_HUMP_23__
3
4/*
5 * MT 22.12.2025
6 *
7 * Temp&hum 23 click SHT45.pdf https://download.mikroe.com/documents/datasheets/SHT45-AD1B-R2_datasheet.pdf
8
9 * I could have taken the library directly from https://github.com/MikroElektronika/mikrosdk_click_v2/blob/master/clicks/temphum23/lib_temphum23/src/temphum23.c
10 * but there is a problem that I would need to pull in other modules, which would increase the program size
11 * Therefore going the route of direct reading from I2C
12 *
13 * geminy:
14 * https://gemini.google.com/share/b64c25662edf
15 *
16 * I2C address 0x44, or 0x45
17 *
18 * Sensor does not have option to separately turn on or off measurement, it turns on when reading data and turns off after measurement
19 */
20
21#include "mysensors_def.h"
22
23#ifdef SENSOR_SHT45
24
25#include "stm32wlxx_hal.h"
26
27#pragma pack(1)
28/**
29 * @brief Measurement data produced by the SHT45 temperature and humidity sensor.
30 * Populate by calling tmphm_sht45_Read(); check IsDataValid before using
31 * Temperature or Humidity.
32 */
33typedef struct
34{
35 float Temperature; /**< Temperature in degrees Celsius */
36 float Humidity; /**< Relative humidity in percent (0–100 %) */
37 int8_t IsDataValid; /**< 1 – values are valid; 0 – last read failed or not yet performed */
39#pragma pack()
40/**
41 * @brief Live measurement data from the SHT45 sensor; updated by tmphm_sht45_Read().
42 */
44/**
45 * @brief Snapshot copy of the last completed SHT45 measurement; used for LoRaWAN transmission.
46 */
48
49/**
50 * @brief - check if tempHum sensor is present
51 * @param tryInit - in case sensor is not yet initialized, 1 - attempt to initialize again, 0 - no
52 * @retval 1 - is present, 0 - is not
53 */
54int8_t tmphm_sht45_Is(I2C_HandleTypeDef *hi2c, int8_t tryInit);
55
56/**
57 * @brief get state - sensor does not have on/off state - only for compatibility with others
58 */
59HAL_StatusTypeDef tmphm_sht45_IsOn(I2C_HandleTypeDef *hi2c, uint8_t *onOff);
60
61/**
62 * @brief Zapnutie sensora dummy
63 */
64HAL_StatusTypeDef tmphm_sht45_On(I2C_HandleTypeDef *hi2c);
65
66/**
67 * @brief turn off sensor - dummy
68 */
69HAL_StatusTypeDef tmphm_sht45_Off(I2C_HandleTypeDef *hi2c);
70
71/**
72 * @brief - initialization, check if sensor is present or not. Checks main (0x44) and alternative address (0x45)
73 * If sensor is present, fnc tempHum_Is() returns 1
74 * @retval - HAL_OK - sensor was found, HAL_ERROR - sensor is not present
75 */
76HAL_StatusTypeDef tmphm_sht45_Init(I2C_HandleTypeDef *hi2c);
77
78/**
79 * @brief - read temperature and humidity from sensor, values are in _tempHumData
80 * @return - HAL_OK, HAL_ERROR, HAL_TIMEOUT - if sensor is off
81 */
82HAL_StatusTypeDef tmphm_sht45_Read(I2C_HandleTypeDef *hi2c);
83
84/**
85 * @brief log data to buffer
86 */
87void tmphm_sht45_LogData(char* buf);
88
89#endif
90
91#endif
Measurement data produced by the SHT45 temperature and humidity sensor. Populate by calling tmphm_sht...
Definition tmphm_sht45.h:34
float Temperature
Definition tmphm_sht45.h:35
int8_t IsDataValid
Definition tmphm_sht45.h:37
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 tmphm_sht45.c:47
HAL_StatusTypeDef tmphm_sht45_On(I2C_HandleTypeDef *hi2c)
Zapnutie sensora dummy.
Definition tmphm_sht45.c:57
HAL_StatusTypeDef tmphm_sht45_Init(I2C_HandleTypeDef *hi2c)
initialization, check if sensor is present or not. Checks main (0x44) and alternative address (0x45) ...
Definition tmphm_sht45.c:76
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
tmphm_sht45_t _bck_tmphm_sht45Data
Snapshot copy of the last completed SHT45 measurement; used for LoRaWAN transmission.
Definition tmphm_sht45.c:28
HAL_StatusTypeDef tmphm_sht45_Off(I2C_HandleTypeDef *hi2c)
turn off sensor - dummy
Definition tmphm_sht45.c:70
tmphm_sht45_t _tmphm_sht45Data
Live measurement data from the SHT45 sensor; updated by tmphm_sht45_Read().
Definition tmphm_sht45.c:27
int8_t tmphm_sht45_Is(I2C_HandleTypeDef *hi2c, int8_t tryInit)
check if tempHum sensor is present
Definition tmphm_sht45.c:40