Questions about Teensy 4.1, MOSFETs, and ON/OFF Button for Battery-Powered LED Project

Po Ting

Well-known member
Questions about Teensy 4.1, MOSFETs, and ON/OFF Button for Battery-Powered LED Project


Hello community,
I have a few questions regarding using MOSFETs and the ON/OFF button with Teensy 4.1.
Previously, I built a battery-powered addressable LED strip project as a Persistence Of Vision (POV) performance device for flow arts.

It was built using a Teensy 3.6 back in 2018:
https://forum.pjrc.com/index.php?threads/posted-venti-pov-v2-0-80hd.53088/

That setup used the Snooze library and a very minimal hardware design (diagram below). By pulling pin D14 low, it achieved a hibernate current of ~100 µA. Probably due to imperfect hand soldering, but still good enough for a lithium battery project.
1756330006861.jpeg


There were 160 APA102 LEDs in the setup, drawing around ~200 mA when the N-channel MOSFET gate was pulled high and the LEDs were all set to "off."

-----------------------

Upgrading to Teensy 4.1​


Now I’m upgrading my setup to use Teensy 4.1, but I’ve run into some issues:


1. Managing hibernation with MOSFETs
The Snooze library doesn’t provide the same support on T4.1, and in ON/OFF mode the controller doesn’t hold GPIO states like the T3.6/LC did.
I tried a modified setup, but with the ON/OFF pin shutting down the board, I still measured ~6 mA of leakage. From some solder/de-solder testing, it seems the leakage comes from the LED strip’s high voltage flowing back through the SPI pins.
1756330142520.jpeg


I also tried a P-channel MOSFET configuration, but that introduced another leakage path, since the pull-up resistor allowed current to flow through the Teensy.

1756331112726.jpeg

I don’t have much experience with these power arrangements, so I’d appreciate any references or shared experience from others who’ve solved similar problems.


2. Sharing a switch between GPIO and ON/OFF
I’d like to connect a single switch to both a GPIO pin and the ON/OFF pin, so that:
  • A short click can be detected as user input.
  • A long press would power off (hibernate).
  • A short press again would wake the device.
So it may share similar behavior with my button control setting in my T3.6 project, with hardware on/off replacing the snooze hibernation.

1756331678477.png


However, in practice it only works once and doesn’t wake up again properly. Debouncing also seems to be an issue.
Has anyone successfully implemented this kind of dual-use button with T4.1?


3. Controlling ON/OFF via GPIO in software
If I connect the ON/OFF pin to a GPIO somehow, is it possible to simulate a button press in software (pulling the pin low) to power off the Teensy?


4. Other approaches
If there are alternative hardware methods or recommended practices for power management and hibernation on Teensy 4.1, I’d be very grateful to hear them.




Thanks in advance for any insights or advice!
 
There was some discussion about the ON/OFF feature not too long ago. Might want to review.
ON/OFF GPIO control
Power ON/OFF
For software control - emulation of the ON/OFF button look at this to see if it helps: https://github.com/FrankBoesing/T4_PowerButton

That will allow turning it of using that pin, and may point to a way in software to turn it off. It will only wake using the On/Off pin as long as it has power once set to OFF.
Thank you, this is helpful in some way:
I can imply the software OFF in my cycle so that it could close when idle for minutes or user press.
My previous hibernate is coded to press for 2 seconds, much shorter than 5 of the ON/OFF.

But in my case, my device would only have an exposed button, which serves as user input and cannot avoid connected to a GPIO.
I probably need that button for ON/OFF wake purpose too, so it still have to be wired.

Not sure if resistors and diode could do that...
I sudden think of dual tactile button? not sure what it calls, but there's some hardware, when pressed, connects individual 2 paths/2 pair of points, like A to B and C to D. But not sure if there's a 6mm*3mm size😂
 
Last edited:
Good luck. Thanks to @BillFM for the links to the now left 2 years ago - they may add more info.
That library by @Mcu32 (Frank B) shows some useful details. The button press goes to code it can respond instantly, or a delayed press could be handled differently. And the On/Off press time for Off can be adjusted IIRC.
 
What about a power latching circuit with push button reading

With power button held down, circuit will always turn on.
As Microcontroller boots up, first thing you do is MC_Latch_On pin to high

When everythings on If you press the button , MC_Button_Sense will go low. record if it goes low for say 2 seconds. then set MC_Latch_On pin to low and everything will turn off when the button is released.
 

Attachments

  • Capture.PNG
    Capture.PNG
    39.9 KB · Views: 61
What about a power latching circuit with push button reading

With power button held down, circuit will always turn on.
As Microcontroller boots up, first thing you do is MC_Latch_On pin to high

When everythings on If you press the button , MC_Button_Sense will go low. record if it goes low for say 2 seconds. then set MC_Latch_On pin to low and everything will turn off when the button is released.
Thank you, this look exactly useful, I remember seeing this design on some other LED product in the flow art market...
I'll think of a way soon and see if it fits
 
1757212246883.png

Inspired by the power latch, I'll add a N-channel mos to my P-channel mos setup up there, I only had 10k or 1M ohm resistor with me so not sure if it's working properly

1757212359410.png

The button : This setup I still rely on the on/off button, hopefully it'll work
 
1762006673053.png

Currently somewhat working with this design,
not stable and sometimes stall with LED lighting on, probably resistance over my probes...
and low voltage since It's powered directly by lithium battery but not a 5V boosted

I'll revise again when it's a full product, it should be working with solderer wires I guess..
 
Back
Top