I have a Seeedstudio 433MHz tx/rx that I want to use with Arduino. The transmitter can be powered from 2-12V. Higher voltage, better range according to Seeedstudio.
I am not very good at drawing schematics with Eagle, but I threw together the one below.
I want to power the RF Transmitter with 12V, but not all the time. I want to switch power on and off through a transistor, a BV337-16 in this case. Switching is done through Arduino analog pin 2 (+5V) to collector and transistor emitter to analog pin 3 (GND). There is +12V at the base of the transistor. As soon as pin 2 goes high, the RF module should be powered with 5V.
At least, this is how I planned to do it. Is there anyone who can check the schematic and my explanation above to confirm it's correct?
The transmitter needs about 60mA at 12V and with your transistor's minimum Hfe at 100 you get away with anything less than 7k for a base resistor. That is 2.5k will be just fine.
I just noticed you have drawn a connection from emitter to ana3. There is no need for this - just wire it directly to Arduino ground (common with 12V DC ground).
Ana2 (digital 16) and digital 12 (data) must be set to pinMode output. Also remember the delay (minimum 20ms) from turning on power (ana2 to high) and starting to transmit. If you still have issues (and know the receiver side is good) try with a full second delay (or leave it powered on) before transmitting to rule out power-on time as a possible cause.
There has been no indication that OP was going to refer to the analog pins using the 14+ numbering. I wanted OP to be aware that analog pins are input only.
pinMode(16, OUTPUT); // +5V - Arduino analog pin 2
pinMode(17, OUTPUT); // GND - Arduino analog pin 3
I have 2 functions to power on and power off the rf transmitter:
void powerOff()
{
digitalWrite(16,LOW);
digitalWrite(17,LOW);
}
void powerOn()
{
digitalWrite(16,HIGH); // Pin 2
digitalWrite(17,LOW); // Pin 3
delay(1000); // wait for things to stabilize
}
So, I understand that I should use digital pins? I have been using the same code with analog pin 2 and 3 when I powered the RF transmitter with only 5V. Because at 5V the distance I need is not enough, I switch to 12V by using the transistor.
The Wiichuck adapter uses analog pins 2 and 3 (actually, digital pins 16 and 17) as a tricky way to provide power. There is really nothing special about these particular pins - they are simply adjacent to the I2C pins it needs for communication. Any digital output can safely source (when set to "1") or sink (when set to "0") up to around 20 mA on a continuous basis.
This trick is no longer applicable for you since you now want to use 12V to power the transmitter. You can use a transistor to turn on/off 12V to the transmitter (high side switch) or to connect/disconnect the transmitter's GND pin to Arduino GND and 12V power supply GND (low side switch). Your second schematic is essentially a low side switch (do as BenF said and connect it to GND instead of analog 3) but an NPN transistor is not really appropriate for the job - use a FET. If you use a logic level FET, you can avoid needing external logic to drive the gate.