Switch controlled by Arduino - Page 1
Forum section: electronics / beginners

author: kingofthehill007
author_rank: Newbie
timestamp: October 08, 2022, 08:35:18 pm
content: Hello,I am trying to turn a 6V pump on using an arduino. My arduino outputs 3.3V. I have an external power source (4 AA batteries in series totaling ~6V)I have read about relays, and they look like a great option for high-voltage applications like things that connect to the power grid. But the concept is amazing and I don't know if something like it exists to use on a smaller scale.I have tried using NPN BJT transistors, but I don't understand the concepts really well, as it is always reducing the current coming from the batteries.How is this problem usually solved?How do you use a low-voltage low-current arduino to close or open a current that is higher voltage and current without affecting or interacting with it?It seems like optocouplers do this but I don't know if they really keep the current and voltage as they are. So just open and close the circuit with the pump and the batteries.Thank you

author: rstofer
author_rank: Super Contributor
timestamp: October 08, 2022, 09:19:21 pm
content: https://www.amazon.com/ICStation-Channel-Optocoupler-Trigger-Development/dp/B01M0E6SQMI would just buy something like this. I have no idea how difficult it might be to get something in Senegal.

author: pcprogrammer
author_rank: Super Contributor
timestamp: October 09, 2022, 05:50:54 am
content: Instead of a NPN BJT transistor try using a N channel MOSFET. These have low on resistance and therefore low voltage drop.https://www.electronics-tutorials.ws/transistor/tran_7.htmlDepending on the current the pump needs you have to select the needed MOSFET. For small currents a 2N7000 can be used.

author: kingofthehill007
author_rank: Newbie
timestamp: October 09, 2022, 07:25:33 am
content: Thank you for your answers.QuoteIn fact, the pump (https://whadda.com/product/mini-peristaltic-pump-6-v-vma447/) doesn't seem to have a "real" datasheet. I could only know that it is "6V and 5W". I did the calculations P = V I and that gave me: current = 833.33 mA.Does this mean that this pump requires 833 mA to function correctly?QuoteI looked at the datasheet for the 2N7000, and I am not sure what to look at for MOSFETs. I saw that the "maximum drain current" is 200.Does that mean that it can at most give out 200 mA?If so I imagine it would be insufficient to power the pump. And if not, what is the value I should be looking at to know if it can output that amount of current?As a side note:This is what confuses me about transistors as switches. It seems like they don't really act as switches if I understood correctly. They act as switches only to some extent, in that they let current flow or not flow. But they change/modify/put a limit on (?) the current flowing out. Instead of just being like aphysical switchthat opens or closes a circuit without affecting the current, i.e. 2 A comes out of the batteries, 2 A will also come out of the switch to reach the pump. In the case of thetransistor as a switchit seems like if 2 A come out of the batteries, only 200 mA come out of the switch, and 1.8 A seems to belostin some sense. (Sorry if this doesn't make sense I can clarify if needed)Thanks again

author: mariush
author_rank: Super Contributor
timestamp: October 09, 2022, 07:46:08 am
content: Here's a tutorial about how to pick a transistor to turn on or off a relay or a solenoid (similar to a relay, still an on/off device):The microcontroller needs to send a small amount of current through the base to emitter and the transistor will allow beta/hFe x your current between the collector and emitter, but usually you want the collector-emitter current much more than what your relay needs to work.You normally want to put a resistor between micro and base otherwise the transistor can burn out like a led but the resistor should be small enough so that you let a few mA go through the base of transistor.An alternative to transistors is mosfets - you don't need a resistor on the gate of the mosfet (the equivalent of base on transistor) but you would want a resistor between the gate and the source of mosfet so that the mosfet's internal capacitor will discharge after your microcontroller no longer sends the signal on the gate pin.One observation I have is that the cheap relays have a default state, and you need to keep powering the relay to have the relay on the other state so you will consume battery.There are a bit more expensive relays which will switch and remain to that position until a new signal is received so basically you would send power to one pin for maybe 3-5 seconds (less time is needed, but 3-5 seconds will guarantee the relay changes) and then the relay is locked in that position. You would have to send power through the other pin to switch the relay to the other position.The complication is that it's difficult to know what state the relay is in when you start your device, so an easy solution for that would be to default to sending the relay a signal each time you start your device, so that you know it's in a known position.

author: hubi
author_rank: Regular Contributor
timestamp: October 09, 2022, 08:24:01 am
content: You could use a DC motor control module (e.g. L298). Cheap, easy to use and you can control the speed of the motor.

author: kingofthehill007
author_rank: Newbie
timestamp: October 09, 2022, 09:06:05 am
content: Quote from: hubi on October 09, 2022, 08:24:01 amThis looks like a good idea, but my arduino outputs 3.3V and this one has "Logic Voltage" as 5 V. I will see if I can find another model that is controlled by lower voltage. If you have any suggestions they are of course much appreciated.Thank you for your answer

author: SmallCog
author_rank: Frequent Contributor
timestamp: October 09, 2022, 09:44:33 am
content: A relay is basically a switch that can be turned on and off with a small amount of electricity.I’d suggest getting a cheap module like this from your chosen marketplace, if only to play with it and learn how they can be used. They can be bought just about anywhere often for less than the one I’ve linked.https://www.ebay.com.au/itm/203114729936?mkcid=16&mkevt=1&mkrid=705-154756-20017-0&ssspo=SzDdJVlNRsG&sssrc=2349624&ssuid=fd5nzGNrSmq&var=&widget_ver=artemis&media=COPY] https://www.ebay.com.au/itm/203114729936?mkcid=16&mkevt=1&mkrid=705-154756-20017-0&ssspo=SzDdJVlNRsG&sssrc=2349624&ssuid=fd5nzGNrSmq&var=&widget_ver=artemis&media=COPY

author: pcprogrammer
author_rank: Super Contributor
timestamp: October 09, 2022, 10:51:12 am
content: Quote from: kingofthehill007 on October 09, 2022, 07:25:33 amYou are looking at it wrongly. When the pump needs 2A you will need a MOSFET that can at least handle the 2A. When you try to control this pump with a 2n7000 it will not limit the current to 200mA, it will happily sink the full 2A until it pops, which it will do. And even when it limits the current due to its internal resistance the "remaining current" just is not there.An IRFZ44NPBF is also a N channel MOSFET that can handle more current, but it might not switch on at 3.3V. In that case it is possible to use the 2n7000 to control the gate of the IRFZ44NPBF like shown in the attached picture.

author: hubi
author_rank: Regular Contributor
timestamp: October 09, 2022, 11:49:08 am
content: Quote from: kingofthehill007 on October 09, 2022, 09:06:05 amThe L298N datasheet specifies 2.3V for logic high, so it should work with a 3.3V arduino directly. The motor driver still requires a 5V supply.