Turn off arduino power using arduino PIN, turn on when 12v is applied - Page 1
Forum section: electronics / beginners

author: scarr999
author_rank: Contributor
timestamp: February 17, 2023, 08:54:57 am
content: Hi All,I want to make a small arduino circuit powered from 12v DC, the circuit has three wires, permenant +12v 2amp, 0v and then a switched +12v inputNormally the arduino is off but When the switcched +12v is turned on a relay is activated and the project is powered, the board remains powered until the arduino turns the relay off. of course if the switched +12v is active at the point of the arduino turning it off it it will simply turn back on again.Added:The +12v input will go through a DC/DC converter outputting +5v for the circuitThe on cycle will be approx 1 hour.Hope I have been clear enough :-)

author: shapirus
author_rank: Super Contributor
timestamp: February 17, 2023, 10:34:47 am
content: If I understand it correctly, you need to google for "soft power off circuit". You'll find a number of usable circuits in the first few links.

author: scarr999
author_rank: Contributor
timestamp: February 17, 2023, 11:15:15 am
content: Hi,I have looked at the soft on circuits but most use a switch to turn on the circuit. I want to use a +12v signal. I will keep looking but any advise would be welcome.

author: TomKatt
author_rank: Frequent Contributor
timestamp: February 17, 2023, 11:23:24 am
content: Have you seen Dave's video on soft power switching?It's usually fairly straightforward to replace a switch with a transistor in many cases. In the video example, a transistor controlled by the Arduino could substitute for the power on switch. Removing power would reset it.

