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

Thread: How to enable/disable Bluetooth module using digital pin

  1. #1
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    220

    How to enable/disable Bluetooth module using digital pin

    Hi

    For the next part of my project I am using a Bluetooth module:

    http://www.lctech-inc.com/Hardware/D...d-4d58c2b3c0cb

    I have connected this to the hardware serial port 1 of the Teensy 3.0 I am using and can send and recieve without issue. What I would now like to be able to do is turn the module on or off using a digital pin when I can not easily access it in its enclosure.

    My project currently uses a TFT display with touch screen and also a micro SD card using the PJRC adaptor. I think, at a glance, I am now down to my last two digital pins so after this I have little room for adding much else.

    The connections to the Bluetooth module are simply as follows:

    GND
    3.3
    5.0
    TXD
    RXD
    KEY

    I am using this to display debug output using Bluetooth and have it connected to the Teensy 3.0 as follows:

    GND - Teensy 3.0 GND
    For power, either/or (Both work):
    3.3 - Teensy 3.3V
    or
    5.0 - Teensy Vin
    RXD - Teensy 3.0 TX1 (Pin 1)

    So rather than connecting the power to 3.3V or Vin I would like to drive it from a digital pin. I guess I need to use a transistor to switch the module but I am unsure and I am looking to the community for guidance. It is a long time since I had to switch my mind to such things and I find a void between my ears.

    What I am looking for is what components I would need and the circuit diagram. My guess is just a transistor and maybe a resistor or is there a pin capable of supplying the required current? Specifcation seems to show "working current: pairing 20 ~ 30MA, paired 8MA."

    Can you help?

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,918
    I would try using a PNP transistor. A 2N3906 or similar should work. Connect the emitter to +3.3V from the Teensy, the collector to +3.3 volts on the bluetooth module. Connect the base to a 4.7k resistor, and the other side of the resistor to the digital pin that will control the power.

    To turn the module on, use digitalWrite(pin, LOW). Use Serial.begin() after the module is powered up. You might need a delay before actually communicating, if the module takes time to start up.

    To turn the module off, first use Serial.end(), and then digitalWrite(pin, HIGH) to turn the transistor off. It's important to first call Serial.end(), so the 2 signals do not try to drive a voltage into the module when you shut the power off.

    If the RX and TX pins do not go to zero volts when the power is off, you might try using pinMode and digitalWrite on those pins to force them to zero volts.
    Last edited by PaulStoffregen; 03-13-2013 at 12:26 AM.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,918
    You could also try using a P-channel mosfet. Most of them require 5 or 10 volts on their gate. You'll need one that works with only 3.3 volts. The FDV304P is a good choice. Connect it the same way, where emitter = source, collector = drain, and base = gate. For very small mosfets like the FDV304P, the 4.7K resistor is not necessary (but will work fine if used). For larger mosfets that have huge gate capacitance, you do need a resistor to limit the current when turning the transitor on and off.

  4. #4
    Senior Member
    Join Date
    Nov 2012
    Location
    Chipping Norton, UK
    Posts
    220
    Paul, as ever thanks for the quick and concise response. I know of no better customer service than yours

Posting Permissions

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