Arduino resets after conneting to Serial Port

Hi guys,

my Arduino Nano Every reboots himself after connecting to Serial Comunication.
How to avoid this?

Im using this code with the Arduino IDE 1.0:

#include <Adafruit_BMP280.h>
Adafruit_BMP280 bmp;
const int i =2396;
unsigned int pres [i];
unsigned int x=0;
bool doloop =true;
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  bmp.begin(0x76);

  bmp.setSampling(Adafruit_BMP280::MODE_NORMAL,     // Operating Mode. 
                  Adafruit_BMP280::SAMPLING_X2,     // Temp. oversampling 
                  Adafruit_BMP280::SAMPLING_X16,    // Pressure oversampling 
                  Adafruit_BMP280::FILTER_X16,      // Filtering
                  Adafruit_BMP280::STANDBY_MS_1); // Standby time. */
 
}

void loop() {
  // put your main code here, to run repeatedly:
    if(doloop==true)
    {
    if (x<=i) 
    {
      pres[x]=(((trunc(bmp.readPressure()))*100)-(75000*100))/100;
      x++;
    }
    else
    {
      Serial.println("Memory full");
      delay(100);
    }
    if (Serial.available()>0)
    {
      for (x=0;x<=i;x++)
      {
        //Serial.print(x);
        //Serial.print(":");
        Serial.println(pres[x]);
        
      }
      doloop=false;
    }
    /*!!!!!!!!!!!!!!AAAAAAAAAAAAACHTUNGGGGGGGGGGGGGGGGGGGGGGGGGGG!!!!!!!!!!!!!!!!!!!!*/
    delay(10);
    }
}

The code reads out data from the BMP280 and stores it in the RAM of the Arduino Nano Every. After reporting that the memory is full, Arduino is connected to a PC.
The data should be read out with the Aduino Serial Monitor( or any other Serial Monitor). But after connecting to the PC and creating a connection the Arduino resets.

Help us help you.

1 Like

Hint, posting an annotated schematic, not a frizzy picture generally gets you a good answer in maybe a day, not weeks of guessing games. Be sure the schematic is as you have wired it, similar to is not allowed. Also links to hardware items technical information helps a lot in answering. Links to azon and other market places generally do not have the needed information. There are many items with the same name and number that are not the same. Have you checked the appropriate data sheets?

The engineers I worked with always did the schematic first then from the BOM (Bill Of Material) ordered the parts they need, even a few extra.

Thanks for posting your complete code.

I would recommend that you change the title of this post to
"Nano Every resets after connecting to Serial Port".

The triggering of program mode (via a 1200 bps pulse) and reset is very different for the Nano Every, and its not clear to me if it should be happening on connection to USB.

How is the Nano Every powered? Perhaps you are getting a POR(power on reset) or BOD (Brownout Detector) reset.

There is a Reset Flag Register(RSTFR) which you can read to determine the cause of the reset. Spending some time with the [Data Sheet for the AT4809] will be helpful. (http://ww1.microchip.com/downloads/en/DeviceDoc/ATmega4808-4809-Data-Sheet-DS40002173A.pdf)

EDIT:
Yes, after usb connection opening the Serial monitor will reset the Nano Every. When I open the connection in Cool Term with DTR and RTS off, the board does not reset. This would lead me to think that the changing of the dtr and rts settings following the procedure in this post might work.
https://forum.arduino.cc/t/how-to-prevent-nano-every-from-resetting-upon-connection-to-the-serial-port/674505

2 Likes

Resetting at Serial Monitor opening is a standard behaviour of the most classical arduinos - Uno, Nano, Mega.... There is nothing incorrect in it.

I am very pleased with the quick response and glad that someone is helping me. Unfortunately, I can only try the solution tomorrow because I had very little time today. Just enough to write this thank you! :hugs:

Good evening from Germany
burningsomepcbs

I have had some issues with the rts/dtr management using the Serial Monitor, and I would recommend using Cool Term or some other terminal program which can control the settings.

Hi,

Thanks for solving the problem that quick. :saluting_face: I was actually using CoolTerm.
I have been able to successfully implement this solution. Of course, after that came another problem. I will create a new thread about it.:smiling_face_with_tear:.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.