Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

b-parasite soil sensor #127

Merged
merged 1 commit into from
Jun 17, 2022
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
1 change: 1 addition & 0 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module.exports = {
sidebarDepth: 1, // optional, defaults to 1
children: [
'devices/BM_V23',
'devices/BPARASITE',
'devices/CGD1',
'devices/CGP1W',
'devices/GAEN',
Expand Down
12 changes: 12 additions & 0 deletions docs/devices/BPARASITE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# rbaron b-parasite

|Model Id|[BPv1.0-1.2](https://github.com/theengs/decoder/blob/development/src/devices/BPARASITE_json.h)|
|-|-|
|Brand|rbaron|
|Model|b-parasite|
|Short Description|Open hardware and open source soil moisture and ambient temperature/humidity/light sensor https://github.com/rbaron/b-parasite|
|Communication|BLE broadcast|
|Frequency|2.4Ghz|
|Power source|CR2032|
|Exchanged data|moisture, temperature, humidity, luminance (v1.1.0+), voltage|
|Encrypted|No|
1 change: 1 addition & 0 deletions src/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class TheengsDecoder {
MS_CDP,
GAEN,
HHCCPOT002,
BPARASITE,
BLE_ID_MAX
};

Expand Down
2 changes: 2 additions & 0 deletions src/devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
#include "devices/iBeacon_json.h"
#include "devices/iNode_json.h"
#include "devices/BM_V23_json.h"
#include "devices/BPARASITE_json.h"

const char* _devices[][2] = {
{_HHCCJCY01HHCC_json, _HHCCJCY01HHCC_json_props},
Expand Down Expand Up @@ -102,4 +103,5 @@ const char* _devices[][2] = {
{_MS_CDP_json, _MS_CDP_json_props},
{_GAEN_json, _GAEN_json_props},
{_HHCCPOT002_json, _HHCCPOT002_json_props},
{_BPARASITE_json, _BPARASITE_json_props},
};
64 changes: 64 additions & 0 deletions src/devices/BPARASITE_json.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
const char* _BPARASITE_json = "{\"brand\":\"rbaron\",\"model\":\"b-parasite\",\"model_id\":\"BPv1.0-1.2\",\"condition\":[\"servicedata\",\">=\",32,\"index\",0,\"1\",\"|\",\"servicedata\",\">=\",32,\"index\",0,\"2\",\"&\",\"uuid\",\"index\",0,\"181a\"],\"properties\":{\"tempc\":{\"condition\":[\"servicedata\",0,\"1\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",8,4,false,true],\"post_proc\":[\"/\",1000]},\"_tempc\":{\"condition\":[\"servicedata\",0,\"2\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",8,4,false,true],\"post_proc\":[\"/\",100]},\"hum\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",12,4,false,false],\"post_proc\":[\"/\",655.35]},\"moi\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",16,4,false,false],\"post_proc\":[\"/\",655.35]},\"lux\":{\"condition\":[\"servicedata\",1,\"bit\",0,1],\"decoder\":[\"value_from_hex_data\",\"servicedata\",32,4,false,false]},\"volt\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,4,false,false],\"post_proc\":[\"/\",1000]}}}";

/* R""""(
{
"brand":"rbaron",
"model":"b-parasite",
"model_id":"BPv1.0-1.2",
"condition":["servicedata", ">=", 32, "index", 0, "1", "|", "servicedata", ">=", 32, "index", 0, "2", "&", "uuid", "index", 0, "181a"],
"properties":{
"tempc":{
"condition":["servicedata", 0, "1"],
"decoder":["value_from_hex_data", "servicedata", 8, 4, false, true],
"post_proc":["/", 1000]
},
"_tempc":{
"condition":["servicedata", 0, "2"],
"decoder":["value_from_hex_data", "servicedata", 8, 4, false, true],
"post_proc":["/", 100]
},
"hum":{
"decoder":["value_from_hex_data", "servicedata", 12, 4, false, false],
"post_proc":["/", 655.35]
},
"moi":{
"decoder":["value_from_hex_data", "servicedata", 16, 4, false, false],
"post_proc":["/", 655.35]
},
"lux":{
"condition":["servicedata", 1, "bit", 0, 1],
"decoder":["value_from_hex_data", "servicedata", 32, 4, false, false]
},
"volt":{
"decoder":["value_from_hex_data", "servicedata", 4, 4, false, false],
"post_proc":["/", 1000]
}
}
})"""";*/

