I am using Atmega328p with 5V power supply, My Arduino getting hangs [or auto restarts] after some times.

I am using libraries:

  • Wire.h
  • CRC32.h
  • EEPROM.h
  • Arduino.h
  • TimerOne.h
  • RtcDS3231.h
  • SoftwareSerial.h
  • Adafruit_NeoPixel.h
  • avr/wdt.h

I have tried to search, some people are deny to use software serial library.

enter image description here

  • it's possibly some error in your code Jan 15 '19 at 5:17
  • This is my code, can you guide me... github.com/savaliyadnk/arduinoswitch Jan 15 '19 at 5:30
  • don't use String. use C strings (zero terminated char array) majenko.co.uk/blog/evils-arduino-strings
    – Juraj
    Jan 15 '19 at 5:45
  • 1
    That is only a minimal circuit in theory. Can you show us a photo? We like to see where the decoupling capacitors are and how close the crystal with the 22pF capacitors to the atmega328p is.
    – Jot
    Jan 15 '19 at 5:50
  • Do you have 100nF connected to aref and vcc? It should be to gnd. All gnd and all vcc should be connected to the power. All of them. You have no decoupling capacitors. They are not an optional extra according to this page: gammon.com.au/bootloader
    – Jot
    Jan 15 '19 at 22:32

Not sure if this will fix your problem, but this is a major error:

  char buf1[8], buf2[6];
  sprintf(buf1, "%08lu", myvote.mydate);
  sprintf(buf2, "%06lu", myvote.mytime);

Take a look at sprintf function reference

A terminating null character is automatically appended after the content.

So, the text buffers are too small. It should be at least:

char buf1[9], buf2[7];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.