Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 8 of 8

Thread: Power ON/OFF with mechanical switch (no external supply)

  1. #1
    Junior Member
    Join Date
    Aug 2018
    Posts
    3

    Power ON/OFF with mechanical switch (no external supply)

    Hi guys,
    I'm completely new to Teensy or actually building any circuits but with the help of internet I am working on a control panel (~20 2-position switches, few buttons and ~20 LED) with Teensy 3.6.
    Tho most of the things needed I already have planned, there is however one I can't find the correct answer for. Every single I found apply to external power.
    The board will get power from USB port only, I have no intentions to add any external power supply. However, I would like to be able to turn on/off the entire panel with one mechanical 2-position switch.
    Is it possible when using USB only? If yes, could you tell me what pins I should use and how exactly step-by-step connect it?

    Regards
    Diego

  2. #2
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,211
    If you strip the USB cable, you'll see 4 wires plus the shield. You can cut the red wire, and put a switch in-between. This will cut/apply the 5V to teensy, which I presume thats what you want switched off.

  3. #3
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,486
    One way to do it is to cut the line between VUSB and VIN (VUSB is the power line from the USB and in the inside row of 4 pins, VIN is the external power line from the Teensy). Once you cut it, you solder a wire from VIN to a mechanical switch, and VUSB on the other side. When the switch is closed, the Teensy gets power, when it is open, it doesn't.

    Unfortunately, VIN and VUSB are not directly next to each other, so you couldn't just put in a 3 pin on-off switch directly on the Teensy (without bending some wires).

    Here is an old discussion of how to do it.


    If you ever think about powering the Teensy with a li-po battery, you can buy this charger that is meant to sit underneath (or on top) of the Teensy. You have to cut the VIN/VUSB solder trace. If there is 5v USB power, it will charge the battery as well as power the Teensy. If there is no USB power, it will use the battery. The charger has an integral on/off switch that cuts power to the Teensy:


    There are other lipo chargers that can be used, but this is convenient because the pin layout is meant to be directly attached to the Teensy, and it has an integral on/off switch.

  4. #4
    Senior Member
    Join Date
    May 2017
    Posts
    208
    Another idea for you: many modern products have a software switch such that the device operates in a very reduced power mode when off but detects when a pushbutton is pressed to turn on/off. You may be able to do something with the sleep library and not have to hack into USB cables.
    https://forum.pjrc.com/threads/28700...etup-Questions

  5. #5
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,486
    If you aren't up to soldering, or advanced programming, a simple approach is to put an on/off cable between the Teensy's USB port and your power source (battery, wall socket, computer). Here is one such device:


    Note such devices usually don't have the ability to pass data, so you would need to replace the cable with a data cable when you want to program the Teensy (this assumes the Teensy isn't connected to the computer to get data from the computer or send data to the computer via USB).

  6. #6
    Junior Member
    Join Date
    Aug 2018
    Posts
    3
    Thank you for all answers.
    Soldering won't be a problem at all.
    Like I said before, my goal is to use power from USB only (panel will stay connected to PC all the time anyway) so the approach with cutting the VUSB from VIN is the best solution in my case.
    Switch will be mounted among the other switches and buttons on front panel of the enclosure for easy access so I will lead the cables from these pins.

    Thank you again for your help, guys.

  7. #7
    Senior Member
    Join Date
    Dec 2016
    Posts
    106
    Quote Originally Posted by DiegoSilva View Post
    Thank you for all answers.
    Soldering won't be a problem at all.
    Like I said before, my goal is to use power from USB only (panel will stay connected to PC all the time anyway) so the approach with cutting the VUSB from VIN is the best solution in my case.
    Switch will be mounted among the other switches and buttons on front panel of the enclosure for easy access so I will lead the cables from these pins.

    Thank you again for your help, guys.
    Why a switch and not using the snooze library to get low power states?

  8. #8
    Junior Member
    Join Date
    Aug 2018
    Posts
    3
    To say it frankly because I didn't dig enough to think it is possible with software.
    I am new to the subject... well I read about some things few years ago already but postponed to go further with the project until now.
    Collecting all info about the circuits, how to connect switches, how to code, design the materials for enclosure. In simple words, I mixed everything up in short time frame now.

    The reason why I do not want to change it now is the fact that I already sent a project to company who will print the front panel layout on PVC and it's too late to make changes.
    However, this isn't a problem for me. There are two separate switches - for panel and LCD screen (re-used from old laptop) - so I will keep it this time this way. However, I will keep in mind the software way for future projects since I'm sure this particular one won't be my last one. :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •