-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add rak12035 VB Soil Monitor Tested & Working #6741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Justin-Mann
wants to merge
69
commits into
meshtastic:master
Choose a base branch
from
Justin-Mann:AddRAK12035VB_4.19.25
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 61 commits
Commits
Show all changes
69 commits
Select commit
Hold shift + click to select a range
fee9166
[WIP] Add RAK12035VB Soil Moisture Sensor support
fifieldt 37e6769
[WIP] Add RAK12035VB Soil Moisture Sensor support
fifieldt b0ecfb8
Merge branch 'RAK12035VB' of https://github.com/fifieldt/meshtastic-f…
Justin-Mann 0c41f90
[WIP] Add RAK12035VB Soil Moisture Sensor support
fifieldt 3200102
Merge branch 'RAK12035VB' of https://github.com/fifieldt/meshtastic-f…
Justin-Mann 3ca6d2f
[WIP] Add RAK12035VB Soil Moisture Sensor support
fifieldt b88ab86
Merge branch 'RAK12035VB' of https://github.com/fifieldt/meshtastic-f…
Justin-Mann 8562d0c
Merge branch 'master' into RAK12035VB
caveman99 8704c15
Update to 1.0.4 release of RAK12035_SoilMoisture
fifieldt 6f0b083
Merge branch 'master' into RAK12035VB
fifieldt 37c1715
Merge branch 'RAK12035VB' of https://github.com/fifieldt/meshtastic-f…
Justin-Mann e2b6375
cleanup
Justin-Mann 5c721bd
Merge branch 'pr/6259' into AddRAK12035VB_4.19.25
Justin-Mann 492b35a
cool
Justin-Mann 77cd76b
Merge branch 'master' into AddRAK12035VB_4.19.25
Justin-Mann 6f87b6a
Merge branch 'master' into AddRAK12035VB_4.19.25
Justin-Mann adfacf7
.
Justin-Mann 0a3f27b
..
Justin-Mann 440f3fd
little bit of cleanup and recompile/upload/test on RAK WISBLAOCK STAC…
Justin-Mann b33ddfe
. comments about current limitations and TODOs
Justin-Mann b5be032
trunk update
Justin-Mann 07b76e8
trying to autoformat..
Justin-Mann f21235a
fix formatting attempt 2
Justin-Mann 3ca2937
..
Justin-Mann 0b31f6d
...
Justin-Mann 3b642ae
...
Justin-Mann 5bed595
.
Justin-Mann 3f2dd95
some corrections and local build success
Justin-Mann 171ea1b
correction in temp code
Justin-Mann 58d6f64
grr formatting
Justin-Mann ad9bc53
cleanup after a few experiments
Justin-Mann b02e33a
remove temp code to overwrite values for temp and humidity protos.. n…
Justin-Mann 7873fb4
Merge branch 'master' into AddRAK12035VB_4.19.25
Justin-Mann 34b56ef
update some values in varient for rak wistap
Justin-Mann ab0d76f
working out trunk formatting..
Justin-Mann 3fcb2ab
Merge branch 'master' into AddRAK12035VB_4.19.25
Justin-Mann 2b8c791
wip
Justin-Mann 8c9988e
.
Justin-Mann 226ab3c
Merge branch 'master' into AddRAK12035VB_4.19.25
Justin-Mann 911f7f5
Merge branch 'master' of https://github.com/meshtastic/firmware
Justin-Mann 825a17f
Merge branch 'master' into AddRAK12035VB_4.19.25
Justin-Mann 488216a
Merge branch 'master' into AddRAK12035VB_4.19.25
Justin-Mann 5ce965d
Merge branch 'master' of https://github.com/meshtastic/firmware
Justin-Mann ad56c70
Merge branch 'master' into AddRAK12035VB_4.19.25
Justin-Mann fca402c
Merge branch 'master' into AddRAK12035VB_4.19.25
caveman99 4743f15
Merge branch 'master' of https://github.com/meshtastic/firmware
Justin-Mann 9ac7e2e
Merge branch 'master' of https://github.com/meshtastic/firmware
Justin-Mann b41742b
Merge branch 'master' into AddRAK12035VB_4.19.25
Justin-Mann 7529a61
Merge branch 'master' into AddRAK12035VB_4.19.25
Justin-Mann 85aa74c
protobuffs?
Justin-Mann 3eed634
protobufs?
Justin-Mann 5875c8d
Update protobufs ref
thebentern 5f2de80
Merge branch 'master' into AddRAK12035VB_4.19.25
thebentern 480e97d
Merge branch 'master' of https://github.com/meshtastic/firmware
Justin-Mann 6635750
Merge branch 'master' into AddRAK12035VB_4.19.25
Justin-Mann bb7507e
Merge branch 'AddRAK12035VB_4.19.25' of https://github.com/Justin-Man…
Justin-Mann a8e47ee
Merge branch 'master' into AddRAK12035VB_4.19.25
thebentern 3689b86
Protobufs ref
thebentern a9c0654
Trunk
thebentern 14f6c75
Update RAK12035Sensor.cpp
thebentern 0ed4fdf
Fmt
thebentern 5756cab
comment changes
Justin-Mann a6737f5
dumb mistakes... resolved, actually built and tested.. all good..
Justin-Mann d53ffa0
Update src/modules/Telemetry/Sensor/RAK12035Sensor.cpp
thebentern 5bc95eb
Update src/modules/Telemetry/Sensor/RAK12035Sensor.cpp
thebentern 227be11
Merge branch 'master' into AddRAK12035VB_4.19.25
thebentern 8112753
Merge branch 'master' into AddRAK12035VB_4.19.25
thebentern beb525f
Merge branch 'master' into AddRAK12035VB_4.19.25
thebentern 7d4e39d
Merge branch 'master' into AddRAK12035VB_4.19.25
thebentern File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -70,6 +70,7 @@ class ScanI2C | |
DFROBOT_RAIN, | ||
DPS310, | ||
LTR390UV, | ||
RAK12035, | ||
TCA8418KB, | ||
PCT2075, | ||
} DeviceType; | ||
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,109 @@ | ||
#include "configuration.h" | ||
#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR && __has_include("RAK12035_SoilMoisture.h") && defined(RAK_4631) && RAK_4631 == 1 | ||
|
||
#include "../mesh/generated/meshtastic/telemetry.pb.h" | ||
#include "RAK12035Sensor.h" | ||
|
||
RAK12035Sensor::RAK12035Sensor() : TelemetrySensor(meshtastic_TelemetrySensorType_RAK12035, "RAK12035") {} | ||
|
||
int32_t RAK12035Sensor::runOnce() | ||
{ | ||
|
||
LOG_INFO("Init sensor: %s", sensorName); | ||
if (!hasSensor()) { | ||
return DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS; | ||
} | ||
|
||
// TODO:: check for up to 2 additional sensors and start them if present. | ||
sensor.set_sensor_addr(RAK120351_ADDR); | ||
delay(100); | ||
sensor.begin(nodeTelemetrySensorsMap[sensorType].first); | ||
|
||
// Get sensor firmware version | ||
uint8_t data = 0; | ||
sensor.get_sensor_version(&data); | ||
LOG_INFO("Sensor1 Firmware version: %i", data); | ||
|
||
if (data != 0) { | ||
LOG_INFO("RAK12035Sensor Init Succeed"); | ||
status = true; | ||
} else { | ||
LOG_ERROR("RAK12035Sensor Init Failed"); | ||
status = false; | ||
} | ||
sensor.sensor_sleep(); | ||
return initI2CSensor(); | ||
} | ||
|
||
void RAK12035Sensor::setup() | ||
{ | ||
// Set the calibration values | ||
// Reading the saved calibration values from the sensor. | ||
// TODO:: Check for and run calibration check for up to 2 additional sensors if present. | ||
uint16_t zero_val = 0; | ||
uint16_t hundred_val = 0; | ||
uint16_t default_zero_val = 550; | ||
uint16_t default_hundred_val = 420; | ||
sensor.sensor_on(); | ||
delay(200); | ||
sensor.get_dry_cal(&zero_val); | ||
sensor.get_wet_cal(&hundred_val); | ||
delay(200); | ||
if (zero_val == 0 || zero_val <= hundred_val) { | ||
LOG_INFO("Dry calibration value is %d", zero_val); | ||
LOG_INFO("Wet calibration value is %d", hundred_val); | ||
LOG_INFO("This does not make sense. You can recalibrate this sensor using the calibration sketch included here: " | ||
"https://github.com/RAKWireless/RAK12035_SoilMoisture."); | ||
LOG_INFO("For now, setting default calibration value for Dry Calibration: %d", default_zero_val); | ||
sensor.set_dry_cal(default_zero_val); | ||
sensor.get_dry_cal(&zero_val); | ||
LOG_INFO("Dry calibration reset complete. New value is %d", zero_val); | ||
} | ||
if (hundred_val == 0 || hundred_val >= zero_val) { | ||
LOG_INFO("Dry calibration value is %d", zero_val); | ||
LOG_INFO("Wet calibration value is %d", hundred_val); | ||
LOG_INFO("This does not make sense. You can recalibrate this sensor using the calibration sketch included here: " | ||
"https://github.com/RAKWireless/RAK12035_SoilMoisture."); | ||
LOG_INFO("For now, setting default calibration value for Wet Calibration: %d", default_hundred_val); | ||
sensor.set_wet_cal(default_hundred_val); | ||
sensor.get_wet_cal(&hundred_val); | ||
LOG_INFO("Wet calibration reset complete. New value is %d", hundred_val); | ||
} | ||
sensor.sensor_sleep(); | ||
delay(200); | ||
LOG_INFO("Dry calibration value is %d", zero_val); | ||
LOG_INFO("Wet calibration value is %d", hundred_val); | ||
} | ||
|
||
bool RAK12035Sensor::getMetrics(meshtastic_Telemetry *measurement) | ||
{ | ||
// TODO:: read and send metrics for up to 2 additional soil monitors if present. | ||
// -- how to do this.. this could get a little complex.. | ||
// ie - 1> we combine them into an average and send that, 2> we send them as separate metrics | ||
// ^-- these scenarios would require different handling of the metrics in the receiving end and maybe a setting in the | ||
// device ui and an additional proto for that? | ||
measurement->variant.environment_metrics.has_soil_temperature = true; | ||
measurement->variant.environment_metrics.has_soil_moisture = true; | ||
|
||
uint8_t moisture = 0; | ||
uint16_t temp = 0; | ||
bool success = false; | ||
|
||
sensor.sensor_on(); | ||
delay(200); | ||
success = sensor.get_sensor_moisture(&moisture); | ||
delay(200); | ||
success = sensor.get_sensor_temperature(&temp); | ||
Justin-Mann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
delay(200); | ||
sensor.sensor_sleep(); | ||
|
||
if (success == false) { | ||
LOG_ERROR("Failed to read sensor data"); | ||
return false; | ||
} | ||
measurement->variant.environment_metrics.soil_temperature = (float)(temp / 10); | ||
thebentern marked this conversation as resolved.
Show resolved
Hide resolved
|
||
measurement->variant.environment_metrics.soil_moisture = moisture; | ||
|
||
return true; | ||
} | ||
#endif |
This file contains hidden or 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,28 @@ | ||
#pragma once | ||
|
||
#include "configuration.h" | ||
|
||
#if !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR && __has_include(<RAK12035_SoilMoisture.h>) && defined(RAK_4631) | ||
#ifndef _MT_RAK12035VBSENSOR_H | ||
#define _MT_RAK12035VBSENSOR_H | ||
#endif | ||
Justin-Mann marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#include "../mesh/generated/meshtastic/telemetry.pb.h" | ||
#include "RAK12035_SoilMoisture.h" | ||
#include "TelemetrySensor.h" | ||
#include <Arduino.h> | ||
|
||
class RAK12035Sensor : public TelemetrySensor | ||
{ | ||
private: | ||
RAK12035 sensor; | ||
|
||
protected: | ||
virtual void setup() override; | ||
|
||
public: | ||
RAK12035Sensor(); | ||
virtual int32_t runOnce() override; | ||
virtual bool getMetrics(meshtastic_Telemetry *measurement) override; | ||
}; | ||
#endif |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.