const char* _BPARASITE_json_props = "{\"properties\":{\"tempc\":{\"unit\":\"°C\",\"name\":\"temperature\"},\"hum\":{\"unit\":\"%\",\"name\":\"humidity\"},\"moi\":{\"unit\":\"%\",\"name\":\"moisture\"},\"lux\":{\"unit\":\"lx\",\"name\":\"illuminance\"},\"volt\":{\"unit\":\"V\",\"name\":\"voltage\"}}}";
/*R""""(
{
"properties":{
"tempc":{
"unit":"°C",
"name":"temperature"
},
"hum":{
"unit":"%",
"name":"humidity"
},
"moi":{
"unit":"%",
"name":"moisture"
},
"lux":{
"unit":"lx",
"name":"illuminance"
},
"volt":{
"unit":"V",
"name":"voltage"
}
}
})"""";*/
12 changes: 12 additions & 0 deletions tests/BLE/test_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ const char* expected_uuid[] = {
"{\"brand\":\"SwitchBot\",\"model\":\"Meter (Plus)\",\"model_id\":\"THX1/W230150X\",\"tempc\":25.8,\"tempf\":78.44,\"hum\":59,\"batt\":58}",
"{\"brand\":\"SwitchBot\",\"model\":\"Meter (Plus)\",\"model_id\":\"THX1/W230150X\",\"tempc\":-25.3,\"tempf\":-13.54,\"hum\":56,\"batt\":58}",
"{\"brand\":\"SwitchBot\",\"model\":\"Meter (Plus)\",\"model_id\":\"THX1/W230150X\",\"tempc\":26,\"tempf\":78.8,\"hum\":56,\"batt\":58}",
"{\"brand\":\"rbaron\",\"model\":\"b-parasite\",\"model_id\":\"BPv1.0-1.2\",\"tempc\":25.6,\"tempf\":78.08,\"hum\":90.00076295,\"moi\":49.99923705,\"volt\":3.1}",
"{\"brand\":\"rbaron\",\"model\":\"b-parasite\",\"model_id\":\"BPv1.0-1.2\",\"tempc\":22.7,\"tempf\":72.86,\"hum\":65.00038148,\"moi\":42.00045777,\"lux\":12500,\"volt\":2.95}",
"{\"brand\":\"rbaron\",\"model\":\"b-parasite\",\"model_id\":\"BPv1.0-1.2\",\"tempc\":25.6,\"tempf\":78.08,\"hum\":90.00076295,\"moi\":49.99923705,\"volt\":3.1}",
"{\"brand\":\"rbaron\",\"model\":\"b-parasite\",\"model_id\":\"BPv1.0-1.2\",\"tempc\":22.7,\"tempf\":72.86,\"hum\":65.00038148,\"moi\":42.00045777,\"lux\":12500,\"volt\":2.95}",
};

// Service data test input [test name] [data]
Expand Down Expand Up @@ -330,6 +334,10 @@ const char* test_uuid[][4] = {
{"Switchbot_Meter", "fd3d", "servicedata", "6900ba08993b"},
{"Switchbot_Meter", "fd3d", "servicedata", "6900ba031938"},
{"Switchbot_Meter", "fd3d", "servicedata", "6900ba009ab8"},
{"bParasite", "181a", "servicedata", "10c30c1c6400e6667fffaabbccddeeff"},
{"bParasite", "181a", "servicedata", "11c30b8658aca6666b85aabbccddeeff30d4"},
{"bParasite", "181a", "servicedata", "20c30c1c0a00e6667fffaabbccddeeff"},
{"bParasite", "181a", "servicedata", "21c30b8608dea6666b85aabbccddeeff30d4"},
};

TheengsDecoder::BLE_ID_NUM test_uuid_id_num[]{
Expand Down Expand Up @@ -363,6 +371,10 @@ TheengsDecoder::BLE_ID_NUM test_uuid_id_num[]{
TheengsDecoder::BLE_ID_NUM::SBMT,
TheengsDecoder::BLE_ID_NUM::SBMT,
TheengsDecoder::BLE_ID_NUM::SBMT,
TheengsDecoder::BLE_ID_NUM::BPARASITE,
TheengsDecoder::BLE_ID_NUM::BPARASITE,
TheengsDecoder::BLE_ID_NUM::BPARASITE,
TheengsDecoder::BLE_ID_NUM::BPARASITE,
};

template <typename T>
Expand Down