1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2026-02-11 15:13:06 +01:00

allow to switch PGN 130311 for sensors on/off, simplify config.json for i2csensors

This commit is contained in:
wellenvogel
2025-09-29 17:05:48 +02:00
parent 9831f8da85
commit fddc3c742b
6 changed files with 118 additions and 235 deletions

View File

@@ -23,6 +23,7 @@ class BME280Config : public IICSensorBase{
bool prAct=true;
bool tmAct=true;
bool huAct=true;
bool sEnv=true;
tN2kTempSource tmSrc=tN2kTempSource::N2kts_InsideTemperature;
tN2kHumiditySource huSrc=tN2kHumiditySource::N2khs_InsideHumidity;
tN2kPressureSource prSrc=tN2kPressureSource::N2kps_Atmospheric;
@@ -152,6 +153,7 @@ SensorBase::Creator registerBME280(GwApi *api){
CFG_SGET(s, prNam, prefix); \
CFG_SGET(s, tmOff, prefix); \
CFG_SGET(s, prOff, prefix); \
CFG_SGET(s, sEnv, prefix); \
s->busId = bus; \
s->addr = baddr; \
s->ok = true; \

View File

@@ -29,6 +29,7 @@ class BMP280Config : public IICSensorBase{
public:
bool prAct=true;
bool tmAct=true;
bool sEnv=true;
tN2kTempSource tmSrc=tN2kTempSource::N2kts_InsideTemperature;
tN2kPressureSource prSrc=tN2kPressureSource::N2kps_Atmospheric;
tN2kHumiditySource huSrc=tN2kHumiditySource::N2khs_Undef;
@@ -150,6 +151,7 @@ SensorBase::Creator registerBMP280(GwApi *api){
CFG_SGET(s, prNam, prefix); \
CFG_SGET(s, tmOff, prefix); \
CFG_SGET(s, prOff, prefix); \
CFG_SGET(s, sEnv,prefix); \
s->busId = bus; \
s->addr = baddr; \
s->ok = true; \

View File

@@ -104,6 +104,7 @@ void sendN2kTemperature(GwApi *api,CFG &cfg,double value, int counterId){
template <class CFG>
void sendN2kEnvironmentalParameters(GwApi *api,CFG &cfg,double tmValue, double huValue, double prValue, int counterId){
if (! cfg.sEnv) return;
tN2kMsg msg;
SetN2kEnvironmentalParameters(msg,1,cfg.tmSrc,tmValue,cfg.huSrc,huValue,prValue);
api->sendN2kMessage(msg);

View File

@@ -91,6 +91,7 @@ void initIicTask(GwApi *api){
GwConfigHandler *config=api->getConfig();
std::vector<SensorBase::Creator> creators;
creators.push_back(registerSHT3X(api));
creators.push_back(registerSHT4X(api));
creators.push_back(registerQMP6988(api));
creators.push_back(registerBME280(api));
creators.push_back(registerBMP280(api));

View File

@@ -9,6 +9,7 @@ class QMP6988Config : public IICSensorBase{
public:
String prNam="Pressure";
bool prAct=true;
bool sEnv=true;
tN2kPressureSource prSrc=tN2kPressureSource::N2kps_Atmospheric;
float prOff=0;
QMP6988 *device=nullptr;
@@ -90,6 +91,7 @@ SensorBase::Creator registerQMP6988(GwApi *api){
CFG_SGET(s,prAct,prefix); \
CFG_SGET(s,intv,prefix); \
CFG_SGET(s,prOff,prefix); \
CFG_SGET(s,sEnv,prefix); \
s->busId = bus; \
s->addr = baddr; \
s->ok = true; \

View File

@@ -1,49 +1,77 @@
[
{
"type": "array",
"name": "SHT3X",
"name": "SHTXX",
"replace": [
{
"b": "1",
"i": "11",
"n": "99"
"n": "99",
"x": "3"
},
{
"b": "1",
"i": "12",
"n": "98"
"n": "98",
"x": "3"
},
{
"b": "2",
"i": "21",
"n": "109"
"n": "109",
"x": "3"
},
{
"b": "2",
"i": "22",
"n": "108"
"n": "108",
"x": "3"
},
{
"b": "1",
"i": "11",
"n": "119",
"x": "4"
},
{
"b": "1",
"i": "12",
"n": "118",
"x": "4"
},
{
"b": "2",
"i": "21",
"n": "129",
"x": "4"
},
{
"b": "2",
"i": "22",
"n": "128",
"x": "4"
}
],
"children": [
{
"name": "SHT3X$itmAct",
"label": "SHT3X$i Temp",
"name": "SHT$xX$itmAct",
"label": "SHT$xX$i Temp",
"type": "boolean",
"default": "true",
"description": "Enable the $i. I2C SHT3x temp sensor (bus $b)",
"description": "Enable the $i. I2C SHT$xX temp sensor (bus $b)",
"category": "iicsensors$b",
"capabilities": {
"SHT3X$i": "true"
"SHT$xX$i": "true"
}
},
{
"name": "SHT3X$itmSrc",
"label": "SHT3X$i Temp Type",
"name": "SHT$xX$itmSrc",
"label": "SHT$xX$i Temp Type",
"type": "list",
"default": "2",
"description": "the NMEA2000 source type for the temperature",
"description": "the NMEA2000 source type for the temperature (PGN 130312,130311)",
"list": [
{
"l": "SeaTemperature",
@@ -112,23 +140,23 @@
],
"category": "iicsensors$b",
"capabilities": {
"SHT3X$i": "true"
"SHT$xX$i": "true"
}
},
{
"name": "SHT3X$ihuAct",
"label": "SHT3X$i Humidity",
"name": "SHT$xX$ihuAct",
"label": "SHT$xX$i Humidity",
"type": "boolean",
"default": "true",
"description": "Enable the $i. I2C SHT3x humidity sensor (bus $b)",
"description": "Enable the $i. I2C SHT$xX humidity sensor (bus $b)",
"category": "iicsensors$b",
"capabilities": {
"SHT3X$i": "true"
"SHT$xX$i": "true"
}
},
{
"name": "SHT3X$ihuSrc",
"label": "SHT3X$i Humid Type",
"name": "SHT$xX$ihuSrc",
"label": "SHT$xX$i Humid Type",
"list": [
{
"l": "OutsideHumidity",
@@ -141,254 +169,68 @@
],
"category": "iicsensors$b",
"capabilities": {
"SHT3X": "true"
"SHT$xX": "true"
}
},
{
"name": "SHT3X$iiid",
"label": "SHT3X$i N2K iid",
"name": "SHT$xX$iiid",
"label": "SHT$xX$i N2K iid",
"type": "number",
"default": "$n",
"description": "the N2K instance id for the $i. SHT3X Temperature and Humidity ",
"description": "the N2K instance id for the $i. SHT$xX Temperature and Humidity (PGN 130312,130311) ",
"category": "iicsensors$b",
"min": 0,
"max": 253,
"check": "checkMinMax",
"capabilities": {
"SHT3X$i": "true"
"SHT$xX$i": "true"
}
},
{
"name": "SHT3X$iintv",
"label": "SHT3X$i Interval",
"name": "SHT$xX$isEnv",
"label": "SHT$xX$i send Env",
"type": "boolean",
"default": "true",
"description": "also send PGN 130311",
"category": "iicsensors$b",
"capabilities": {
"SHT$xX$i": "true"
}
},
{
"name": "SHT$xX$iintv",
"label": "SHT$xX$i Interval",
"type": "number",
"default": 2,
"description": "Interval(s) to query SHT3X Temperature and Humidity (1...300)",
"description": "Interval(s) to query SHT$xX Temperature and Humidity (1...300)",
"category": "iicsensors$b",
"min": 1,
"max": 300,
"check": "checkMinMax",
"capabilities": {
"SHT3X$i": "true"
"SHT$xX$i": "true"
}
},
{
"name": "SHT3X$itmNam",
"label": "SHT3X$i Temp XDR",
"name": "SHT$xX$itmNam",
"label": "SHT$xX$i Temp XDR",
"type": "String",
"default": "Temp$i",
"description": "set the XDR transducer name for the $i. SHT3X Temperature, leave empty to disable NMEA0183 XDR ",
"description": "set the XDR transducer name for the $i. SHT$xX Temperature, leave empty to disable NMEA0183 XDR ",
"category": "iicsensors$b",
"capabilities": {
"SHT3X$i": "true"
"SHT$xX$i": "true"
}
},
{
"name": "SHT3X$ihuNam",
"label": "SHT3X$i Humid XDR",
"name": "SHT$xX$ihuNam",
"label": "SHT$xX$i Humid XDR",
"type": "String",
"default": "Humidity$i",
"description": "set the XDR transducer name for the $i. SHT3X Humidity, leave empty to disable NMEA0183 XDR",
"description": "set the XDR transducer name for the $i. SHT$xX Humidity, leave empty to disable NMEA0183 XDR",
"category": "iicsensors$b",
"capabilities": {
"SHT3X$i": "true"
}
}
]
},
{
"type": "array",
"name": "SHT4X",
"replace": [
{
"b": "1",
"i": "11",
"n": "119"
},
{
"b": "1",
"i": "12",
"n": "118"
},
{
"b": "2",
"i": "21",
"n": "129"
},
{
"b": "2",
"i": "22",
"n": "128"
}
],
"children": [
{
"name": "SHT4X$itmAct",
"label": "SHT4X$i Temp",
"type": "boolean",
"default": "true",
"description": "Enable the $i. I2C SHT4X temp sensor (bus $b)",
"category": "iicsensors$b",
"capabilities": {
"SHT4X$i": "true"
}
},
{
"name": "SHT4X$itmSrc",
"label": "SHT4X$i Temp Type",
"type": "list",
"default": "2",
"description": "the NMEA2000 source type for the temperature",
"list": [
{
"l": "SeaTemperature",
"v": "0"
},
{
"l": "OutsideTemperature",
"v": "1"
},
{
"l": "InsideTemperature",
"v": "2"
},
{
"l": "EngineRoomTemperature",
"v": "3"
},
{
"l": "MainCabinTemperature",
"v": "4"
},
{
"l": "LiveWellTemperature",
"v": "5"
},
{
"l": "BaitWellTemperature",
"v": "6"
},
{
"l": "RefridgerationTemperature",
"v": "7"
},
{
"l": "HeatingSystemTemperature",
"v": "8"
},
{
"l": "DewPointTemperature",
"v": "9"
},
{
"l": "ApparentWindChillTemperature",
"v": "10"
},
{
"l": "TheoreticalWindChillTemperature",
"v": "11"
},
{
"l": "HeatIndexTemperature",
"v": "12"
},
{
"l": "FreezerTemperature",
"v": "13"
},
{
"l": "ExhaustGasTemperature",
"v": "14"
},
{
"l": "ShaftSealTemperature",
"v": "15"
}
],
"category": "iicsensors$b",
"capabilities": {
"SHT4X$i": "true"
}
},
{
"name": "SHT4X$ihuAct",
"label": "SHT4X$i Humidity",
"type": "boolean",
"default": "true",
"description": "Enable the $i. I2C SHT4X humidity sensor (bus $b)",
"category": "iicsensors$b",
"capabilities": {
"SHT4X$i": "true"
}
},
{
"name": "SHT4X$ihuSrc",
"label": "SHT4X$i Humid Type",
"list": [
{
"l": "OutsideHumidity",
"v": "1"
},
{
"l": "Undef",
"v": "0xff"
}
],
"category": "iicsensors$b",
"capabilities": {
"SHT4X": "true"
}
},
{
"name": "SHT4X$iiid",
"label": "SHT4X$i N2K iid",
"type": "number",
"default": "$n",
"description": "the N2K instance id for the $i. SHT4X Temperature and Humidity ",
"category": "iicsensors$b",
"min": 0,
"max": 253,
"check": "checkMinMax",
"capabilities": {
"SHT4X$i": "true"
}
},
{
"name": "SHT4X$iintv",
"label": "SHT4X$i Interval",
"type": "number",
"default": 2,
"description": "Interval(s) to query SHT4X Temperature and Humidity (1...300)",
"category": "iicsensors$b",
"min": 1,
"max": 300,
"check": "checkMinMax",
"capabilities": {
"SHT4X$i": "true"
}
},
{
"name": "SHT4X$itmNam",
"label": "SHT4X$i Temp XDR",
"type": "String",
"default": "Temp$i",
"description": "set the XDR transducer name for the $i. SHT4X Temperature, leave empty to disable NMEA0183 XDR ",
"category": "iicsensors$b",
"capabilities": {
"SHT4X$i": "true"
}
},
{
"name": "SHT4X$ihuNam",
"label": "SHT4X$i Humid XDR",
"type": "String",
"default": "Humidity$i",
"description": "set the XDR transducer name for the $i. SHT4X Humidity, leave empty to disable NMEA0183 XDR",
"category": "iicsensors$b",
"capabilities": {
"SHT4X$i": "true"
"SHT$xX$i": "true"
}
}
]
@@ -444,6 +286,17 @@
"QMP6988$i": "true"
}
},
{
"name": "QMP6988$isEnv",
"label": "QMP6988$i send Env",
"type": "boolean",
"default": "true",
"description": "also send PGN 130311",
"category": "iicsensors$b",
"capabilities": {
"QMP6988$i": "true"
}
},
{
"name": "QMP6988$iintv",
"label": "QMP6988-$i Interval",
@@ -670,7 +523,7 @@
"label": "BME280-$i N2K iid",
"type": "number",
"default": "$n",
"description": "the N2K instance id for the BME280 Temperature and Humidity ",
"description": "the N2K instance id for the BME280 Temperature, Humidity, Pressure (PGN 130312,130313, 130314) ",
"category": "iicsensors$b",
"min": 0,
"max": 253,
@@ -679,6 +532,17 @@
"BME280$i": "true"
}
},
{
"name": "BME280$isEnv",
"label": "BME280$i send Env",
"type": "boolean",
"default": "true",
"description": "also send PGN 130311",
"category": "iicsensors$b",
"capabilities": {
"BME280$i": "true"
}
},
{
"name": "BME280$iintv",
"label": "BME280-$i Interval",
@@ -880,7 +744,7 @@
"label": "BMP280-$i N2K iid",
"type": "number",
"default": "$n",
"description": "the N2K instance id for the BMP280 Temperature",
"description": "the N2K instance id for the BMP280 Temperature/Pressure (PGN 130312,130314)",
"category": "iicsensors$b",
"min": 0,
"max": 253,
@@ -889,6 +753,17 @@
"BMP280$i": "true"
}
},
{
"name": "BMP280$isEnv",
"label": "BMP280$i send Env",
"type": "boolean",
"default": "true",
"description": "also send PGN 130311",
"category": "iicsensors$b",
"capabilities": {
"BMP280$i": "true"
}
},
{
"name": "BMP280$iintv",
"label": "BMP280-$i Interval",