mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-20 09:43:03 +00:00
add veml7700 readings to protobuf and to the mqtt json + fix the readigns validator code in env telemetry
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "Sensor/MCP9808Sensor.h"
|
||||
#include "Sensor/SHT31Sensor.h"
|
||||
#include "Sensor/SHTC3Sensor.h"
|
||||
#include "Sensor/VEML7700Sensor.h"
|
||||
|
||||
BMP085Sensor bmp085Sensor;
|
||||
BMP280Sensor bmp280Sensor;
|
||||
@@ -32,6 +33,7 @@ MCP9808Sensor mcp9808Sensor;
|
||||
SHTC3Sensor shtc3Sensor;
|
||||
LPS22HBSensor lps22hbSensor;
|
||||
SHT31Sensor sht31Sensor;
|
||||
VEML7700Sensor veml7700Sensor;
|
||||
|
||||
#define FAILED_STATE_SENSOR_READ_MULTIPLIER 10
|
||||
#define DISPLAY_RECEIVEID_MEASUREMENTS_ON_SCREEN true
|
||||
@@ -90,6 +92,8 @@ int32_t EnvironmentTelemetryModule::runOnce()
|
||||
result = ina219Sensor.runOnce();
|
||||
if (ina260Sensor.hasSensor())
|
||||
result = ina260Sensor.runOnce();
|
||||
if (veml7700Sensor.hasSensor())
|
||||
result = veml7700Sensor.runOnce();
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
@@ -192,10 +196,11 @@ bool EnvironmentTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPac
|
||||
const char *sender = getSenderShortName(mp);
|
||||
|
||||
LOG_INFO("(Received from %s): barometric_pressure=%f, current=%f, gas_resistance=%f, relative_humidity=%f, "
|
||||
"temperature=%f, voltage=%f\n",
|
||||
"temperature=%f, voltage=%f, lux=%f, iaq=%i\n",
|
||||
sender, t->variant.environment_metrics.barometric_pressure, t->variant.environment_metrics.current,
|
||||
t->variant.environment_metrics.gas_resistance, t->variant.environment_metrics.relative_humidity,
|
||||
t->variant.environment_metrics.temperature, t->variant.environment_metrics.voltage);
|
||||
t->variant.environment_metrics.temperature, t->variant.environment_metrics.voltage,
|
||||
t->variant.environment_metrics.lux, t->variant.environment_metrics.iaq);
|
||||
#endif
|
||||
// release previous packet before occupying a new spot
|
||||
if (lastMeasurementPacket != nullptr)
|
||||
@@ -210,44 +215,65 @@ bool EnvironmentTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPac
|
||||
bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly)
|
||||
{
|
||||
meshtastic_Telemetry m;
|
||||
bool valid = false;
|
||||
bool valid = true;
|
||||
bool hasSensor = false;
|
||||
m.time = getTime();
|
||||
m.which_variant = meshtastic_Telemetry_environment_metrics_tag;
|
||||
|
||||
m.variant.environment_metrics.barometric_pressure = 0;
|
||||
m.variant.environment_metrics.current = 0;
|
||||
m.variant.environment_metrics.gas_resistance = 0;
|
||||
m.variant.environment_metrics.relative_humidity = 0;
|
||||
m.variant.environment_metrics.temperature = 0;
|
||||
m.variant.environment_metrics.voltage = 0;
|
||||
|
||||
if (sht31Sensor.hasSensor())
|
||||
valid = sht31Sensor.getMetrics(&m);
|
||||
if (lps22hbSensor.hasSensor())
|
||||
valid = lps22hbSensor.getMetrics(&m);
|
||||
if (shtc3Sensor.hasSensor())
|
||||
valid = shtc3Sensor.getMetrics(&m);
|
||||
if (bmp085Sensor.hasSensor())
|
||||
valid = bmp085Sensor.getMetrics(&m);
|
||||
if (bmp280Sensor.hasSensor())
|
||||
valid = bmp280Sensor.getMetrics(&m);
|
||||
if (bme280Sensor.hasSensor())
|
||||
valid = bme280Sensor.getMetrics(&m);
|
||||
if (bme680Sensor.hasSensor())
|
||||
valid = bme680Sensor.getMetrics(&m);
|
||||
if (mcp9808Sensor.hasSensor())
|
||||
valid = mcp9808Sensor.getMetrics(&m);
|
||||
if (ina219Sensor.hasSensor())
|
||||
if (sht31Sensor.hasSensor()) {
|
||||
valid = valid && sht31Sensor.getMetrics(&m);
|
||||
hasSensor = true;
|
||||
}
|
||||
if (lps22hbSensor.hasSensor()) {
|
||||
valid = valid && lps22hbSensor.getMetrics(&m);
|
||||
hasSensor = true;
|
||||
}
|
||||
if (shtc3Sensor.hasSensor()) {
|
||||
valid = valid && shtc3Sensor.getMetrics(&m);
|
||||
hasSensor = true;
|
||||
}
|
||||
if (bmp085Sensor.hasSensor()) {
|
||||
valid = valid && bmp085Sensor.getMetrics(&m);
|
||||
hasSensor = true;
|
||||
}
|
||||
if (bmp280Sensor.hasSensor()) {
|
||||
valid = valid && bmp280Sensor.getMetrics(&m);
|
||||
hasSensor = true;
|
||||
}
|
||||
if (bme280Sensor.hasSensor()) {
|
||||
valid = valid && bme280Sensor.getMetrics(&m);
|
||||
hasSensor = true;
|
||||
}
|
||||
if (bme680Sensor.hasSensor()) {
|
||||
valid = valid && bme680Sensor.getMetrics(&m);
|
||||
hasSensor = true;
|
||||
}
|
||||
if (mcp9808Sensor.hasSensor()) {
|
||||
valid = valid && mcp9808Sensor.getMetrics(&m);
|
||||
hasSensor = true;
|
||||
}
|
||||
if (ina219Sensor.hasSensor()) {
|
||||
valid = ina219Sensor.getMetrics(&m);
|
||||
if (ina260Sensor.hasSensor())
|
||||
valid = ina260Sensor.getMetrics(&m);
|
||||
hasSensor = true;
|
||||
}
|
||||
if (ina260Sensor.hasSensor()) {
|
||||
valid = valid && ina260Sensor.getMetrics(&m);
|
||||
hasSensor = true;
|
||||
}
|
||||
if (veml7700Sensor.hasSensor()) {
|
||||
valid = valid && veml7700Sensor.getMetrics(&m);
|
||||
hasSensor = true;
|
||||
}
|
||||
|
||||
valid = valid && hasSensor;
|
||||
|
||||
if (valid) {
|
||||
LOG_INFO("(Sending): barometric_pressure=%f, current=%f, gas_resistance=%f, relative_humidity=%f, temperature=%f, "
|
||||
"voltage=%f\n",
|
||||
"voltage=%f, lux=%f, iaq=%i\n",
|
||||
m.variant.environment_metrics.barometric_pressure, m.variant.environment_metrics.current,
|
||||
m.variant.environment_metrics.gas_resistance, m.variant.environment_metrics.relative_humidity,
|
||||
m.variant.environment_metrics.temperature, m.variant.environment_metrics.voltage);
|
||||
m.variant.environment_metrics.temperature, m.variant.environment_metrics.voltage,
|
||||
m.variant.environment_metrics.lux, m.variant.environment_metrics.iaq);
|
||||
|
||||
sensor_read_error_count = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user