ATmega 32u4 (Adafruit Adalogger Feather) Serial Monitor COM4

I apologize if I am posting to the wrong forum, but I was not sure which forum would be best suited to my question.

I ran the Blink sketch on my Feather 32u4 (which has the ATmega 32u4 uC), and it ran successfully; however, each time I had to manually press the board’s reset button while the Feather was uploading the Blink sketch. I altered the blinking rate of pin 13 red LED just to make sure that this sketch was working properly, and it did work properly.

Here is the Blink sketch that ran successfully on my Feather:

// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 as an output.
pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

Then I uploaded the following sketch to my Feather. This sketch worked fine on my Uno. It uses the Spark Fun MMA8452Q accelerometer. :

#include <Wire.h>

#include <SparkFun_MMA8452Q.h>

MMA8452Q accel; // initialize MMA8452Q accelerometer with I2C address (0x1D)

int Xout_12_bit, Yout_12_bit, Zout_12_bit;
float Msq, DifX, DifY, DifZ;
int X_last = 0;
int Y_last = 0;
int Z_last = 0;
int n = 0; // records number of motion of events
int motion = 0;

void setup() {

accel.init(); // Default init: +/-2g and 800Hz ODR

Serial.begin(9600);

}

void loop() {
delay(1000); // delay for 1 second
accel.read(); // Update accelerometer data
Xout_12_bit = accel.x; // read in raw x-axis acceleration data
Yout_12_bit = accel.y; // read in raw y-axis acceleration data
Zout_12_bit = accel.z; // read in raw z-axis acceleration data

DifX = (Xout_12_bit - X_last);
DifY =(Yout_12_bit - Y_last);
DifZ =(Zout_12_bit - Z_last);
X_last = Xout_12_bit;
Y_last =Yout_12_bit;
Z_last = Zout_12_bit;
Msq = DifXDifX + DifYDifY + DifZ*DifZ;

if(Msq > 1000 & motion == 0){
n++;
Serial.print(n);
Serial.print(" ");
Serial.println(“MOTION DETECTION”);
motion = 2;
} else if(Msq <= 1000){
if(motion > 0) motion–;
}

} // end of loop()

This sketch allows me to see when the accelerometer detects motion by printing MOTION DETECTION in the Serial Monitor when the MMA8452Q is moved. As I said, it worked fine on the Uno.

I also manually pressed the Feather’s reset button during uploading of this sketch, and it uploaded successfully. However, as soon as I tried to open the serial monitor (by pressing its magnifying glass icon in top right corner of the Arduino IDE window), I received an error message that states:

Arduino: 1.6.7 (Windows 10), Board: “Adafruit Feather 32u4”

Sketch uses 8,752 bytes (30%) of program storage space. Maximum is 28,672 bytes.
Global variables use 445 bytes of dynamic memory.

Board at COM4 is not available

This report would have more information with
“Show verbose output during compilation”
enabled in File > Preferences.

I am guessing that this is related to the Serial Monitor and the COM port through which it communicates, but I do not understand Arduinos enough to be sure. Any advice would be greatly appreciated.

The ATmega32U4 can do that sometimes. Use the newest Arduino IDE and the newest firmware for the ATmega32U4. Sometimes you have to set the serial COM port again in the Arduino IDE while working with it.

I see there is delay(1000) in the loop, that is good. Because when sending too much Serial data to the computer the automatic reset might not work very well.

However, I use the ATmega32U4 in both linux and Windows and lately I don't have many problems with it. If you have to press the reset button, then perhaps something is wrong. Do you use a USB hub ? or a cheap USB cable that drops the voltage too much ?
Try another cable and another USB port.

It is safer to wait in the sketch for the serial monitor to open.
That is done like this:

  Serial.begin(9600);
  while(!Serial);        // Leonardo only: wait for the serial monitor.

