What is destroying my nanos?

Hi there,

I'm currently building a 12V power System for a max of 20 Amps Output controlled by a Arduino Nano Clone

%product-title% kaufen

It Consists roughly of Solar Cells, a battery and a Backup Power Supply wich is an old, refurbished ATX supply. It now went through many revisions as I'm learning by doing, but it seems I've hit a wall, since I've destroyed 3 Nanos in the last two days.

It should work like this: The Nano gets its power from the 5V sby usb line from the power supply. this line schuld never turn off. Then the nano measures the voltage off the battery. It does that by measuring at A0 where i connected the divided battery voltage.

If it is to low, it turns on the supply on by connecting its power on line to its ground (transistor via D13). Then it turns off the batterie by using a transistor to switch off a relay (with D12).

All parts work fine alone, but they make problems together.

The first Arduino was killed because I accidentally connected the 5V line to a ground pin. oopsie
The second Arduino died Because I didn't had the diode d3. Because of that I connected the battery to my consumers through the Arduino. I was very surprised that the lights suddenly turned on.

But now i don't know what is happening. I connected everything correctly and the system worked fine for a moment but when i tried to upload the non debugging version of the code the chip burned out. So my third and for the point in time last nano went south.

Before i buy new ones I want to get some help by people who might know what they are doing.

What is wrong with my circuit. Is there an easy fix do I need to rethink the whole thing again. I had some "working" solutions before, meaning that nothing got damaged, but for different reasons it wasn't good enough. For example the accuracy of the measurements was really bad.

I sadly can't upload my schematics yet, because I'm a new user.

Here is my source code. I don't think there's anything wrong with it.:

#include <Arduino.h>

int rawVoltage = 0;
const int sampleTime = 120;
const int waitingTime = 1800;
int voltages[sampleTime];
int oldestPoint = 0;
float minVoltage = 11.0;
float startupVoltage = 12.8;
float voltage = 0;
float coefficient = 50.75943001;
bool shutdown = false;

