diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..c44e139
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,6 @@
+[submodule "fw/Libs/--force"]
+ path = fw/Libs/--force
+ url = git@gitlab.com:VelesLabs/stm32libs/sht4x.git
+[submodule "fw/Libs/sht4x"]
+ path = fw/Libs/sht4x
+ url = git@gitlab.com:VelesLabs/stm32libs/sht4x.git
diff --git a/fw/.cproject b/fw/.cproject
index 51ffe1b..33a9011 100644
--- a/fw/.cproject
+++ b/fw/.cproject
@@ -29,6 +29,9 @@
+
@@ -55,6 +58,7 @@
+
@@ -83,6 +87,7 @@
+
@@ -104,21 +109,24 @@
-
-
-
-
-
+
+
+
+
+
-
+
-
+
+
-
-
-
+
+
-
-
-
+
+
-
+
diff --git a/fw/Core/Inc/sht4x.h b/fw/Core/Inc/sht4x.h
deleted file mode 100644
index 36c4351..0000000
--- a/fw/Core/Inc/sht4x.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * sht4x.h
- *
- * Created on: Jun 8, 2021
- * Author: user
- */
-
-#ifndef INC_SHT4X_H_
-#define INC_SHT4X_H_
-
-#include "stdint.h"
-#include "stm32l0xx_ll_i2c.h"
-#include "stm32l0xx_ll_utils.h"
-#include "i2c.h"
-#include "crc8.h"
-
-/*
- * Defines & macros
- */
-
-#define SHT4X_I2C_ADDRESS 0x44
-
-/*
- * Return values
- */
-
-#define SHT4X_OK 0
-#define SHT4X_ERROR -1 // generic error
-#define SHT4X_CRC8_ERROR -2 // checksum failed
-
-/*
- * Data types
- */
-
-typedef enum {
- SHT4X_START_MEAS_HIGH_PRECISION = 0xFD,
- SHT4X_START_MEAS_MEDIUM_PRECISION = 0xF6,
- SHT4X_START_MEAS_LOW_PRECISION = 0xE0,
- SHT4X_READ_SERIAL = 0x89,
- SHT4X_SOFT_RESET = 0x94,
- SHT4X_HEATER_200_mW_1_s = 0x39,
- SHT4X_HEATER_200_mW_01_s = 0x32,
- SHT4X_HEATER_110_mW_1_s = 0x2F,
- SHT4X_HEATER_110_mW_01_s = 0x24,
- SHT4X_HEATER_20_mW_1_s = 0x1E,
- SHT4X_HEATER_20_mW_01_s = 0x15
-} sht4x_cmd_t;
-
-/*
- * Function prototypes
- */
-
-int8_t sht4x_send_cmd(sht4x_cmd_t cmd);
-int8_t sht4x_read_data(uint8_t *buffer, int len);
-int8_t sht4x_measure(int16_t *temperature, uint16_t *relative_humidity);
-
-#endif /* INC_SHT4X_H_ */
diff --git a/fw/Core/Src/main.c b/fw/Core/Src/main.c
index 7732ab1..768820d 100644
--- a/fw/Core/Src/main.c
+++ b/fw/Core/Src/main.c
@@ -168,6 +168,40 @@ void CO2_to_color(uint16_t co2, uint16_t co2_limit_yellow, uint16_t co2_limit_re
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
+/*
+ * Functions for SHT4x lib
+ */
+
+
+int8_t sht4x_i2c_transmit(uint8_t address, uint8_t *buffer, int len)
+{
+ i2c_transmit(address, buffer, len);
+}
+
+int8_t sht4x_i2c_receive(uint8_t address, uint8_t *buffer, int len)
+{
+ i2c_receive(address, buffer, len);
+}
+
+uint8_t sensirion_crc8_calculate(const uint8_t *data, uint16_t count)
+{
+ crc8_calculate(data, count);
+}
+
+int8_t sht4x_disable_interrupts(void)
+{
+ uart_disable_interrupts();
+}
+
+int8_t sht4x_enable_interrupts(void)
+{
+ uart_enable_interrupts();
+}
+
+void delay_ms(int delay_ms)
+{
+ LL_mDelay(delay_ms);
+}
/* USER CODE END 0 */
/**
diff --git a/fw/Core/Src/sht4x.c b/fw/Core/Src/sht4x.c
deleted file mode 100644
index 2d05774..0000000
--- a/fw/Core/Src/sht4x.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * sht4x.c
- *
- * Created on: Jun 8, 2021
- * Author: user
- */
-
-#include "sht4x.h"
-#include "main.h" /* for uart_disable_interrupts() */
-
-int8_t sht4x_send_cmd(sht4x_cmd_t cmd)
-{
- return SHT4X_OK;
-}
-
-int8_t sht4x_read_data(uint8_t *buffer, int len)
-{
- return SHT4X_OK;
-}
-
-int8_t sht4x_measure(int16_t *temperature, uint16_t *relative_humidity)
-{
- uint8_t buffer[32];
- int result;
-
- /* start measurement */
- buffer[0] = SHT4X_START_MEAS_HIGH_PRECISION;
- /* disable interrupts to prevent modbus/i2c conflict */
- uart_disable_interrupts();
- result = i2c_transmit(SHT4X_I2C_ADDRESS<<1, buffer, 1);
- uart_enable_interrupts();
- if (result != I2C_OK) {
- return SHT4X_ERROR;
- }
- LL_mDelay(10); /* 10 ms should be enough */
- /* read out */
- uart_disable_interrupts();
- result = i2c_receive(SHT4X_I2C_ADDRESS<<1, buffer, 6);
- uart_enable_interrupts();
- if (result != I2C_OK) {
- return SHT4X_ERROR;
- }
- /* Convert to T and RH; taken directly from pseudocode in SHT4x datasheet, page 3 */
- uint32_t t_ticks = (buffer[0] << 8) + buffer[1];
- uint8_t t_crc = buffer[2];
- uint32_t rh_ticks = (buffer[3] << 8) + buffer[4];
- uint8_t rh_crc = buffer[5];
- /* check CRC-8 checksum */
- uint8_t crc_correct = crc8_calculate(buffer, 2) == t_crc;
- crc_correct &= crc8_calculate(buffer + 3, 2) == rh_crc;
- if (!crc_correct) {
- return SHT4X_CRC8_ERROR;
- }
- /* copy data to output variables */
- int t_degC = -450 + 10 * 175 * t_ticks / 65535; /* temperature * 10 */
- int rh_pRH = -6 + 125 * rh_ticks / 65535;
- if (rh_pRH > 100) {
- rh_pRH = 100;
- }
- if (rh_pRH < 0) {
- rh_pRH = 0;
- }
- *temperature = t_degC;
- *relative_humidity = rh_pRH;
-
- return SHT4X_OK;
-}
diff --git a/fw/Libs/sht4x b/fw/Libs/sht4x
new file mode 160000
index 0000000..233d4da
--- /dev/null
+++ b/fw/Libs/sht4x
@@ -0,0 +1 @@
+Subproject commit 233d4da9b405062cdaf49ca2927325e90d5bde9e
diff --git a/fw/iaq_wired_sensor Debug.launch b/fw/iaq_wired_sensor Debug.launch
index 191079c..abffb15 100644
--- a/fw/iaq_wired_sensor Debug.launch
+++ b/fw/iaq_wired_sensor Debug.launch
@@ -38,7 +38,7 @@
-
+