i have several sensors connected to arduino which requires 5v input but larger amp than the arduino is able to supply, so i'm using an external 5v adapter to feed the sensors for power directly.
i wish to control the on/off state of the sensors in order to be able among the rest - reset them.
i can use a 5v to 5v relay, but i wonder if there is a better simpler way to do this without it since the output voltage is low (and no need for 220v supplied by most market relays).
Relays do not supply 220V, the contacts may be capable of switching 220V but that is another matter.
i wish to control the on/off state of the sensors in order to be able among the rest - reset them.
If removing the power resets the sensor then you can do it with a PNP transistor. Emitter to 5V, base to a 1K resistor other end of the resistor to your Arduino output. Collector to sensor's 5V connection and sensor's ground to Arduino's ground.
Grumpy_Mike:
Relays do not supply 220V, the contacts may be capable of switching 220V but that is another matter.
If removing the power resets the sensor then you can do it with a PNP transistor. Emitter to 5V, base to a 1K resistor other end of the resistor to your Arduino output. Collector to sensor's 5V connection and sensor's ground to Arduino's ground.
Base is connected to output pin of the arduino through the 1k resistor, the emitter is connected to 5v (external source power - not the arduino) and the collector is connected to one side of my multimeter. The other side of the multimeter is connected to ground of the external power source.
Turning on off is working good, but the measured voltage is for some reason half the voltage of the power source which is not good for me (the external power source is 5V and I'm getting ~2.5V).
Base is connected to output pin of the arduino through the 1k resistor,
OK
the emitter is connected to 5v
Wrong
the collector is connected to one side of my multimeter
Wrong
The emitter should be to ground. The collector should go to an other resistor, 1K will do. The other end of the resistor goes to the external +5V. The external -ve wire should go to the Arduino ground.
Then your multimeter is connected between the ground and the collector. When the base is low the multimeter will read 5V, when the base is high it will read about 0.7V or less.
it works perfectly. i don't understand the role of the resistor that is connected between the collector to the +5V (although i verified that IT IS required) - can you please explain?
A transistor works by switching current. Without the resistor in the collector there is no current for it to switch.
There must be a voltage across the transistor in order for current to flow without the collector resistor connected to +ve then there is no voltage across the transistor and hence no current can flow.
Base is connected to output pin of the arduino through the 1k resistor, the emitter is connected to 5v (external source power - not the arduino) and the collector is connected to one side of my multimeter. The other side of the multimeter is connected to ground of the external power source.
Which as you see, is very like a PNP top switch but he had no load. Which means even if he had a PNP then it still would not have worked like he expected it to.
Wouldn't it be better to use a 2-transistor high-side switch.
PNP power switch and NPN driver.
Then the sensors will be off when the Arduino is off.
That is not the case with a 1-transistor switch.
With a 1-transistor switch, when Arduino is off and sensor power is on, 4mA is flowing through Arduino's pin protection diode. And that is a bad thing ain't it Mike.
Leo..
Grumpy_Mike:
A transistor works by switching current. Without the resistor in the collector there is no current for it to switch.
There must be a voltage across the transistor in order for current to flow without the collector resistor connected to +ve then there is no voltage across the transistor and hence no current can flow.
i meant - why does it need a resistor there instead of a regular wire?
The ESP module's (+) is connected to the +3.3v power source and (-) to it's ground. At this point all is well, the module works great and the multimeter at these points shows 3.3v.
The problem happens when I'm using the circuit described above (with the transistor):
I'm connecting the multimeter to the collector and ground and getting a reading of 3.3v when the base is low and 0 when it's high. But when I connect the ESP to these points with the multimeter, the voltage suddenly drops to 0.9v which does not power on the module.
For some reason the power output supplied by the circuit's collector and ground behaves differently than the one directly coming out from power source. Is it related to current - does this circuit make the current drop?
The resistor is the load, if you connect the ESP between the collector and ground any current to the ESP has to pass through the resistor. If the ESP takes a lot of current then this will drop the voltage because the collector resistor will not be able to supply it.
How much current does the ESP require and what exactly are you trying to do. This slow disclosure of information is most annoying.
What you want to do is to wire the ESP in place of the collector resistor, that is ESP ground to the collector and +vs to the supply. However an ESP normally has a low current input control you do not normally wire it like this. This is your first mention of an ESP so come clean if you want help. Links to what you are trying to switch.
Why does it matter if I wish to use this kind of circuit for a sensor or other module (like ESP)? I have many uses for it and I'm testing it now with the ESP.
The current general idea is to be able to power off/power on the ESP module from the arduino. It sometimes stops to respond, and I want that the arduino to be able to restart it automatically it in such a case.
The ESP seems to draw ~200ma at peaks from what i've measured.
There is no reason to be annoyed - obviously I didn't feel that there was any slow disclosure and anyway that was definitely not my intention.
You've been handed several good ideas. What exactly is your question, at this point? If you want a general purpose solution, you still need to define the specifications - e.g. maximum current. If that is 200mA, then the answers that were previously given, will likely work. But since you are the designer, it's up to you to cross the t's and dot the i's.