Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 47 additions & 2 deletions src/helpers/sensors/EnvironmentSensorManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ static Adafruit_MLX90614 MLX90614;
static Adafruit_VL53L0X VL53L0X;
#endif

#if ENV_INCLUDE_RAK12035
#define TELEM_RAK12035_ADDRESS 0x20 // RAK12035 Soil Moisture sensor I2C address
#include "RAK12035_SoilMoisture.h"
static RAK12035_SoilMoisture RAK12035;
#endif

#if ENV_INCLUDE_GPS && defined(RAK_BOARD) && !defined(RAK_WISMESH_TAG)
#define RAK_WISBLOCK_GPS
#endif
Expand Down Expand Up @@ -331,6 +337,17 @@ bool EnvironmentSensorManager::begin() {
}
#endif

#if ENV_INCLUDE_RAK12035
RAK12035.setup(*TELEM_WIRE);
if (RAK12035.begin(TELEM_RAK12035_ADDRESS)) {
MESH_DEBUG_PRINTLN("Found sensor RAK12035 at address: %02X", TELEM_RAK12035_ADDRESS);
RAK12035_initialized = true;
} else {
RAK12035_initialized = false;
MESH_DEBUG_PRINTLN("RAK12035 was not found at I2C address %02X", TELEM_RAK12035_ADDRESS);
}
#endif

return true;
}

Expand Down Expand Up @@ -483,8 +500,36 @@ bool EnvironmentSensorManager::querySensors(uint8_t requester_permissions, Cayen
}
#endif

}
#if ENV_INCLUDE_RAK12035
if (RAK12035_initialized) {

// RAK12035 Telemetry is Channel 2
telemetry.addTemperature(2, RAK12035.get_sensor_temperature());
telemetry.addPercentage(2, RAK12035.get_sensor_moisture());

// RAK12035 CALIBRATION Telemetry is Channel 3, if enabled

#ifdef ENABLE_RAK12035_CALIBRATION
// Calibration Data Screen is Channel 3
float cap = RAK12035.get_sensor_capacitance();
float _wet = RAK12035.get_humidity_full();
float _dry = RAK12035.get_humidity_zero();

telemetry.addFrequency(3, cap);
telemetry.addTemperature(3, _wet);
telemetry.addPower(3, _dry);

if(cap > _dry){
RAK12035.set_humidity_zero(cap);
}

if(cap < _wet){
RAK12035.set_humidity_full(cap);
}
#endif
}
#endif
}
return true;
}

Expand Down Expand Up @@ -665,7 +710,7 @@ bool EnvironmentSensorManager::gpsIsAwake(uint8_t ioPin){
gps_detected = true;
return true;
}

pinMode(ioPin, INPUT);
MESH_DEBUG_PRINTLN("GPS did not init with this IO pin... try the next");
return false;
Expand Down
1 change: 1 addition & 0 deletions src/helpers/sensors/EnvironmentSensorManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class EnvironmentSensorManager : public SensorManager {
bool SHT4X_initialized = false;
bool BME680_initialized = false;
bool BMP085_initialized = false;
bool RAK12035_initialized = false;

bool gps_detected = false;
bool gps_active = false;
Expand Down
Loading
Loading