Breadboard Arduino keeps restarting

I've build a simple clock/thermometer that outputs its data to a 16x1 LCD. No advanced stuff there. At first I used an UNO and everything worked fine. As I want to create a PCB for this project, I pulled out the ATMEGA and breadboarded it.

(linked because the images are too big)



Up-to-date code can be found here: infopanel.ino · GitHub

  1. DS1307 RTS Breakout, uses I2C. I've already added 2 4k7 pull-up resistors not on the photo. This module appeared to work fine with the arduino's internal pull-ups, but added them just to be sure.
  2. LCD (16x1), not much special going on here
  3. TMP36 sensor, it uses 3.3V, more on that later.
  4. ATMEGA, 10k Pull-Up for reset. I have replaced the 10uF cap with a 0.1uF one. AREF is supplied with 3.3V (for the TMP36)
  5. 16Mhz crystal with caps. Tried it right next to the atmega as well, no difference.
  6. No fully photographed, but here is a low-pass RC filter and a transistor to adjust contrast and backlight of the LCD using PWMs.
  7. Divide 5V into 3.3V using a 1k8 and 3k6 resistor. Used for AREF and the TMP36 sensor.
  8. 7805, incl. two 10uF caps, seems stable enough.
  9. Power-on LED
  10. Unused, but attached to pins 11-13 for a ICSP connection.

For some reason, after connecting power, the system starts up (I see the initialization tests I wrote on the LCD), the it starts displaying time. After taking 10 tmp samples it wants to display the tmp as well, but this is when the whole thing restarts.

I have not been able to find any voltage drop coming from the 7805.

I've also tried disconnecting the 7805 and powering everything through a supplemental arduino board over USB, the same thing happens.

I'm at a loss at what could be wrong. How do I start troubleshooting this? Are there any common causes for resets to happend (except brown outs and a floating reset pin?)

Thanks!

you may be overflowing the stack... e.g. using a recursive function call or a memory leak

try to post your code

BulldogLowell:
you may be overflowing the stack... e.g. using a recursive function call or a memory leak

I'm not doing anything recursive. A memory leak, may be.

BulldogLowell:
try to post your code

Here you go: infopanel.ino · GitHub

Can't see the problem but I'd use a millis() timer in your loop() function:

void loop() {
  // Only update time and temp every second.
  if (millis() - timerCount >= 1000UL) {
    printTime();
    printTemp();
    timerCount += 1000UL;
  }
}

and change

int timerCount = 0;

to

unsigned long timerCount = 0;

you may be overflowing that int...

You could try adding decoupling capacitors, o.1uF from VCC to ground close to the chip, and on the powerlines.

See:

Erni:
You could try adding decoupling capacitors, o.1uF from VCC to ground close to the chip, and on the powerlines.

I have one over pins 7 and 8 (Vcc and GND), Vcc and GND of the LCD and two (10uF) over the input and output of the 7805. I could try with some more on each breadboard rail.

BulldogLowell:
you may be overflowing that int...

Nope. I initialize it at 0. Increase it in small bits of 200 (ms) each loop. If it reaches a 1000 or more (1 second-ish), it is decreased again by a 1000. It should stay in the 0-1200 range. If anything I should pick a smaller data type :slight_smile: Also, I don't use millis because I do no need millisecond accuracy here.

Your example, on the contrary, keeps ever increasing timerCount, and although it's an unsigned long, it may still overflow. Looking at the Arduino docs, that is in about 50 days after system start: millis() - Arduino Reference If I were to use millis() I'd do something like:

unsigned long previousMillis = 0;

void loop() {
  if (millis() - previousMillis >= 1000) {
    // Reset previousMillis to 0-difference
    previousMillis = millis();

    // Do things
  }

  // Handle millis() rolling back to 0 after 50-ish days.
  if (millis() - previousMillis < 0) {
    previousMillis = 0;
  }
}

ariejan:
Your example, on the contrary, keeps ever increasing timerCount, and although it's an unsigned long, it may still overflow. Looking at the Arduino docs, that is in about 50 days after system start: millis() - Arduino Reference

I would never give you bad advice like that :blush:

learn about unsigned subtraction here. and avoid the rollover issue.

@BulldogLowell I guess your approach works as well, relying on how ints roll over. Either way I don't think it's what's causing my project to restart.

I did discover that AREF has an internal 32k pull up resistor. If there is a resistor on the supplied reference voltage, this internal pull up works as part of a voltage divider. I'm already using a voltage divider to get the 3.3V reference. This means my temperature readings are off and probably causing issues.

Because I don't want to add a 3.3V ref IC to my project I'm going to switch to the provided 5V internal reference of the atmega. This also eliminates the two resistors for the voltage divider (as I want my board to be as small as possible). The temperature readings will be a bit more rough, but I can easily write some software to smooth that out.

Going to try this later this week, I'll report back if it works.

The problem could be due to a bad breadboard. Those things are not reliable at all.
The "clamps" that are being used to hold pins and wires down are usually not of the best quality and after inserting a big lead or wire, they tend to stand apart.

Try a different location on the breadboard, some new (better) wires or even a fresh breadboard.