diff --git a/protobufs b/protobufs index bc484d8063..1f0c500315 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit bc484d8063585770cf97e98c5a332ccb27c57c20 +Subproject commit 1f0c50031516ce96dc0fbd10a82683d3c741a735 diff --git a/src/detect/ScanI2CTwoWire.cpp b/src/detect/ScanI2CTwoWire.cpp index 8c09221355..057cb2a716 100644 --- a/src/detect/ScanI2CTwoWire.cpp +++ b/src/detect/ScanI2CTwoWire.cpp @@ -464,11 +464,11 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize) break; case CGRADSENS_ADDR: - LOG_INFO("Looking for ClimateGuard RadSense Geiger-Muller Sensor"); + // Register 0x00 of the RadSens sensor contains is product identifier 0x7D registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x00), 1); if (registerValue == 0x7D) { type = CGRADSENS; - LOG_INFO("ClimateGuard RadSense Geiger-Muller Sensor found"); + LOG_INFO("ClimateGuard RadSens Geiger-Muller Sensor found"); break; } break; diff --git a/src/mesh/generated/meshtastic/telemetry.pb.h b/src/mesh/generated/meshtastic/telemetry.pb.h index 7980a84f77..874eef60fe 100644 --- a/src/mesh/generated/meshtastic/telemetry.pb.h +++ b/src/mesh/generated/meshtastic/telemetry.pb.h @@ -78,7 +78,7 @@ typedef enum _meshtastic_TelemetrySensorType { meshtastic_TelemetrySensorType_MLX90614 = 31, /* SCD40/SCD41 CO2, humidity, temperature sensor */ meshtastic_TelemetrySensorType_SCD4X = 32, - /* RADSENS, radiation, geiger-muller tube */ + /* ClimateGuard RadSens, radiation, Geiger-Muller Tube */ meshtastic_TelemetrySensorType_RADSENS = 33 } meshtastic_TelemetrySensorType; @@ -157,7 +157,7 @@ typedef struct _meshtastic_EnvironmentMetrics { /* Wind lull in m/s */ bool has_wind_lull; float wind_lull; - /* Radiation in micro roentgen/hr */ + /* Radiation in µR/h */ bool has_radiation; float radiation; } meshtastic_EnvironmentMetrics; diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index defad40491..a57dcfb5e0 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -214,16 +214,18 @@ void EnvironmentTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiSt // Display "Env. From: ..." on its own display->drawString(x, y, "Env. From: " + String(lastSender) + "(" + String(agoSecs) + "s)"); - String last_temp = String(lastMeasurement.variant.environment_metrics.temperature, 0) + "°C"; - if (moduleConfig.telemetry.environment_display_fahrenheit) { - last_temp = - String(UnitConversions::CelsiusToFahrenheit(lastMeasurement.variant.environment_metrics.temperature), 0) + "°F"; - } + if (lastMeasurement.variant.environment_metrics.has_temperature || lastMeasurement.variant.environment_metrics.has_relative_humidity) { + String last_temp = String(lastMeasurement.variant.environment_metrics.temperature, 0) + "°C"; + if (moduleConfig.telemetry.environment_display_fahrenheit) { + last_temp = + String(UnitConversions::CelsiusToFahrenheit(lastMeasurement.variant.environment_metrics.temperature), 0) + "°F"; + } - // Continue with the remaining details - display->drawString(x, y += _fontHeight(FONT_SMALL), - "Temp/Hum: " + last_temp + " / " + - String(lastMeasurement.variant.environment_metrics.relative_humidity, 0) + "%"); + // Continue with the remaining details + display->drawString(x, y += _fontHeight(FONT_SMALL), + "Temp/Hum: " + last_temp + " / " + + String(lastMeasurement.variant.environment_metrics.relative_humidity, 0) + "%"); + } if (lastMeasurement.variant.environment_metrics.barometric_pressure != 0) { display->drawString(x, y += _fontHeight(FONT_SMALL), diff --git a/src/modules/Telemetry/Sensor/CGRadSensSensor.cpp b/src/modules/Telemetry/Sensor/CGRadSensSensor.cpp index 6f94ffe1fb..4804973c9f 100644 --- a/src/modules/Telemetry/Sensor/CGRadSensSensor.cpp +++ b/src/modules/Telemetry/Sensor/CGRadSensSensor.cpp @@ -1,3 +1,7 @@ +/* + * Support for the ClimateGuard RadSens Dosimeter + * A fun and educational sensor for Meshtastic; not for saftey critical applications. + */ #include "configuration.h" #if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR @@ -12,6 +16,7 @@ CGRadSensSensor::CGRadSensSensor() : TelemetrySensor(meshtastic_TelemetrySensorT int32_t CGRadSensSensor::runOnce() { + // Initialize the sensor following the same pattern as RCWL9620Sensor LOG_INFO("Init sensor: %s", sensorName); if (!hasSensor()) { return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; @@ -27,6 +32,7 @@ void CGRadSensSensor::setup() {} void CGRadSensSensor::begin(TwoWire *wire, uint8_t addr) { + // Store the Wire and address to the sensor following the same pattern as RCWL9620Sensor _wire = wire; _addr = addr; _wire->begin(); @@ -34,6 +40,7 @@ void CGRadSensSensor::begin(TwoWire *wire, uint8_t addr) float CGRadSensSensor::getStaticRadiation() { + // Read a register, following the same pattern as the RCWL9620Sensor uint32_t data; _wire->beginTransmission(_addr); // Transfer data to addr. _wire->write(0x06); // Radiation intensity (static period T = 500 sec) @@ -45,6 +52,8 @@ float CGRadSensSensor::getStaticRadiation() data <<= 8; data |= _wire->read(); + // As per the data sheet for the RadSens + // Register 0x06 contains the reading in 0.1 * μR / h float microRadPerHr = float(data) / 10.0; return microRadPerHr; } @@ -54,7 +63,7 @@ float CGRadSensSensor::getStaticRadiation() bool CGRadSensSensor::getMetrics(meshtastic_Telemetry *measurement) { - LOG_INFO("getMetrics: ClimateGuard RadSense Geiger-Muller Sensor"); + // Store the meansurement in the the appropriate fields of the protobuf measurement->variant.environment_metrics.has_radiation = true; LOG_DEBUG("CGRADSENS getMetrics");