Posted 29 November 2026
While working with my new vision-enhanced robot, I have noticed that it takes forever to recharge the batteries because the Raspberry Pi5 ‘brain’ draws around 0.4A – more than ten times the current drain from everything else when the motors aren’t running. The Pi5 really isn’t needed during recharge periods (the Teensy monitors charge levels), so I started looking for ways to shut the Pi5 down when the robot is recharging its battery.
A chat with Grok revealed that the Pi5 has no serviceable ‘sleep’ mode, so it looked like I would have to design and fabricate a power switch on the Pi5 power supply line that the Teensy could control. I have some AOD424G 20V/45A N-Channel MOSFET power switches with Rd(on) < 4mΩ left over from another project, so they might do. Unfortunately they require a VDS > 3.3V, so the Teensy 3.5 can’t drive the switch directly – a driver stage would be required.
Then I remembered that the D24V50F5 low-voltage-drop 5V switching regulator has an ENABLE input

that effectively disconnects the load (the Pi5) from the power supply – just what I needed. Even better, the ENABLE line is held high with a 100K pullup resistor, and pulling this line LOW opens the power circuit, meaning it can be driven directly from a normal Teensy GPIO pin.
To test this, I connected an unused wire on my first/second deck connector to Teensy pin 3 (PUR) on the bottom deck to the ENABLE pin on the D24V50F5 module on the second deck and created a small Arduino program to manually switch the ENABLE pin HIGH & LOW. Here’s the Arduino code:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
/* Name: Pi5PwrEnableDemo.ino Created: 11/28/2026 12:17:44 PM Author: Frank */ #define PI_POWER_CTRL_PIN 3 // the setup function runs once when you press reset or power the board void setup() { Serial.begin(115200); delay(2000); pinMode(LED_BUILTIN, OUTPUT); pinMode(PI_POWER_CTRL_PIN, OUTPUT); } // the loop function runs over and over again until power down or reset void loop() { //digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); //Serial.printf("LED is %s\n", digitalRead(LED_BUILTIN) ? "ON" : "OFF"); CheckForUserInput(); delay(500); } bool CheckForUserInput() { //Notes: // 11/21/21 rev to accommodate cmd input from either serial, and output to both // 12/25/21 another try at using pointer for Serial object // 09/19/22 Serial object is now global - no need to figure it out here // 09/25/22 remove if (incomingByte != 0), extend if (gl_pSerPort->available() > 0) to entire function // 09/25/22 chg return type from void to char so 'auto' (Aa) exit can be detected // 09/27/22 back to void type - 'Aa' now soft-reboots the processor // 09/27/22 now this function just grabs character & calls CheckForUserInput(char in_char) // 11/04/23 chg to bool ret value so can use to exit calling while() loop if necessary // 08/07/26 rev to check for input on any serial port //const int bufflen = 20; //10/22/26 rev to handle full-string commands, i.e. 'STUCK_SCAN' const int bufflen = 50; //11/11/26 rev to handle "!OBSTACLE_AHEAD_SCAN" char buff[bufflen]; memset(buff, 0, bufflen); //*byte incomingByte = 0; //moved here 11/21/21 //bool retval = true; //11/04/23 chg to bool ret value so can use to exit calling while() loop if necessary bool retval = false; //09/25/26 chg to 'false' to denote 'nothing avail on either port' situation // 08/07/26 rev to check for input on any serial port if (Serial.available() > 0) { // read the incoming byte: relies on having 'Both CR & LF' enabled at the bottom of the serial port window Serial.readBytesUntil('\n', buff, sizeof(buff)); //*incomingByte = buff[0]; // Convert to uppercase for (uint8_t i = 0; i < strlen(buff); i++) { buff[i] = toupper(buff[i]); } //10/22/26 remove any trailing whitespace trim_trailing(buff); // say what you got: rev 09/25/26 to show entire string Serial.printf("\n%lu: in CheckForUserInput got %s from Serial\n", millis(), buff); if (strcmp(buff, "ON") == 0) { Serial.printf("Got 'ON' from user - enabling Pi5 Power!\n"); digitalWrite(PI_POWER_CTRL_PIN, HIGH); digitalWrite(LED_BUILTIN, HIGH); } if (strcmp(buff, "OFF") == 0) { Serial.printf("Got 'OFF' from user - disabling Pi5 Power!\n"); digitalWrite(PI_POWER_CTRL_PIN, LOW); digitalWrite(LED_BUILTIN, LOW); } } return retval;//11/04/23 chg to bool ret value so can use to exit calling while() loop if necessary } void trim_trailing(char* s) { int len = strlen(s); while (len > 0 && isspace((unsigned char)s[len - 1])) s[--len] = '\0'; } |
And here is a short video showing the Pi5 being powered OFF & ON:
In the video the blue scope trace in the background shows the voltage at the Pi5 5V power pin. The clamping current meter in the foreground shows the Pi5 current draw. The power is first turned OFF, as shown by the voltage drop and the current going to zero. Then the power is turned back ON, and the current meter shows the current stabilizing around 0.4A.
Implementation of this capability will require some handshaking between the Teensy and the Pi5, as killing power to the Pi5 will need to shut down gracefully to avoid potential corruption of SD card files. The sequence will be something like the following:
- Teensy detects Start-of-Charge and sends shutdown message to the Pi5
- Pi5 acknowledges the message and starts an ordered shutdown
- When the Pi5 is in a safe state, it tells the Teensy that it is ready for shutdown
- Teensy pulls the D24V50F5 ENABLE line LOW, and disconnects the Pi5 from +5V
- Teensy detects End-of-Charge and sets the D24V50F5 ENABLE line HIGH, reconnecting the Pi5 to +5V
- Pi5 boots up and resumes normal operation (the exact steps are TBD).
Stay tuned,