PlatformIO Community

Arduino crashes on startup

Hey together,

I am creating a project to control and measure the temperature and humidity in my terrariums using an Arduino Uno. I have a lot of code by now and suddenly the arduino crashes in the setup routine.

Here is the output of the Serial:

imanuel@imanuel-inspiron ~/P/terrarium-measure-and-control> pio device monitor

--- Available ports:
---  1: /dev/ttyACM0         'Goodix Fingerprint Device'
---  2: /dev/ttyUSB0         'USB2.0-Serial'
--- Enter port index or full name: 2
--- Miniterm on /dev/ttyUSB0  9600,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
Init display
Create epd
Create paint
Init epd
Clear frame memory
Set width an␀

This is the code of the setup routine:

Serial.println(F("Init display"));

display->displayText(F("Initializing..."), 0);

Serial.println(F("Init clock"));

Serial.println(F("Init humidity sensor"));

Serial.println(F("Init dimmer"));

Serial.println(F("Init temperatures"));
coldSideThermometer->setup(5, 0);
hotSideThermometer->setup(5, 1);

Serial.println(F("Init relay"));

Serial.println(F("Init sender"));
sender->setup(A0, A1);

auto ip = sender->getIp();

It does run through though, if I uncomment the following lines:

Serial.println(F("Init clock"));

Serial.println(F("Init sender"));
sender->setup(A0, A1);

The code inside the functions is as follows, for the clock->setup method

#include <RTClib.h>

auto rtc = new RTC_DS3231();

In the method sender->setup the code is as follows:

#include <SoftwareSerial.h>
#include <EEPROM.h>
#include <eeprom/EEPROMAccess.h>
#include "Sender.h"

Serial.println(F("Init ESP8266"));
auto serial = new SoftwareSerial(txPin, rxPin);
esp8266 = new ESP8266(*serial);
auto ssid = EEPROMAccess::readString(0);
auto passphrase = EEPROMAccess::readString(34);
esp8266->joinAP(ssid, passphrase);

The packages I have installed have the following ids:

  • 64
  • 19
  • 31
  • 54
  • 83
  • 127

Can someone help me?

Greetings Knerd

Hard to reproduce without the full code. If your setup is extremely long, you might get problems with a watchdog. Does calling wdt_disable(); first in setup() help (reference)? If you shuffle around the order of initializations in setup(), does it change where the ESP crashes?

Thanks for your reply, I just got pointed out on reddit, I should name which Arduino I use. I am using an Arduino Nano which connects to the ESP8266 via SoftwareSerial.

The full code is here:

Does the firmware crash / hang when you do this as a first thing in setup()? Have you tested each initialization in isolation?

Running them in isolation, only the sender crashes.