AnalogRead couses arduino to restart

Hello,

i have problem with one of my arduinos, runnig code:

#define BUTTON_CHANGE  A5

void setup()
{
  pinMode(BUTTON_CHANGE, INPUT);
  Serial.begin(115200);
  Serial.println("setup");
  delay(100);
}


void loop()
{
  Serial.println("loop");delay(100);
  
  for(;;){  
    Serial.println("beforeAnalogRead");delay(100);    
    //int i = 1;
    int i = analogRead(BUTTON_CHANGE);
    Serial.println(i,DEC);
    delay(10);
  }
}

Meaning dooing just one AnalogRead makes my arduino to restart. When reading serial i receive

setup
loop
beforeAnalogRead
setup
loop
beforeAnalogRead
setup
loop
beforeAnalogRead

Where could be problem?

Should i swap Atmega Chip? Can't there be problem just with fuses or so?

Thank you

Jan

Where could be problem?

It could be that you have something wired wrong. You seem to have forgotten to tell us what is connected to the analog pin, and what other connections you have to the Arduino.

Is it a blue pro mini with dswy_Robot on the back? Those have a capacitor connected wrong that can do that - if that's the one let me know and I'll take a pic or two to show what you need to move to fix it. I don't know if many are still in circulation though.

DrAzzy:
Is it a blue pro mini with dswy_Robot on the back? Those have a capacitor connected wrong that can do that - if that's the one let me know and I'll take a pic or two to show what you need to move to fix it. I don't know if many are still in circulation though.

Yes, it is not, but cheap board from china.

GDrive image

The one i have on my own board and arduinos are OK.

DrAzzy:
Is it a blue pro mini with dswy_Robot on the back? Those have a capacitor connected wrong that can do that - if that's the one let me know and I'll take a pic or two to show what you need to move to fix it. I don't know if many are still in circulation though.

Found this thread:

according to picture:

22p caps are OK.

What caps are wrong?

You ain't gonna believe this.

They have a 0.1uf cap between AVcc and RST. Yup. Instead of AVcc and Gnd. Luckily, you can flip that cap around and use the ground pad of one of the adjacent caps for the crystal.

The AVcc side of the cap should also be connected to Vcc. I just noticed that now.

DrAzzy:
Is it a blue pro mini with dswy_Robot on the back? Those have a capacitor connected wrong that can do that - if that's the one let me know and I'll take a pic or two to show what you need to move to fix it. I don't know if many are still in circulation though.

I found this thread

... will try to move the cap.

Jan

It works, thank you…

My pic is here:

This works great.

Thank you

Jan

DrAzzy:
You ain’t gonna believe this.

They have a 0.1uf cap between AVcc and RST. Yup. Instead of AVcc and Gnd. Luckily, you can flip that cap around and use the ground pad of one of the adjacent caps for the crystal.

The AVcc side of the cap should also be connected to Vcc. I just noticed that now.