Skip to content

Added Sensor RAK12035 Soil Moisture and Temperature#2191

Open
KPrivitt wants to merge 11 commits intomeshcore-dev:devfrom
KPrivitt:main
Open

Added Sensor RAK12035 Soil Moisture and Temperature#2191
KPrivitt wants to merge 11 commits intomeshcore-dev:devfrom
KPrivitt:main

Conversation

@KPrivitt
Copy link
Copy Markdown

A RAK12035 Soil Moisture Sensor will be automatically detected and incorporated into the Telemetry and
can be accessed via the Telemetry screen in a repeater or a companion. The sensor data is displayed on Channel 2.

This code also supports Calibration of a sensor via a custom version of the firmware. See the RAK12035_SoilMoisture.cpp for instructions on the calibration procedure, which uses Channel 3. Calibration must be done to a sensor; each sensor will generate different capacitance output values. Calibration will ensure the reported Moisture will return a value between 0 and 100%.

The RAK12035 Soil Moisture Sensor connects to a RAK12023 which provide three connectors for sensors. This driver only supports one sensor attached with a default I2C address of 0x20. Support can be added for additional sensors via the Set Sensor Address command (which is incorporated). The sensors attached must all have a different I2C address (this can be done by changing an additional sensors I2C address to 0x21 or 0x22) and this code will need to include the initialization of each of these sensors (but this is not included).

@KPrivitt
Copy link
Copy Markdown
Author

This has been tested on a RAK19007 with a RAK12023 and a single RAK12035 (default I2C 0x20) sensor installed. Repeater and Companion versions have been tested and operated correctly for 48 hours.

This has been tested with a RAK1901 and RAK1902 sensor installed which report their data on Channel 1. This sensor reports its data on Channel 2 (there is no conflict)

A RAK12035 sensor was calibrated, and it now reports Soil Moisture percentage (0 - 100%) as well as the Soil Temperature. The displayed % Moisture value changes continuously when inserted into water and taken out and dried. The Temperature changes if it is placed in warm or cold water or held in your hand to warm it up.

@KPrivitt KPrivitt changed the base branch from main to dev April 1, 2026 06:51
@recrof
Copy link
Copy Markdown
Collaborator

recrof commented Apr 1, 2026

you're using main as source branch, can you change it to dev?


#if MESH_DEBUG && ARDUINO
#include <Arduino.h>
#define MESH_DEBUG_PRINT(F, ...) Serial.printf("DEBUG: " F, ##__VA_ARGS__)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MESH_DEBUG_ logging functions are defined in src/MeshCore.h, we probably shouldn't redefine them in a sensor class.

-D ENV_INCLUDE_VL53L0X=1
-D ENV_INCLUDE_BME680=1
-D ENV_INCLUDE_BMP085=1
-D ENV_INCLUDE_RAK12035=1
Copy link
Copy Markdown
Member

@liamcottle liamcottle Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ENV_INCLUDE_RAK12035 will probably need to be moved to the RAK4631 variant platformio.ini instead of global sensors, as it causes compilation errors for other devices, due to RAK WisBlock specific pin defines not existing.

src/helpers/sensors/RAK12035_SoilMoisture.cpp:246:18: error: 'WB_IO2' was not declared in this scope

You can see these errors in the automated tests run against this PR.
https://github.com/meshcore-dev/MeshCore/actions/runs/23731296245/job/69516637482?pr=2191

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants