Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/devices/H5140.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Govee H5140

|Model Id|[H5140](https://github.com/theengs/decoder/blob/development/src/devices/H5140_json.h)|
|-|-|
|Brand|Govee|
|Model|Smart CO2 Monitor|
|Short Description|Air quality monitor with temperature, humidity and CO2|
|Communication|BLE broadcast|
|Frequency|2.4Ghz|
|Power Source|USB-C|
|Exchanged Data|temperature, humidity, CO2|
|Encrypted|No|
1 change: 1 addition & 0 deletions src/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class TheengsDecoder {
H5074,
H5102,
H5106,
H5140,
H5179,
H5179_N,
HHCCJCY10,
Expand Down
2 changes: 2 additions & 0 deletions src/devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "devices/H5074_json.h"
#include "devices/H5102_json.h"
#include "devices/H5106_json.h"
#include "devices/H5140_json.h"
#include "devices/H5179_json.h"
#include "devices/HHCCJCY10_json.h"
#include "devices/HHCCJCY01HHCC_json.h"
Expand Down Expand Up @@ -188,6 +189,7 @@ const char* _devices[][2] = {
{_H5074_json, _H5074_json_props},
{_H5102_json, _H5102_json_props},
{_H5106_json, _H5106_json_props},
{_H5140_json, _H5140_json_props},
{_H5179_json, _H5179_json_props},
{_H5179_json_N, _H5179_json_props},
{_HHCCJCY10_json, _HHCCJCY10_json_props},
Expand Down
69 changes: 69 additions & 0 deletions src/devices/H5140_json.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
const char* _H5140_json = "{\"brand\":\"Govee\",\"model\":\"Smart CO2 Monitor\",\"model_id\":\"H5140\",\"tag\":\"0f03\",\"condition\":[\"name\",\"contain\",\"GV5140\",\"&\",\"manufacturerdata\",\">=\",20,\"index\",0,\"01000101\"],\"properties\":{\"tempc\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",8,6,false,false],\"post_proc\":[\"/\",10000]},\"hum\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",8,6,false,false],\"post_proc\":[\"&\",2147483647,\"%\",1000,\"/\",10]},\"co2\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",14,4,false,false]}}}";
/* R""""(
{
"brand":"Govee",
"model":"Smart CO2 Monitor",
"model_id":"H5140",
"tag":"0f03",
"condition":["name", "contain", "GV5140", "&", "manufacturerdata", ">=", 20, "index", 0, "01000101"],
"properties":{
"tempc":{
"decoder":["value_from_hex_data", "manufacturerdata", 8, 6, false, false],
"post_proc":["/", 10000]
},
"hum":{
"decoder":["value_from_hex_data", "manufacturerdata", 8, 6, false, false],
"post_proc":["&", 2147483647, "%", 1000, "/", 10]
},
"co2":{
"decoder":["value_from_hex_data", "manufacturerdata", 14, 4, false, false]
}
}
})"""";*/

/*
* Govee H5140 Smart CO2 Monitor - BLE Manufacturer Data Format
* =============================================================
*
* Advertisement name pattern: GV5140XXXX (where XXXX is device suffix)
* Manufacturer data: 20 hex characters (10 bytes)
*
* Byte layout:
* Positions 0-7: 01000101 (constant header)
* Positions 8-13: XXXXXX (24-bit combined temp/humidity)
* Positions 14-17: YYYY (16-bit CO2 in ppm, big-endian)
* Positions 18-19: 00 (padding/unknown)
*
* Decoding formulas:
* - temp_celsius = 24bit_value / 10000
* - humidity_percent = (24bit_value % 1000) / 10
* - co2_ppm = 16bit_value
*
* Example: 0100010103fcbf044c00
* - Header: 01000101
* - Temp/Hum: 03fcbf = 261311 decimal
* - Temperature: 261311 / 10000 = 26.13°C (79.04°F)
* - Humidity: (261311 % 1000) / 10 = 31.1%
* - CO2: 044c = 1100 ppm
*
* Tested with OpenMQTTGateway on ESP32
*/

