Skip to content

rak4631: cut the serial GPS power with WB_IO2 (opt-in, NMEA path only) - #2

Merged
fdlamotte merged 1 commit into
fdlamotte:gps_refactorfrom
Ve2mrx:rak4631-gps-rail-on-refactor
Nov 8, 2026
Merged

fdlamotte merged 1 commit into
fdlamotte:gps_refactorfrom
Ve2mrx:rak4631-gps-rail-on-refactor

Conversation

@Ve2mrx

@Ve2mrx Ve2mrx commented Nov 8, 2026

Copy link
Copy Markdown

@fdlamotte, as asked on meshcore-dev#3753.

On a RAK19007 base, the RAK12501's power comes from 3V3_S, which WB_IO2 switches. This passes WB_IO2 to the serial
driver as peripheralPower, so gps off, periodic mode and shutdown cut it. It's opt-in, through a new
RAK_4631_repeater_gps_power env that sets GPS_RAIL_POWER_CONTROL, because the same rail powers every other slot module.

  • variants/rak4631/target.cpp: under GPS_RAIL_POWER_CONTROL, a RefCountedDigitalPin on WB_IO2 goes to RakLocationProvider.
    Builds with ETHERNET_ENABLED stop with an error, since the RAK13800 is powered the same way.
  • RakLocationProvider: an optional serialPower argument, passed to NmeaGpsDriver. I2C: the RAK12500 driver already switches
    its own power pin, so this is used on the NMEA path only. If the RAK12500 is found, the serial driver's claim from detect()
    stays, so the rail behaves as it does without the flag.
  • RefCountedDigitalPin: claim() and release() now also set the pin as an output. Measured on this board: WB_IO2 left as an
    input keeps 3V3_S in its last state, and probeRak12500() leaves it as an input after a failed probe. Without this, the release
    writes the output latch only and the rail stays on.
  • variants/rak4631/platformio.ini: the new env.

Tested

RAK WisMesh Repeater Mini v2 (RAK4631, RAK19007, RAK12501 serial L76K, no other slot modules), RAK_4631_repeater_gps_power built
on 2ed19734. ChargerLAB KM003C in line on USB at about 5.11 to 5.13 V, battery and panel disconnected, medians over 20 s or
means over 3 to 15 s between radio peaks.

State gps_refactor at 0388403b This PR
Boot with gps off saved 39.2 mA 11.9 mA
gps on 40.3 to 40.8 mA 37.9 to 39.4 mA
gps off, 4 toggles 40.2 to 40.8 mA 12.4 mA
gps period 60, while waiting 40.9 mA 11.9 mA, ttf:7s/1m ok:7 miss:0
shutdown 29.7 mA 1.30 mA

Also: a fix about 1 min after gps on that set the clock, gps once from gps off (fix, then back to off), and a reboot
with gps off saved (11.9 mA once booted).

Not tested: a RAK12500 (I2C), which I don't have. The stock RAK_4631_repeater and RAK_4631_repeater_ethernet envs still build.

Who did what: I worked on this with Claude Code. I set the requirements, ran the bench and flashed the builds. Claude wrote the
patch, ran the commands and meter readings, and drafted this text, which I reviewed before posting.

🤖 Generated with Claude Code

On a RAK19007 the RAK12501's supply is 3V3_S, switched by WB_IO2, so
gps off, periodic mode and shutdown left it powered. Pass WB_IO2 to the
NMEA driver as peripheralPower under GPS_RAIL_POWER_CONTROL, set by the
new RAK_4631_repeater_gps_power env. It is opt-in because the rail feeds
every slot module, and refused with ETHERNET_ENABLED (RAK13800).

The RAK12500 (I2C) driver keeps switching its own power pin, so this
only applies on the NMEA path.

RefCountedDigitalPin now sets OUTPUT on claim and release: WB_IO2 left
as an input (as probeRak12500() leaves it after a failed probe) keeps
3V3_S in its last state, so writing the latch alone did not cut it.

Measured with a KM003C, battery and panel out: gps off 40.5 -> 12.4 mA,
shutdown 29.7 -> 1.30 mA.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fdlamotte
fdlamotte merged commit af4a41a into fdlamotte:gps_refactor Nov 8, 2026
1 check 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.

2 participants