-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix detection of lark weather station and add rain sensor (#5874)
* fix detection of lark weather station * fix unit tests and add support for Dfrobot rain gauge * fix name display on bootup * fix gauge init logic * trunk fmt
- Loading branch information
Showing
9 changed files
with
105 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,6 +126,7 @@ lib_deps = | |
mprograms/[email protected] | ||
dfrobot/[email protected] | ||
https://github.com/meshtastic/DFRobot_LarkWeatherStation#4de3a9cadef0f6a5220a8a906cf9775b02b0040d | ||
https://github.com/DFRobot/DFRobot_RainfallSensor#38fea5e02b40a5430be6dab39a99a6f6347d667e | ||
robtillaart/[email protected] | ||
|
||
; Health Sensor Libraries | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include "configuration.h" | ||
|
||
#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR | ||
|
||
#include "../mesh/generated/meshtastic/telemetry.pb.h" | ||
#include "DFRobotGravitySensor.h" | ||
#include "TelemetrySensor.h" | ||
#include <DFRobot_RainfallSensor.h> | ||
#include <string> | ||
|
||
DFRobotGravitySensor::DFRobotGravitySensor() : TelemetrySensor(meshtastic_TelemetrySensorType_DFROBOT_RAIN, "DFROBOT_RAIN") {} | ||
|
||
int32_t DFRobotGravitySensor::runOnce() | ||
{ | ||
LOG_INFO("Init sensor: %s", sensorName); | ||
if (!hasSensor()) { | ||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; | ||
} | ||
|
||
gravity = DFRobot_RainfallSensor_I2C(nodeTelemetrySensorsMap[sensorType].second); | ||
status = gravity.begin(); | ||
|
||
return initI2CSensor(); | ||
} | ||
|
||
void DFRobotGravitySensor::setup() | ||
{ | ||
LOG_DEBUG("%s VID: %x, PID: %x, Version: %s", sensorName, gravity.vid, gravity.pid, gravity.getFirmwareVersion().c_str()); | ||
} | ||
|
||
bool DFRobotGravitySensor::getMetrics(meshtastic_Telemetry *measurement) | ||
{ | ||
measurement->variant.environment_metrics.has_rainfall_1h = true; | ||
measurement->variant.environment_metrics.has_rainfall_24h = true; | ||
|
||
measurement->variant.environment_metrics.rainfall_1h = gravity.getRainfall(1); | ||
measurement->variant.environment_metrics.rainfall_24h = gravity.getRainfall(24); | ||
|
||
LOG_INFO("Rain 1h: %f mm", measurement->variant.environment_metrics.rainfall_1h); | ||
LOG_INFO("Rain 24h: %f mm", measurement->variant.environment_metrics.rainfall_24h); | ||
return true; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#pragma once | ||
|
||
#ifndef _MT_DFROBOTGRAVITYSENSOR_H | ||
#define _MT_DFROBOTGRAVITYSENSOR_H | ||
#include "configuration.h" | ||
|
||
#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR | ||
|
||
#include "../mesh/generated/meshtastic/telemetry.pb.h" | ||
#include "TelemetrySensor.h" | ||
#include <DFRobot_RainfallSensor.h> | ||
#include <string> | ||
|
||
class DFRobotGravitySensor : public TelemetrySensor | ||
{ | ||
private: | ||
DFRobot_RainfallSensor_I2C gravity = DFRobot_RainfallSensor_I2C(nodeTelemetrySensorsMap[sensorType].second); | ||
|
||
protected: | ||
virtual void setup() override; | ||
|
||
public: | ||
DFRobotGravitySensor(); | ||
virtual int32_t runOnce() override; | ||
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; | ||
}; | ||
|
||
#endif | ||
#endif |