-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DFRobot Lark weather station support (#4032)
* DF Robot Lark weather station support * Missed it * I am a man of const char sorrow... * Strang * Use our fork
- Loading branch information
1 parent
b43c7c0
commit a218c6f
Showing
10 changed files
with
191 additions
and
3 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
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
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,53 @@ | ||
#include "configuration.h" | ||
|
||
#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR | ||
|
||
#include "../mesh/generated/meshtastic/telemetry.pb.h" | ||
#include "DFRobotLarkSensor.h" | ||
#include "TelemetrySensor.h" | ||
#include "gps/GeoCoord.h" | ||
#include <DFRobot_LarkWeatherStation.h> | ||
#include <string> | ||
|
||
DFRobotLarkSensor::DFRobotLarkSensor() : TelemetrySensor(meshtastic_TelemetrySensorType_DFROBOT_LARK, "DFROBOT_LARK") {} | ||
|
||
int32_t DFRobotLarkSensor::runOnce() | ||
{ | ||
LOG_INFO("Init sensor: %s\n", sensorName); | ||
if (!hasSensor()) { | ||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; | ||
} | ||
|
||
lark = DFRobot_LarkWeatherStation_I2C(nodeTelemetrySensorsMap[sensorType].first, nodeTelemetrySensorsMap[sensorType].second); | ||
|
||
if (lark.begin() == 0) // DFRobotLarkSensor init | ||
{ | ||
LOG_DEBUG("DFRobotLarkSensor Init Succeed\n"); | ||
status = true; | ||
} else { | ||
LOG_ERROR("DFRobotLarkSensor Init Failed\n"); | ||
status = false; | ||
} | ||
return initI2CSensor(); | ||
} | ||
|
||
void DFRobotLarkSensor::setup() {} | ||
|
||
bool DFRobotLarkSensor::getMetrics(meshtastic_Telemetry *measurement) | ||
{ | ||
measurement->variant.environment_metrics.temperature = lark.getValue("Temp").toFloat(); | ||
measurement->variant.environment_metrics.relative_humidity = lark.getValue("Humi").toFloat(); | ||
measurement->variant.environment_metrics.wind_speed = lark.getValue("Speed").toFloat(); | ||
measurement->variant.environment_metrics.wind_direction = GeoCoord::bearingToDegrees(lark.getValue("Dir").c_str()); | ||
measurement->variant.environment_metrics.barometric_pressure = lark.getValue("Pressure").toFloat(); | ||
|
||
LOG_INFO("Temperature: %f\n", measurement->variant.environment_metrics.temperature); | ||
LOG_INFO("Humidity: %f\n", measurement->variant.environment_metrics.relative_humidity); | ||
LOG_INFO("Wind Speed: %f\n", measurement->variant.environment_metrics.wind_speed); | ||
LOG_INFO("Wind Direction: %d\n", measurement->variant.environment_metrics.wind_direction); | ||
LOG_INFO("Barometric Pressure: %f\n", measurement->variant.environment_metrics.barometric_pressure); | ||
|
||
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,24 @@ | ||
#include "configuration.h" | ||
|
||
#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR | ||
|
||
#include "../mesh/generated/meshtastic/telemetry.pb.h" | ||
#include "TelemetrySensor.h" | ||
#include <DFRobot_LarkWeatherStation.h> | ||
#include <string> | ||
|
||
class DFRobotLarkSensor : public TelemetrySensor | ||
{ | ||
private: | ||
DFRobot_LarkWeatherStation_I2C lark = DFRobot_LarkWeatherStation_I2C(); | ||
|
||
protected: | ||
virtual void setup() override; | ||
|
||
public: | ||
DFRobotLarkSensor(); | ||
virtual int32_t runOnce() override; | ||
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; | ||
}; | ||
|
||
#endif |