I am using the USB cable that I purchased from Adafruit when I purchased the Adafruit Feather Adalogger. I plug that USB cable directly into a USB port on my PC which uses Windows 10 (but was using Windows 7 until it automatically changed over to Windows 10 without my intention to do so). I am not using a USB hub.

I added the code:

while(!Serial);

just after:

Serial.begin(9600);

but again I received the same error message.

I also added the code (recommended by another individual):

while ( ! Serial ) { delay( 10 ); }

just before:

Serial.begin(9600);

and again I received the same error message.

My MMA8452Q sketch uploads fine (as long as I manually press the reset button on the Feather board during uploading). However, as soon as I press the serial monitor icon in the top right of the Arduino IDE, I still get the same error message as before.

I tried using a different USB port, and I still get a similar error message, but it now states: "Board at COM6 is not available". I evidently was using COM6 (when I used this different USB port) because it states "Adafruit Feather 32u4 on COM6" in bottom right of Arduino IDE (after successfully uploading my sketch but before I pressed the serial monitor button in top right of Arduino IDE).

I am using the Arduino IDE 1.6.7; how can I upgrade that to a newer version (if there is one) as you recommend?

When you state: "newest firmware for the ATmega32U4", are you referring to the bootloader within the Feather's program memory? I assumed that came already installed within the Feather and that I cannot change it.

When you state: "Sometimes you have to set the serial COM port again in the Arduino IDE while working with it.", could you explain to me how to do that?

I apologize for bothering you with so many questions, but I am rather new to all of this.

Could you try another ATmega32U4 based board ? (Arduino Leonardo, Micro, Pro Micro, and so on).
A Pro Micro is a stripped down version of the Arduino Micro and is 3.43 dollars at AliExpress.

For the newest Arduino IDE, click the 'Download' in the top menu bar of this website, you find the new Arduino 1.6.9.
If you use the zipped file, be sure to install the newest drivers from the "drivers" folder.

I ment indeed the bootloader, and I assume as well that it came with the newest bootloader.

Sometimes I have to set a new serial COM port in the Arduino IDE. In the menu : Tools / Port

Adafruit Feather Adalogger : Adafruit Feather 32u4 Adalogger : ID 2795 : $21.95 : Adafruit Industries, Unique & fun DIY electronics and kits
Did you do everything in the tutorial ?
It seems they have their own drivers, did you install them ?
Perhaps that driver works with the bootloader.

Maybe the board is faulty. If you have installed everything as Adafruit says, and did not make a mistake with soldering, then you better ask Adafruit about it.

I did everything in the Adafruit tutorial except download their drivers.

I did not install their driver because I had already installed a driver when I originally downloaded the Arduino IDE 1.6.7 to use with my Arduino Uno before I purchased the Feather (I wanted to learn on the Uno first). I asked at the Adafruit forum if I should install their driver if I already had installed a driver that I used with the Uno. They said to try using that Uno driver with the Feather first. I did, and it worked fine with the Blink sketch; so I assumed that I should just continue to use that Uno driver (this is how much of a novice I am; my apologies).

If I install the Feather driver from the Adafruit website, do I need to delete the driver that I already installed previously for the Uno? (in other words, can trying to install a new driver create problems if another driver already exists within my computer?) If so, is there anywhere that I can find step by step instructions on how to do this?

Again, I apologize for such basic questions.

I think you can install the driver without removing the others.
If you follow the tutorial step by step, you see a green button to download the drivers.

There is still the possibility that your board is faulty.

I finally was able to use the serial monitor! Here is how:

I used this in my code:

while ( ! Serial ) { delay( 10 ); }
Serial.begin( 9600 );

Then I uploaded my accelerometer (MMA8452Q) sketch, and I manually pressed the reset button on the Feather board while it was uploading.

Then I went to: Tools > Port to see if a new port had appeared. When it did, I selected it, and then I opened my Serial Monitor which finally worked (as it had with my Arduino Uno).

Thanks so much for all of the advice and help. I would not have been able to do what I did without your help.