const char* _H5140_json_props = "{\"properties\":{\"tempc\":{\"unit\":\"°C\",\"name\":\"temperature\"},\"hum\":{\"unit\":\"%\",\"name\":\"humidity\"},\"co2\":{\"unit\":\"ppm\",\"name\":\"carbon_dioxide\"}}}";
/*R""""(
{
"properties":{
"tempc":{
"unit":"°C",
"name":"temperature"
},
"hum":{
"unit":"%",
"name":"humidity"
},
"co2":{
"unit":"ppm",
"name":"carbon_dioxide"
}
}
})"""";*/
9 changes: 9 additions & 0 deletions tests/BLE/test_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ const char* expected_mfg[] = {
"{\"brand\":\"Victron Energy\",\"model\":\"Smart Battery Sense\",\"model_id\":\"VICTSBS\",\"type\":\"ENRG\",\"track\":true,\"volt\":12.99,\"tempc\":17.5,\"tempf\":63.5,\"alarm_reason\":0}",
"{\"brand\":\"Victron Energy\",\"model\":\"Smart Battery Sense\",\"model_id\":\"VICTSBS\",\"type\":\"ENRG\",\"track\":true,\"volt\":14.01,\"tempc\":17.5,\"tempf\":63.5,\"alarm_reason\":0}",
"{\"brand\":\"Victron Energy\",\"model\":\"Smart Battery Sense\",\"model_id\":\"VICTSBS\",\"type\":\"ENRG\",\"track\":true,\"volt\":12.22,\"tempc\":22.5,\"tempf\":72.5,\"alarm_reason\":0}",
"{\"brand\":\"Govee\",\"model\":\"Smart CO2 Monitor\",\"model_id\":\"H5140\",\"type\":\"AIR\",\"cidc\":false,\"acts\":true,\"tempc\":26.1311,\"tempf\":79.03598,\"hum\":31.1,\"co2\":1100}",
"{\"brand\":\"Govee\",\"model\":\"Smart CO2 Monitor\",\"model_id\":\"H5140\",\"type\":\"AIR\",\"cidc\":false,\"acts\":true,\"tempc\":15.56,\"tempf\":60.008,\"hum\":60,\"co2\":500}",
"{\"brand\":\"Govee\",\"model\":\"Smart CO2 Monitor\",\"model_id\":\"H5140\",\"type\":\"AIR\",\"cidc\":false,\"acts\":true,\"tempc\":23.8048,\"tempf\":74.84864,\"hum\":4.8,\"co2\":1700}",
};

const char* expected_name_uuid_mfgsvcdata[] = {
Expand Down Expand Up @@ -828,6 +831,9 @@ const char* test_mfgdata[][3] = {
{"Victron Smart Battery Sense", "", "e1021180a5a302ffff7bffff130500008971feff7fffffffff"},
{"Victron Smart Battery Sense", "", "e1021180a5a302ffff7bffff790500008971feff7fffffffff"},
{"Victron Smart Battery Sense", "", "e1021100a4a302ffff7cffffc60400007d73feff7fffffffff"},
{"H5140", "GV5140_1234", "0100010103fcbf044c00"},
{"H5140", "GV5140_1234", "01000101025fd001f400"},
{"H5140", "GV5140_1234", "0100010103a1e006a400"},
};

TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{
Expand Down Expand Up @@ -1048,6 +1054,9 @@ TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{
TheengsDecoder::BLE_ID_NUM::VICTSBS,
TheengsDecoder::BLE_ID_NUM::VICTSBS,
TheengsDecoder::BLE_ID_NUM::VICTSBS,
TheengsDecoder::BLE_ID_NUM::H5140,
TheengsDecoder::BLE_ID_NUM::H5140,
TheengsDecoder::BLE_ID_NUM::H5140,
};

// uuid test input [test name] [device name] [uuid] [manufacturer data] [service data]
Expand Down