author: shapirus
author_rank: Super Contributor
timestamp: February 17, 2023, 11:49:37 am
content: Quote from: scarr999 on February 17, 2023, 11:15:15 amIf you have a 12V signal, you can always use it to:1) feed the base of a BJT or charge the gate of a MOSFET to deliver a potential (either high or low) where the switch was used to deliver it, thereby preserving the same logic of operation, but this may require slight changes in the schematics;2) power the coil of a relay (directly or via a transistor, depending on the signal's current sourcing capability) whose contacts will directly replace the switch with no schematics change required at all -- and there are some low-power relays available with ~10mA coil current @12V. This is less power-efficient and (arguably) less fun than semiconductors, but easier.

author: Peabody
author_rank: Super Contributor
timestamp: February 17, 2023, 03:02:15 pm
content: Can you solve this in software? After your code turns off the relay through the GPIO output, just go into sleep mode, or an endless loop. If the switched 12V is still active, your Arduino will still be on, but inactive, until the switched 12V finally turns off.

author: scarr999
author_rank: Contributor
timestamp: February 20, 2023, 08:30:32 am
content: Hi,I'll probably get slated but I like the relay option, the only problem is the "switch" is +12v (automotive) arduino is +5v (+12v automotive via DC/DC) I just hope my pathetic attempt isn't too far from working.1, Starts in OFF position no power to DC/DC regulator so no power to arduino2. When 12v "momentary switch" is applied the voltage divider + zenner activate the relay and the permanant 12v feeds the DC/DC regulator powering the arduino3. The arduino takes over and now powers the relay via PNP transistor.4. Arduino starts to count down eventually switching the circuit off.Will this work? / comments please?

author: shapirus
author_rank: Super Contributor
timestamp: February 20, 2023, 06:01:28 pm
content: Quote from: scarr999 on February 20, 2023, 08:30:32 amit won't. arduino needs time to boot and tun on the transistor, and before that can happen, the relay coil will long be unpowered.

author: Peabody
author_rank: Super Contributor
timestamp: February 20, 2023, 06:04:08 pm
content: I don't think so. First, your voltage divider probably won't provide enough current to power the relay coil. Second, when you energize the coil, that will disconnect power to the coil, so the movement of the switches may not be complete, and it may fall back to the off position, and then oscillate.But the main thing is that you're using a single-coil latching relay, which requires reverse current to change to the other state. And there's nothing in your circuit that provides reverse current. So once you turn it on, there's no way to turn it off.You might be able to use a double coil SPDT latching relay, where the state is changed by energizing alternate coils. But if the switched 12V is still active when you want to shut down, you would be applying current through both coils at the same time, with unpredictable results. One thing to look at is passing the 12V switched supply through a series capacitor, which would provide only an initial bump even if that source stays high.But I think you can do all this without an expensive relay. It would require two mosfets, a diode, a capacitor, and some resistors. I'll attach below what that circuit might look like. I think all the resistors could be 100K, and the cap value you would have to determine experimentally. The mosfets would need to tolerate 20V gate voltage. I haven't actually tried the circuit.

author: shapirus
author_rank: Super Contributor
timestamp: February 20, 2023, 06:51:58 pm
content: Doing it with a P-channel MOSFET is really a more elegant solution. But if you still need/want to do it with a relay (for example, you'll need to order the transistor that you don't have, but you have 12V relays in your parts bin), it can be done like this, see schematics.The button on the top is your momentary switch. The button on the bottom is simply for simulation, in reality it will be the arduino pin to be set high to turn power off.How it works: when the momentary switch is pressed, current will flow via D2, R3, R4 and B-E of Q1 and it will turn on, allowing current via the relay coil and C-E of Q1. Once the relay clicks, current from the second 12V source will flow through its contacts via D3, R1, R4 and Q1's B-E, and will keep flowing, keeping Q1 turned on, even when the momentary switch is released. You have your relay and load powered now.Power off: once there is +3.3V (HIGH) at the GPIO pin, current will start flowing via R2 and Q2's B-E, Q2 will turn on and shunt all current away from the base of Q1, making it happily flow through Q2 instead, which will cause Q1 to turn off and power off the relay.The diodes (D2 and D3) are there to isolate the two 12V sources from each other. If it's physically the same source, they are not needed.Something tells me that this circuit wants to be redesigned on only BJTs without a relay. I'll check later, maybe someone can do it before mep.s. will this forum ever stop converting PNGs to jpegs? What a nuisance.

author: sleemanj
author_rank: Super Contributor
timestamp: February 20, 2023, 11:21:33 pm
content: Could put micro into deep dreamless sleep mode with reset normally pulled up, then use the 12v to pull reset momentarily down, reboots micro. Power consumption in "off" state would be more than zero, but not much more.For example....This Falstad Examplethe dangling wire is to the reset pin of the micro. With 12v open it will have about 6v on it pulling it up, with 12v closed it will momentarily pull down causing reset and then rise to about 4.5v, after some 10-20ms or so.Edit to add: of course the 100k+100k divider could be eliminated just there for demonstration, you can pullup to your 5v supply (or use the internal reset pullup, if you trust it...).

author: scarr999
author_rank: Contributor
timestamp: February 21, 2023, 07:52:09 am
content: Quote from: shapirus on February 20, 2023, 06:51:58 pmI like the look of this becuase I can understand it with the help of your explanationTo save board space and reduce components is there a dual NPN transistor package that would do this job that you can point me to?P.S. both 12v's are the same source so we save the two diodes

author: scarr999
author_rank: Contributor
timestamp: February 21, 2023, 08:54:30 am
content: @shapirus Can you take a look at my circuit, I'm trying to use stuff I have to hand.Thanks

author: shapirus
author_rank: Super Contributor
timestamp: February 21, 2023, 09:43:36 am
content: Quote from: scarr999 on February 21, 2023, 08:54:30 amlooks about right, unless I miss something, but don't quote me on this.use realtime simulators, such as Falstad (online) mentioned above, they really help to develop and understand this stuff.p.s. of course the fact that you need to calculate the current that'll flow via each of the transistor pins and elsewhere goes without saying. Check the datasheets and make sure that all the devices will operate within their specs. Also use current/voltage probes in simulation.

author: Peabody
author_rank: Super Contributor
timestamp: February 21, 2023, 02:52:20 pm
content: You show a G6AU relay in your schematic. The datasheet says that's a single coil latching relay. if that's the case, it won't work. It will not turn off when you remove power from the coil. You would have to apply reverse current to turn it off. Do you have a normal relay you could use?Also, it appears you have changed the problem definition. Originally you had what you called the switched 12V supply which might be left on after you wanted to shut down. Now you have a push button switch providing a "momentary" supply. Which is it? If that supply is not turned off, power will turn back on again after the Arduino shuts down and stops sending a high to the second transistor. I thought that's what you were trying to prevent.

author: scarr999
author_rank: Contributor
timestamp: March 01, 2023, 03:24:54 pm
content: @PeaBody Sorry old part uumber it's a G6A-274P-ST-US 12DC non latchingHowever it's not working as I we thought, it powers up but when the MCU turns it of it turns on stright away

author: scarr999
author_rank: Contributor
timestamp: March 01, 2023, 03:25:45 pm
content: Hi,It's not working as I we thought, it powers up but when the MCU turns it off it turns on stright awayThe yellow trace is the +12 into D4 and the Blue is the arduion +5vEDIT: Fixed, Added a cap to the arduino output