float averageVoltage(){
  float sum = 0;
  for(int i = 0; i < sampleTime; i++){
    sum = sum + voltages[i];
  return sum/sampleTime;

void pushVoltage(int newVoltage){
  voltages[oldestPoint] = newVoltage;

void getVoltage(){
  voltage = averageVoltage()/coefficient;

void setup() {
  //power supply on
  pinMode(13, OUTPUT);
  digitalWrite(13, HIGH);
  //batterie off
  pinMode(12, OUTPUT);
  digitalWrite(12, LOW);

void loop() {


  if(voltage > startupVoltage)
    //batterie on
    digitalWrite(12, HIGH);
    //netzteil off
    digitalWrite(13, LOW); 
    for(int i = 0; i <= sampleTime; i++){
  if (voltage <= minVoltage)
    //netzteil on
    digitalWrite(13, HIGH);
    //batterie off
    for(int i = 0; i <= waitingTime; i++){

Please post a schematic diagram (not Fritzing).

Please identify the components with type and value.

The transistors lack the required base resistors -- you may destroy the Arduino by overloading the output pins.

What does this mean?

How is the ATX supply connected to common ground?

Here is a typical transistor-controlled relay circuit. It would help if you organized your drawing similarly (power and ground at top and bottom, signals move from left to right).


Your base resistors are insufficient.

I'm sorry, I forgot to draw the base resistors. Both bases have a 10k resistor.

I forgot to draw the base resistors but, both have a 10k resistor. the confusing + and - minus in the middle are the point where i take most of the power for my consumers like light and so on. It has no special technical meaning.

The Transistors are CTBC337-25 LS
The diodes are SBX3040

I will try to make a new drawing soon

It’s possible too that the 12v you measure will power the nano through the analog pin if the usb connection is not made and damage it .
You should protect the input from this happening , also a bad connection on the resistor divider can put 12v on this pin and destroy the nano.
Use the 1.1v internal reference too - it us better .
If you have the ref connected to 3.3v and miss the “ext ref” command that can damage the board too .

Don’t ever switch the negative cable ! That can have unexpected results too, in putting too much voltage into the nano

Your circuit switching the relay us wrong - see that nice post example above

Draw schematics with positive supplies at the top and negative at the bottom , try to get the logical flow of what happens going left to right . All negatives in your case should be joined . Again look at the post above .
All these things help your board survive !

Test your circuit without the Nano connected.
If possible use a power supply with both voltage and current limiting.
Start low and work your way up.
Use a multimeter to identify unusual currents on your circuit.
A Nano could switch the National Grid with the right bits in the external circuit.
Losing one is forgivable, but doing it twice again?

I tried to create better schematics. I hope these are sufficient.

A vast improvement, thanks.

What is D3 supposed to do? As shown, it prevents T1 and T2 from being activated by the Arduino. Take another look at the transistor switch shown in reply #4.

Why is there a second GND connection via the relay?

What is the part labeled "Consumer"?

What current does the relay coil require? The 10K base resistor may be too high.

With relay switching, why do you gnd switch the battery?

Why aren't you HIGH side switching the battery?

Connect ALL gnds together and re-think your logic.

Tom... :smiley: :+1: :coffee: :australia:

1 Like

The Consumer "part" represents all the devices i want to run with the 12V System, like lights and a wifi router.

D3 has the following purpose: When the relay switch is open, the nano still connects the grounds of the Battery and the PSU which then allows the consumer to draw a high current through the grounds of the nano. That was what destroyed the second nano. D3 prevents that. I measured it.
It doesn't seem to affect the transistor. They still work. The coil draws around 100mA. With a 10k resistor i should get a max around 400mA. And it works

In fact everything seems to work until the nano dies.

I will do the following:

  1. Change the Position of the relay switch. I will switch the positive side of the batterie instead of the negative. Then i can connect the grounds together. This will prevent all currents through the ground connectors of the nano.

  2. I will switch from the external 3.3V to the internal 1.1V.

But I still desperately want to find out what happened before.

#8 implies that the pi could get ist power through the A0 pin when no other power source for the nano is connected. But when I'm correct, only a few milliamps can flow trough the connected resistors. That can't do harm, right?

I can't completely prevent That the negative side switches off. Under some circumstances the charging-regulator, where i really get the batterie voltage from, except for the measurements connection, can switch off the negative side of the batterie. This should not happen but it probably will once or twice a year and i won't really be able to prevent it.

So what else can i do?

As mentioned, 10k is too high for your base resistors, should be no more than 1k.

You clearly have a fundamental misunderstanding of circuit design, and should abandon this one. Given this misunderstanding, you should buy and use optoisolated relay modules to switch the "consumer" supplies, so that they are electrically separated from the nano. With optoisolated connections, the grounds are separate and independent.

That once was my plan, but I only found modules rated for up to 10 Amps. The Consumers will draw up to 20 AMPs.

I know other solutions that work and I had them before but they are too big for the place I want to install the System.

I'm obviously not an electrical engineer but I'm trying to improve. This is the first time I drew schematics. I've hit a wall and I want to overcome it. Thats why I'm here.

I can change to 1k but it worked with 10 as well.

Thanks for the tip unfortunately as mentioned in 13 I'm not directly connected to the battery but through a charge controller. I will move the switch to the positive side and connect the grounds but the charge controller sometimes switches the negative side as well so I have to find a solution anyway.

I'm not directly connected to the battery but through a charge controller.

What on Earth does that mean?

There are many experts on this forum, but until you can supply a complete and correct schematic of your entire system, including the charge controller, with no mystery parts, you will not get good advice.

I'm out.

The charge controller was in the original schematic. I reduced the circuit and put away the charge controller for now, for a better analysis.

I just wanted to say that in the future i won't be able to always connect all grounds together.