diff --git a/applications/plugins/unitemp/README.md b/applications/plugins/unitemp/README.md
index 257e8a8ae..2f753faea 100644
--- a/applications/plugins/unitemp/README.md
+++ b/applications/plugins/unitemp/README.md
@@ -1,9 +1,10 @@

# Unitemp - Universal temperature sensor reader
[](https://github.com/quen0n/unitemp-flipperzero/releases/)
+[]()
[](https://github.com/quen0n/unitemp-flipperzero/blob/dev/LICENSE.md)
[Flipper Zero](https://flipperzero.one/) application for reading temperature, humidity and pressure sensors using Onewire, Singlewire, I2C protocols.
## List of supported sensors (supplemented)
-
+
## Installation
Copy the contents of the repository to the `applications/plugins/unitemp` folder and build the project. Flash FZ along with resources. [More...](https://github.com/flipperdevices/flipperzero-firmware/blob/dev/documentation/fbt.md)
diff --git a/applications/plugins/unitemp/Sensors.c b/applications/plugins/unitemp/Sensors.c
index f202794f4..d35e31931 100644
--- a/applications/plugins/unitemp/Sensors.c
+++ b/applications/plugins/unitemp/Sensors.c
@@ -71,21 +71,8 @@ const Interface ONE_WIRE = {
//Перечень интерфейсов подключения
//static const Interface* interfaces[] = {&SINGLE_WIRE, &I2C, &ONE_WIRE};
//Перечень датчиков
-static const SensorType* sensorTypes[] = {
- &DHT11,
- &DHT12_SW,
- &DHT20,
- &DHT21,
- &DHT22,
- &Dallas,
- &AM2320_SW,
- &AM2320_I2C,
- &AHT10,
- &SHT30,
- &GXHT30,
- &LM75,
- &BMP280,
- &BME280};
+static const SensorType* sensorTypes[] =
+ {&DHT11, &DHT12_SW, &DHT21, &DHT22, &AM2320_SW, &AM2320_I2C, &LM75, &BMP280, &BME280, &Dallas};
const SensorType* unitemp_sensors_getTypeFromInt(uint8_t index) {
if(index > SENSOR_TYPES_COUNT) return NULL;
diff --git a/applications/plugins/unitemp/Sensors.h b/applications/plugins/unitemp/Sensors.h
index 0643ffb1f..52e6165f5 100644
--- a/applications/plugins/unitemp/Sensors.h
+++ b/applications/plugins/unitemp/Sensors.h
@@ -321,6 +321,4 @@ const GPIO*
//BMP280, BME280
#include "./sensors/BMx280.h"
#include "./sensors/AM2320.h"
-#include "./sensors/DHT20.h"
-#include "./sensors/SHT30.h"
#endif
diff --git a/applications/plugins/unitemp/application.fam b/applications/plugins/unitemp/application.fam
index 23ad07223..4fc9472cc 100644
--- a/applications/plugins/unitemp/application.fam
+++ b/applications/plugins/unitemp/application.fam
@@ -1,5 +1,5 @@
App(
- appid="Temp_Sensors_Reader",
+ appid="unitemp",
name="Unitemp",
apptype=FlipperAppType.EXTERNAL,
entry_point="unitemp_app",
@@ -16,5 +16,4 @@ App(
fap_icon="icon.png",
fap_icon_assets="assets",
fap_libs=["assets"],
- fap_icon_assets_symbol="unitemp",
)
\ No newline at end of file
diff --git a/applications/plugins/unitemp/interfaces/SingleWireSensor.c b/applications/plugins/unitemp/interfaces/SingleWireSensor.c
index e601e086e..183bfc872 100644
--- a/applications/plugins/unitemp/interfaces/SingleWireSensor.c
+++ b/applications/plugins/unitemp/interfaces/SingleWireSensor.c
@@ -43,7 +43,7 @@ const SensorType DHT12_SW = {
.updater = unitemp_singlewire_update};
const SensorType DHT21 = {
.typename = "DHT21",
- .altname = "DHT21/AM2301",
+ .altname = "DHT21 (AM2301)",
.interface = &SINGLE_WIRE,
.datatype = UT_DATA_TYPE_TEMP_HUM,
.pollingInterval = 1000,
@@ -54,7 +54,7 @@ const SensorType DHT21 = {
.updater = unitemp_singlewire_update};
const SensorType DHT22 = {
.typename = "DHT22",
- .altname = "DHT22/AM2302",
+ .altname = "DHT22 (AM2302)",
.interface = &SINGLE_WIRE,
.datatype = UT_DATA_TYPE_TEMP_HUM,
.pollingInterval = 2000,
diff --git a/applications/plugins/unitemp/sensors/DHT20.c b/applications/plugins/unitemp/sensors/DHT20.c
deleted file mode 100644
index f16e8dfc1..000000000
--- a/applications/plugins/unitemp/sensors/DHT20.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- Unitemp - Universal temperature reader
- Copyright (C) 2022 Victor Nikitchuk (https://github.com/quen0n)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-*/
-#include "DHT20.h"
-#include "../interfaces/I2CSensor.h"
-
-const SensorType DHT20 = {
- .typename = "DHT20",
- .altname = "DHT20/AM2108/AHT20",
- .interface = &I2C,
- .datatype = UT_TEMPERATURE | UT_HUMIDITY,
- .pollingInterval = 1000,
- .allocator = unitemp_DHT20_I2C_alloc,
- .mem_releaser = unitemp_DHT20_I2C_free,
- .initializer = unitemp_DHT20_init,
- .deinitializer = unitemp_DHT20_I2C_deinit,
- .updater = unitemp_DHT20_I2C_update};
-const SensorType AHT10 = {
- .typename = "AHT10",
- .interface = &I2C,
- .datatype = UT_TEMPERATURE | UT_HUMIDITY,
- .pollingInterval = 1000,
- .allocator = unitemp_DHT20_I2C_alloc,
- .mem_releaser = unitemp_DHT20_I2C_free,
- .initializer = unitemp_DHT20_init,
- .deinitializer = unitemp_DHT20_I2C_deinit,
- .updater = unitemp_DHT20_I2C_update};
-
-static uint8_t DHT20_get_status(I2CSensor* i2c_sensor) {
- uint8_t status[1] = {0};
- unitemp_i2c_readArray(i2c_sensor, 1, status);
- return status[0];
-}
-
-static uint8_t DHT20_calc_CRC8(uint8_t* message, uint8_t Num) {
- uint8_t i;
- uint8_t byte;
- uint8_t crc = 0xFF;
- for(byte = 0; byte < Num; byte++) {
- crc ^= (message[byte]);
- for(i = 8; i > 0; --i) {
- if(crc & 0x80)
- crc = (crc << 1) ^ 0x31;
- else
- crc = (crc << 1);
- }
- }
- return crc;
-}
-
-static void DHT20_reset_reg(I2CSensor* i2c_sensor, uint8_t addr) {
- uint8_t data[3] = {addr, 0x00, 0x00};
-
- unitemp_i2c_writeArray(i2c_sensor, 3, data);
-
- furi_delay_ms(5);
-
- unitemp_i2c_readArray(i2c_sensor, 3, data);
-
- furi_delay_ms(10);
-
- data[0] = 0xB0 | addr;
- unitemp_i2c_writeArray(i2c_sensor, 3, data);
-}
-
-bool unitemp_DHT20_I2C_alloc(Sensor* sensor, char* args) {
- UNUSED(args);
- I2CSensor* i2c_sensor = (I2CSensor*)sensor->instance;
-
- //Адреса на шине I2C (7 бит)
- i2c_sensor->minI2CAdr = 0x38 << 1;
- i2c_sensor->maxI2CAdr = (sensor->type == &DHT20) ? (0x38 << 1) : (0x39 << 1);
- return true;
-}
-
-bool unitemp_DHT20_I2C_free(Sensor* sensor) {
- //Нечего высвобождать, так как ничего не было выделено
- UNUSED(sensor);
- return true;
-}
-
-bool unitemp_DHT20_init(Sensor* sensor) {
- I2CSensor* i2c_sensor = (I2CSensor*)sensor->instance;
-
- uint8_t data[3] = {0xA8, 0x00, 0x00};
- if(!unitemp_i2c_writeArray(i2c_sensor, 3, data)) return false;
- furi_delay_ms(10);
- data[0] = (sensor->type == &DHT20) ? 0xBE : 0xE1;
- data[1] = 0x08;
- if(!unitemp_i2c_writeArray(i2c_sensor, 3, data)) return false;
- furi_delay_ms(10);
-
- return true;
-}
-
-bool unitemp_DHT20_I2C_deinit(Sensor* sensor) {
- //Нечего деинициализировать
- UNUSED(sensor);
- return true;
-}
-
-UnitempStatus unitemp_DHT20_I2C_update(Sensor* sensor) {
- I2CSensor* i2c_sensor = (I2CSensor*)sensor->instance;
-
- if(DHT20_get_status(i2c_sensor) != 0x18) {
- DHT20_reset_reg(i2c_sensor, 0x1B);
- DHT20_reset_reg(i2c_sensor, 0x1C);
- DHT20_reset_reg(i2c_sensor, 0x1E);
- }
- furi_delay_ms(10);
-
- uint8_t data[7] = {0xAC, 0x33, 0x00};
- if(!unitemp_i2c_writeArray(i2c_sensor, 3, data)) return UT_SENSORSTATUS_TIMEOUT;
- furi_delay_ms(80);
- uint32_t t = furi_get_tick();
- while(DHT20_get_status(i2c_sensor) == 0x80) {
- if(furi_get_tick() - t > 10) return UT_SENSORSTATUS_TIMEOUT;
- }
-
- if(!unitemp_i2c_readArray(i2c_sensor, 7, data)) return UT_SENSORSTATUS_TIMEOUT;
-
- if(DHT20_calc_CRC8(data, 6) != data[6]) {
- return UT_SENSORSTATUS_BADCRC;
- }
- uint32_t RetuData = 0;
- RetuData = (RetuData | data[1]) << 8;
- RetuData = (RetuData | data[2]) << 8;
- RetuData = (RetuData | data[3]);
- RetuData = RetuData >> 4;
- sensor->hum = RetuData * 100 * 10 / 1024.0f / 1024.0f / 10.0f;
-
- RetuData = 0;
- RetuData = (RetuData | data[3]) << 8;
- RetuData = (RetuData | data[4]) << 8;
- RetuData = (RetuData | data[5]);
- RetuData = RetuData & 0xfffff;
- sensor->temp = (RetuData * 200 * 10.0f / 1024.0f / 1024.0f - 500) / 10.0f;
-
- return UT_SENSORSTATUS_OK;
-}
diff --git a/applications/plugins/unitemp/sensors/DHT20.h b/applications/plugins/unitemp/sensors/DHT20.h
deleted file mode 100644
index db49495dc..000000000
--- a/applications/plugins/unitemp/sensors/DHT20.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- Unitemp - Universal temperature reader
- Copyright (C) 2022 Victor Nikitchuk (https://github.com/quen0n)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-*/
-#ifndef UNITEMP_DHT20
-#define UNITEMP_DHT20
-
-#include "../unitemp.h"
-#include "../Sensors.h"
-extern const SensorType DHT20;
-extern const SensorType AHT10;
-/**
- * @brief Выделение памяти и установка начальных значений датчика DHT20
- *
- * @param sensor Указатель на создаваемый датчик
- * @return Истина при успехе
- */
-bool unitemp_DHT20_I2C_alloc(Sensor* sensor, char* args);
-
-/**
- * @brief Инициализации датчика DHT20
- *
- * @param sensor Указатель на датчик
- * @return Истина если инициализация упспешная
- */
-bool unitemp_DHT20_init(Sensor* sensor);
-
-/**
- * @brief Деинициализация датчика
- *
- * @param sensor Указатель на датчик
- */
-bool unitemp_DHT20_I2C_deinit(Sensor* sensor);
-
-/**
- * @brief Обновление значений из датчика
- *
- * @param sensor Указатель на датчик
- * @return Статус обновления
- */
-UnitempStatus unitemp_DHT20_I2C_update(Sensor* sensor);
-
-/**
- * @brief Высвободить память датчика
- *
- * @param sensor Указатель на датчик
- */
-bool unitemp_DHT20_I2C_free(Sensor* sensor);
-
-#endif
\ No newline at end of file
diff --git a/applications/plugins/unitemp/sensors/SHT30.c b/applications/plugins/unitemp/sensors/SHT30.c
deleted file mode 100644
index 700a54dec..000000000
--- a/applications/plugins/unitemp/sensors/SHT30.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- Unitemp - Universal temperature reader
- Copyright (C) 2022 Victor Nikitchuk (https://github.com/quen0n)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-*/
-#include "SHT30.h"
-#include "../interfaces/I2CSensor.h"
-
-const SensorType SHT30 = {
- .typename = "SHT30",
- .altname = "SHT30/31/35",
- .interface = &I2C,
- .datatype = UT_TEMPERATURE | UT_HUMIDITY,
- .pollingInterval = 1000,
- .allocator = unitemp_SHT30_I2C_alloc,
- .mem_releaser = unitemp_SHT30_I2C_free,
- .initializer = unitemp_SHT30_init,
- .deinitializer = unitemp_SHT30_I2C_deinit,
- .updater = unitemp_SHT30_I2C_update};
-const SensorType GXHT30 = {
- .typename = "GXHT30",
- .altname = "GXHT30/31/35",
- .interface = &I2C,
- .datatype = UT_TEMPERATURE | UT_HUMIDITY,
- .pollingInterval = 1000,
- .allocator = unitemp_SHT30_I2C_alloc,
- .mem_releaser = unitemp_SHT30_I2C_free,
- .initializer = unitemp_GXHT30_init,
- .deinitializer = unitemp_SHT30_I2C_deinit,
- .updater = unitemp_SHT30_I2C_update};
-
-bool unitemp_SHT30_I2C_alloc(Sensor* sensor, char* args) {
- UNUSED(args);
- I2CSensor* i2c_sensor = (I2CSensor*)sensor->instance;
-
- //Адреса на шине I2C (7 бит)
- i2c_sensor->minI2CAdr = 0x44 << 1;
- i2c_sensor->maxI2CAdr = 0x45 << 1;
- return true;
-}
-
-bool unitemp_SHT30_I2C_free(Sensor* sensor) {
- //Нечего высвобождать, так как ничего не было выделено
- UNUSED(sensor);
- return true;
-}
-
-bool unitemp_SHT30_init(Sensor* sensor) {
- UNUSED(sensor);
- return true;
-}
-
-bool unitemp_GXHT30_init(Sensor* sensor) {
- I2CSensor* i2c_sensor = (I2CSensor*)sensor->instance;
- //Включение режима автоматического преобразования 2 раза в сек
- uint8_t data[2] = {0x22, 0x36};
- if(!unitemp_i2c_writeArray(i2c_sensor, 2, data)) return false;
- return true;
-}
-
-bool unitemp_SHT30_I2C_deinit(Sensor* sensor) {
- //Нечего деинициализировать
- UNUSED(sensor);
- return true;
-}
-
-UnitempStatus unitemp_SHT30_I2C_update(Sensor* sensor) {
- I2CSensor* i2c_sensor = (I2CSensor*)sensor->instance;
- //Получение данных
- uint8_t data[6] = {0xE0, 0x00};
- if(!unitemp_i2c_writeArray(i2c_sensor, 2, data)) return UT_SENSORSTATUS_TIMEOUT;
- if(!unitemp_i2c_readArray(i2c_sensor, 6, data)) return UT_SENSORSTATUS_TIMEOUT;
-
- sensor->temp = -45 + 175 * (((uint16_t)(data[0] << 8) | data[1]) / 65535.0f);
- sensor->hum = 100 * (((uint16_t)(data[3] << 8) | data[4]) / 65535.0f);
-
- return UT_SENSORSTATUS_OK;
-}
diff --git a/applications/plugins/unitemp/sensors/SHT30.h b/applications/plugins/unitemp/sensors/SHT30.h
deleted file mode 100644
index 93e9d05f2..000000000
--- a/applications/plugins/unitemp/sensors/SHT30.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- Unitemp - Universal temperature reader
- Copyright (C) 2022 Victor Nikitchuk (https://github.com/quen0n)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-*/
-#ifndef UNITEMP_SHT30
-#define UNITEMP_SHT30
-
-#include "../unitemp.h"
-#include "../Sensors.h"
-extern const SensorType SHT30;
-extern const SensorType GXHT30;
-/**
- * @brief Выделение памяти и установка начальных значений датчика SHT30
- *
- * @param sensor Указатель на создаваемый датчик
- * @return Истина при успехе
- */
-bool unitemp_SHT30_I2C_alloc(Sensor* sensor, char* args);
-
-/**
- * @brief Инициализации датчика SHT30
- *
- * @param sensor Указатель на датчик
- * @return Истина если инициализация упспешная
- */
-bool unitemp_SHT30_init(Sensor* sensor);
-/**
- * @brief Инициализации датчика GXHT30
- *
- * @param sensor Указатель на датчик
- * @return Истина если инициализация упспешная
- */
-bool unitemp_GXHT30_init(Sensor* sensor);
-
-/**
- * @brief Деинициализация датчика
- *
- * @param sensor Указатель на датчик
- */
-bool unitemp_SHT30_I2C_deinit(Sensor* sensor);
-
-/**
- * @brief Обновление значений из датчика
- *
- * @param sensor Указатель на датчик
- * @return Статус обновления
- */
-UnitempStatus unitemp_SHT30_I2C_update(Sensor* sensor);
-
-/**
- * @brief Высвободить память датчика
- *
- * @param sensor Указатель на датчик
- */
-bool unitemp_SHT30_I2C_free(Sensor* sensor);
-
-#endif
\ No newline at end of file
diff --git a/applications/plugins/unitemp/sensors/Sensors.xlsx b/applications/plugins/unitemp/sensors/Sensors.xlsx
index b139b1b00..2b6578e0e 100644
Binary files a/applications/plugins/unitemp/sensors/Sensors.xlsx and b/applications/plugins/unitemp/sensors/Sensors.xlsx differ
diff --git a/applications/plugins/unitemp/views/General_view.c b/applications/plugins/unitemp/views/General_view.c
index fc1408b1a..e21b04de2 100644
--- a/applications/plugins/unitemp/views/General_view.c
+++ b/applications/plugins/unitemp/views/General_view.c
@@ -362,8 +362,7 @@ static void _draw_carousel_info(Canvas* canvas) {
BUFF_SIZE,
"0x%02X",
((I2CSensor*)unitemp_sensor_getActive(generalview_sensor_index)->instance)
- ->currentI2CAdr >>
- 1);
+ ->currentI2CAdr);
canvas_draw_str(canvas, 57, 35, app->buff);
canvas_draw_str(canvas, 54, 46, "15 (C0)");
canvas_draw_str(canvas, 54, 58, "16 (C1)");
diff --git a/applications/plugins/unitemp/views/SensorEdit_view.c b/applications/plugins/unitemp/views/SensorEdit_view.c
index d1660bc2e..4d5bc17db 100644
--- a/applications/plugins/unitemp/views/SensorEdit_view.c
+++ b/applications/plugins/unitemp/views/SensorEdit_view.c
@@ -214,9 +214,9 @@ static void _gpio_change_callback(VariableItem* item) {
static void _i2caddr_change_callback(VariableItem* item) {
uint8_t index = variable_item_get_current_value_index(item);
((I2CSensor*)editable_sensor->instance)->currentI2CAdr =
- ((I2CSensor*)editable_sensor->instance)->minI2CAdr + index * 2;
+ ((I2CSensor*)editable_sensor->instance)->minI2CAdr + index;
char buff[5];
- snprintf(buff, 5, "0x%2X", ((I2CSensor*)editable_sensor->instance)->currentI2CAdr >> 1);
+ snprintf(buff, 5, "0x%2X", ((I2CSensor*)editable_sensor->instance)->currentI2CAdr);
variable_item_set_current_value_text(item, buff);
}
/**
@@ -335,15 +335,11 @@ void unitemp_SensorEdit_switch(Sensor* sensor) {
VariableItem* item = variable_item_list_add(
variable_item_list,
"I2C address",
- (((I2CSensor*)sensor->instance)->maxI2CAdr >> 1) -
- (((I2CSensor*)sensor->instance)->minI2CAdr >> 1) + 1,
+ ((I2CSensor*)sensor->instance)->maxI2CAdr - ((I2CSensor*)sensor->instance)->minI2CAdr +
+ 1,
_i2caddr_change_callback,
app);
- snprintf(app->buff, 5, "0x%2X", ((I2CSensor*)sensor->instance)->currentI2CAdr >> 1);
- variable_item_set_current_value_index(
- item,
- (((I2CSensor*)sensor->instance)->currentI2CAdr >> 1) -
- (((I2CSensor*)sensor->instance)->minI2CAdr >> 1));
+ snprintf(app->buff, 5, "0x%2X", ((I2CSensor*)sensor->instance)->currentI2CAdr);
variable_item_set_current_value_text(item, app->buff);
}
diff --git a/applications/plugins/unitemp/views/Widgets_view.c b/applications/plugins/unitemp/views/Widgets_view.c
index 892b31f98..6d8702ca1 100644
--- a/applications/plugins/unitemp/views/Widgets_view.c
+++ b/applications/plugins/unitemp/views/Widgets_view.c
@@ -132,7 +132,7 @@ void unitemp_widget_delete_switch(Sensor* sensor) {
app->buff,
BUFF_SIZE,
"\e#I2C addr:\e# 0x%02X",
- ((I2CSensor*)current_sensor->instance)->currentI2CAdr >> 1);
+ ((I2CSensor*)current_sensor->instance)->currentI2CAdr);
widget_add_text_box_element(
app->widget, 0, 28, 128, 23, AlignLeft, AlignTop, app->buff, false);
}