I have done the getting started tutorial, and ultimately I am trying to make a solenoid lock that can be accessed by a keypad. I found this basic tutorial on triggering a solenoid lock with Tinker:
But I am not clear on the wiring, because his directions are probably aimed at slightly more advanced users.
I hate to just say “please explain this to me”, but any help would be appreciated. I have tried to figure it out but am a bit lost.
So I found this tutorial and it helped shed a lot of light on the subject:
My first question now is how did the authors of the tutorial come up with the resistor value to use? One author used a 1K resistor and the second author used a 2k resistor. The transistor and diodes were the same.
Was it due to the different voltages of the solenoids they chose to use? How does one determine the appropriate resistor in this scenario?
With a transistor as a switch the base resistor’s value isn’t that important, you just need to limit it to a safe value for the output pin.
The main intent here is to fully open/“shut off” the transistor, which is achieved via the output voltage greater/less (by enough margin) than the forward voltage of the base emitter diode (0.3~0.7V depending on transistor material) - which will be easily achieved with 3.3V/0V (HIGH/LOW).
That also shows in the chosen resistors of your two samples.
The Arduino project uses a 1k despite the higher 5V output of the Arduino pins (5mA base current), while the Photon project went for 2k with 3.3V output voltage (1.65mA).
Thanks for your help. I understand what you are saying overall but am getting lost in the details.
For my education please bare with me.
What is the forward voltage of the resistor they both chose (TIP12 )? How did you determine this forward voltage?
I understand if the high voltage of Photon is 3.3V and your resistor is 2k, then you used Ohms law V=IR to calculate 1.65mA of current is getting to the transistor. So if we used a 1k resistor then 3.3mA of current would go to the transistor and that would be fine too.
So what resistor value would not be acceptable?
You would get the forward voltage out the datasheet, but since you’ll be well beyond that either way with your logic levels, you don’t need to bother.
And about the resistor, I’d go with the bigger one to save power (as long as the transistor switches it’s fine).
Don’t make things overcomplicated - if it doesn’t matter, don’t need to care
Not acceptable would be a too high value which wouldn’t switch the TR or a too low one that would exceed the 25mA pin rating.
Thank you ScruffR
So for powering the solenoid, if I got this power supply:
and used this solenoid lock (12v 1amp)
Would I need to get a 12K resistor for that circuit (1amp = 12v/12ohms)?
The resistor is placed between the controling output pin of the Photon and the Base pin of the transistor and is never to come in contact with 12V.
Just go with the 2K (or 1K or whatever you have around in that area)!
I thought you had seen and understood the schema of the two links in your OP.
I don’t see any resistor in series with the solenoid.
The only other component (apart of the TR and supply) connected to the solenoid is the flyback diode.
BTW, 12K (12.000Ohm) resistor would give you 12mA, hardly enough to pull the solenoid. And if you used a 12Ohm resistor, that would get rather warm burning up 12W (12V * 1A).
One thing I’d change in those circuits. I’d put an opto isolator between the Photon and the transistor, to keep the GND lines seperated too.
Regarding the 12k resistor question. I had a fundamental misunderstanding of the circuit which led to that question. I get it now. Thanks
I looked up what an opto isolator is, but I don’t see how it relates to keeping GND lines separated.
Can you explain further what you mean by keeping the GND lines separated?
@CS_know_nothing, all voltages are measured in reference TO something which is typically a circuit’s ground (GND). Having two circuits powered by different supplies (the Photon at 3.3v and the solenoid at 12v) requires that both GND be tied together to create a common reference OR that the ground be isolated somehow. The isolation is often desired if there is concern that one circuit may be “noisy” such as the solenoid which can create spikes on its supply and possibly on its ground.
In order to isolate the grounds, an opto-isolator uses light to carry the signal from one circuit to the other. So one side of the opto-isolator (the LED side) connects to the Photon’s GPIO pin and GND and the other side (the transistor side) connects to the transistor that controls the 12v going to the solenoid the the GND of the 12v supply. This keeps the grounds of the two circuits separate but also allows both side to interact. This type of isolation is commonly used to separate high and low voltage circuits. Hope that helps!
that helped A LOT. Thank you.