# Voltage regulator getting hot after relay is switched on. Then uController burned after one day of testing

The circuit below aims at switching the relay according to user need while interacting with the display and push buttons. Everything is fine before the relay switches on. But after the relay switched on, the voltage regulator gets very hot. After that, when the program switches the relay off it cools down and everything is fine again.

I thought at the beginnig that I just have to add a heatsink, and went through this question

I measured the current consumption: total current is around: 150 mA. 95mA for Relay. 15mA for the buzzer. 40mA for the Arduino and the rest of the circuit.

After one day of testing, the uController (Arduino nano) burned! What could be the source of the problem and how to solve it?

Components used Arduino nano. Optocoupler CNY17. Pololu 5VDC Relay Board. 128X32 0.96" OLED display. Voltage regulator 7805. voltage Source: Wall adapter, 12V 1A. Electromagnetic Buzzer. BS170Small Signal MOSFET.

Notes: * the relay Module has a freewheeling diode. * I can't use two voltage sources for this application

• You need to add a freewheeling diode antiparallel to your relay connector, thats most probalby the source of your problem. But anyway, also the optocopler is useless here, because you use common ground afterwards and your relay connector doesn't make any sence at all. – HansPeterLoft Jun 18 '18 at 6:12
• The relay module contains a freewheeling diode. See this link link – OlaN Jun 18 '18 at 6:21
• Ok, from your relay board connector it looks like you are feeding your relay over the optocoupler over a 100Ohm resistor and the MOSFET in your module is always on. But that should not be your problem. Have you an oscilloscope, such that you can depict the output voltage of your Regulator? – HansPeterLoft Jun 18 '18 at 6:25
• No I dont't have one. @HansPeterLoft . Anyway, what could I benifit from it? – OlaN Jun 18 '18 at 7:35
• You could see if there are voltage spikes that may damage your Arduino. But anyway, your connection of the relay module is wrong, you should change pin 2 and 3. – HansPeterLoft Jun 18 '18 at 8:04

At a minimum, the 5 VDC power supply must source this amount of current:

I_OUT = Arduino Nano nominal = 19 mA
+ Arduino Nano D2 output current = current into 2N2222 base
+ Arduino Nano D6 output current = current BS170 gate
+ Relay coil = 79.4 mA
+ Buzzer = 70 mA


As a best practice, design the 5 VDC power supply to handle at least 30% more current than the nominal/typical operating current that's drawn from the supply by the project.

Let's assume you've chosen $\beta_{sat}=10$ for the 2N2222 NPN transistor. Therefore, current that must be sourced from the Nano's D2 pin into the NPN transistor's base is:

$$I_{B_{sat}} = \frac{I_{C_{sat}}}{\beta_{sat}} = \frac{I_{C_{sat}}}{10}$$

where $I_{C_{sat}}$ is the transistor's collector current when the transistor is operating in saturation mode (fully "ON").

The value for the NPN transistor's base current limiting resistor is calculated as follows:

$$R_B = \frac{V_{R_B}}{I_{RB}} = \frac{V_{OH}-V_{BE_{sat}}}{I_{B_{sat}}}$$

where $V_{OH}$ is the minimum voltage for a logic HIGH output (~4.2 VDC when the DIO pin is sourcing 20 mA), and $V_{BE_{sat}}$ is the NPN's base-emitter voltage when operating in saturation mode with a collector current of $I_{C_{sat}}$. (Example: If the optocoupler LED current is 50 mA when ON, then $I_{C_{sat}}=50\,mA$, $I_{B_{sat}}=I_{C_{sat}}/\beta_{sat}=50\,mA / 10 = 5\,mA$, and $V_{BE_{sat}}\;(@I_{C_{sat}}=50\,mA)\;\approx 0.7\,VDC$.)

Getting back to the 5 VDC power supply, the power it dissipates is approximately:

$$P_D = \frac{V_{IN}-5\,VDC}{I_{OUT}}$$

where $V_{IN} \approx 12\,VDC -0.6\,VDC = 11.4\,VDC$, and $I_{OUT}$ is as calculated above (including the >=30% headroom). For example, if $I_{OUT}=200\,mA$, then $P_D \approx 1.28\,Watts$. If you perform the heat calculations for these voltage and current conditions, and for an ambient air temperature of 28 °C, the 7805's temperature can reach ~116 °C or more (without a heat sink), which is above the boiling point of water!, which could cause the 7805 to overheat and shut itself down. So yes, you're going to want a heat sink on the 7805. (n.b. My "quickie" calculations show you might try a natural convection heat sink (not a forced air heat sink) whose thermal resistance is no greater than 19.1 °C/W. Don't forget to use thermal grease and an electrical insulator between the 7805 and its heat sink, which adds ~1 °C/W of thermal resistance in the heat flow calculations. And be sure to use a heat sink mounting kit that electrically isolates any metal fasteners—e.g., the metal screw—from the 7805's metal tab which has voltage on it! You don't want the metal screw to transfer the voltage from the 7805's metal tab to the metal heat sink!)

You are drawing 150mA from 12V and your 7805 regulator brings that down to 5V. So you are burning 7V x 0.15 A = 1W on this regulator. 1W on a 7805 can work out, but it needs a heat sink to dissipate the heat. With no heat sink it will overheat and shut down or break.

A better solution would be to use a 12V relay instead and feed it directly from the 12V power source.

The 5V relay (G5LE-14) is rated at 79.4mA @ 5V, so even with it on, so I am not quite sure where 150mA comes from.

With 12V input, 5V output, you are dropping 7 V across the regulator, so ~1W of power is being dissipated in the regulator, a TO220 regulator should be ok, but are you using the 220 version?

I would be using a 12V relay and running it directly off the raw input, also what is that opto supposed to be doing, I don't see the point?

• FWIW, I agree with your comment, "what is the opto supposed to be doing [...]?" The relay already provides some galvanic isolation between the low voltage side (the relay's coil) and its "high voltage" switched circuit; so adding an optocoupler to provide a second/redundant layer of galvanic isolation is questionable and possibly unnecessary. – Jim Fischer Jun 18 '18 at 10:57