Skip to content

Added RAK12035 Soil Moisture and Temperature Sensor#2223

Merged
liamcottle merged 18 commits intomeshcore-dev:devfrom
KPrivitt:2026/RAK12035
Apr 3, 2026
Merged

Added RAK12035 Soil Moisture and Temperature Sensor#2223
liamcottle merged 18 commits intomeshcore-dev:devfrom
KPrivitt:2026/RAK12035

Conversation

@KPrivitt
Copy link
Copy Markdown

@KPrivitt KPrivitt commented Apr 1, 2026

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 KPrivitt changed the base branch from main to dev April 1, 2026 21:02
@KPrivitt KPrivitt closed this Apr 1, 2026
@KPrivitt KPrivitt reopened this Apr 1, 2026
@KPrivitt KPrivitt changed the title 2026/rak12035 Added RAK12035 Soil Moisture and Temperature Sensor Apr 1, 2026
@KPrivitt
Copy link
Copy Markdown
Author

KPrivitt commented Apr 1, 2026

Changed PR #2191 to use dev as the base. Removed platformIO.ini and added
-D ENV_INCLUDE_RAK12035=1 to variants/platformIO.ini

It still compiles correctly for the RAK4631 versions but, is it still getting errors from the Heltec_v3 due to the mismatched pin numbering.

Since it is not possible to connect a RAK12035 to a Heltec (they do not have the connector), it will never be detected, and this code will not be utilized.

I can conditionalize it, but I'm not that familiar with the Heltec V3. I found the pin they use to control their 3v3 supply. All RAK boards use IO2 to control 3v3_S, but the EnvironmentSensorManager rakGPSInit() is incorrectly is using IO4 and IO5. These are actually the *reset signal for the RAK12500 GNSS GPS Location unit. The RAK12035 uses the IO4 as its *reset input.

#if defined(ARDUINO_RAK4631) || defined(PLATFORM_RAK_WISBLOCK)
#define SENSOR_PWR_PIN WB_IO2
#define SENSOR_RST_PIN WB_IO4

#elif defined(ARDUINO_HELTEC_WIFI_LORA_32_V3) || defined(HELTEC_V3)
// Heltec V3 uses Vext for 3V3 peripheral power
#define SENSOR_PWR_PIN Vext
// Heltec V3 does not have a reset pin for sensors
#define SOIL_RST_PIN GPIO4 // I believe this is a General Purpose I/O and is not tied to anything

#else
#error "Unsupported board: define SOIL_PWR_PIN and SOIL_RST_PIN"

OR should I conditionalize each use of the WB_IO2, WB_IO4 with
#ifdef RAK_WISBLOCK_GPS
pinMode(ioPin, OUTPUT);
digitalwrite(ioPin, HIGH);
#endif

OR I can comment all of them out, the purpose of this code is to turn off the 3v3_S when the sensor is put to sleep and to turn the power back on when it is woken up.
But MeshCore does not have any power management for sensors yet. I put this in for a possible sensor power management controller that would signal sensors to power on and reinitialize themselves.

@KPrivitt
Copy link
Copy Markdown
Author

KPrivitt commented Apr 2, 2026

This now compiles correctly for Heltec v3 versions.

I commented out all the uses of pinMode() and digitalWrite() and included comments on what the intended functionality was for. This was intended for when a future sensor power management is implemented. None of the routines affected were utilized, so this did not affect the functionality.

The unutilized routines were added to provide the following functionality:

  1. To put the sensor into sleep mode, optionally to turn the 3v3_S power off to obtain even lower power draw.
  2. To turn the power back on, properly reset the sensor and verify it will respond to commands

These can be uncommented and potentially used with future sensor power management firmware. At that time, it will require modifications to utilize the pinMode() and digitalWrite() functions with a Heltec v3. The errors will return when the comments are removed.

@KPrivitt
Copy link
Copy Markdown
Author

KPrivitt commented Apr 2, 2026

Should I close PR #2191

with:
github_token: ${{ secrets.GITHUB_TOKEN }}
cname: docs.meshcore.nz
cname: docs.meshcore.io
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This has already been update in the main branch

Copy link
Copy Markdown
Author

@KPrivitt KPrivitt Apr 2, 2026

Choose a reason for hiding this comment

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

Do I need to remove this? I did not make this change. I believe it appeared when I moved to the dev branch from main. How do I fix this?

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.

These changes are probably being pulled in because @KPrivitt made their changes against the main branch in their local environment, and then changed the base branch to dev in the GitHub UI.

Ideally, users should check out the dev branch locally, and make changes against that.

You should be able to fix this PR by performing a rebase of your local 2026/RAK12035 branch against the dev branch and then force push it.

The reason the extra commits show up, is because your local branch is based on main which has these new commits that don't yet exist in the dev branch.

It's not really a big deal, and we could merge as is, it would just create duplicate commits, but it's cleaner for the history if you rebase the branch.

@ripplebiz
Copy link
Copy Markdown
Collaborator

Should I close PR #2191

Yes. This PR looks fine. Ready to merge once that unneeded yaml change is reverted.

@KPrivitt
Copy link
Copy Markdown
Author

KPrivitt commented Apr 2, 2026

#2191 has been closed.

This is my first PR, how do I revert this?

@KPrivitt
Copy link
Copy Markdown
Author

KPrivitt commented Apr 2, 2026

Here are screen shots of Channel 1, which has two other sensor cards that are plugged in and their data shown

image

Channel 2, which is this new sensor and its data shown

image

Soil Moisture and Soil Temperature

Copy link
Copy Markdown
Author

@KPrivitt KPrivitt left a comment

Choose a reason for hiding this comment

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

I believe the rebase worked. It appears that it is no longer included but it is now shown as a comment. Let me know if I still need to do something.

PS C:\Users\kenpr\Documents\MeshCore\MeshCore-dev> git rebase --continue

[detached HEAD e7b9401] RAK12035: Rebase to resolve YAML changes
1 file changed, 33 insertions(+), 2 deletions(-)
dropping 0423729 Remomve redefinition of MESH_DEBUG_PRINT/LN -- patch contents already upstream
Successfully rebased and updated refs/heads/2026/RAK12035.
PS C:\Users\kenpr\Documents\MeshCore\MeshCore-dev> git push --force-with-lease

Everything up-to-date

@KPrivitt KPrivitt reopened this Apr 2, 2026
@KPrivitt
Copy link
Copy Markdown
Author

KPrivitt commented Apr 2, 2026

There are now only the five that were updated or changed, and it is now pointing to meshcore-dev:dev

This was a disaster, the rebase failed and I had to basically start over. All the changes I had
previously done to get it to compile clean were lost and were regenerated. Well at least
the comments are now better.

Please recheck, I verified that it compiles for the RAk4631 and Heltec v3
So, everything should now be ready to merge.

@liamcottle
Copy link
Copy Markdown
Member

Thanks for the rebase, tests appear to be passing now that the include flag has moved to the RAK variant.

The commit log is now 18 commits long, so I'll squash these during merge so there's only 1 commit in the project history.

Thanks for contributing!

@liamcottle liamcottle merged commit 27f7326 into meshcore-dev:dev Apr 3, 2026
9 checks passed
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