Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

Feather Adalogger M0 SerialUSB vs. Serial
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Feather Adalogger M0 SerialUSB vs. Serial

by gsklinger on Thu Jan 28, 2016 6:46 pm

Hi,
I'm having some difficulty getting Serial print to work on this M0 board. I've searched the forums and found several threads that brought up this issue, but I haven't found anything that works for me. I'm using version 1.6.5 of the IDE, and 1.6.2 of the Arduino SAMD board, but I can't get Serial printing to work using either method. Any suggestion? [edit - I forgot to mention the Adafruit SAMD version is 1.0.4]

gsklinger
 
Posts: 22
Joined: Wed Apr 03, 2013 6:57 pm

Re: Feather Adalogger M0 SerialUSB vs. Serial

by adafruit_support_mike on Fri Jan 29, 2016 4:15 am

On an M0, the interface that talks to the USB cable is officially named SerialUSB.

We've modified the variant libraries to map that to Serial transparently, but if that isn't working you can define the swap explicitly:

Code: Select all | TOGGLE FULL SIZE
#define Serial  SerialUSB
If you're writing original code and just want to talk to the computer, you can use SerialUSB explicitly if you want.

adafruit_support_mike
 
Posts: 61206
Joined: Thu Feb 11, 2010 2:51 pm

Re: Feather Adalogger M0 SerialUSB vs. Serial

by gsklinger on Fri Jan 29, 2016 3:29 pm

That doesn't work for me. Under 1.0.4 I get the following error:
Code: Select all | TOGGLE FULL SIZE
Arduino: 1.6.5 (Windows 7), TD: 1.25, Board: "Adafruit Feather M0 (Native USB Port)"

M0_datalogger.ino: In function 'void setup()':
M0_datalogger:43: error: 'SerialUSB' was not declared in this scope
M0_datalogger.ino:49:3: note: in expansion of macro 'Serial'
M0_datalogger.ino: In function 'void loop()':
M0_datalogger:43: error: 'SerialUSB' was not declared in this scope
M0_datalogger.ino:90:3: note: in expansion of macro 'Serial'
'SerialUSB' was not declared in this scope

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

Under 1.0.3 I don't get the error, but it does print anything to the serial monitor either.
If I try to use Serial USB I get the following error:
Code: Select all | TOGGLE FULL SIZE
Arduino: 1.6.5 (Windows 7), TD: 1.25, Board: "Adafruit Feather M0 (Native USB Port)"

M0_datalogger.ino: In function 'void setup()':
M0_datalogger:49: error: 'SerialUSB' was not declared in this scope
'SerialUSB' was not declared in this scope


  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.
[edit - apparently I wasn't printing enough characters! It must buffer more characters than AVRs before they get sent off to the serial monitor. But I got it working with plain old Serial.print ...

gsklinger
 
Posts: 22
Joined: Wed Apr 03, 2013 6:57 pm

Re: Feather Adalogger M0 SerialUSB vs. Serial

by adafruit_support_mike on Sun Jan 31, 2016 12:47 am

Hmm.. I wasn't aware of that buffering issue.

When in doubt, call Serial.flush() to send whatever is in the buffer.

adafruit_support_mike
 
Posts: 61206
Joined: Thu Feb 11, 2010 2:51 pm

Re: Feather Adalogger M0 SerialUSB vs. Serial

by maxleclercq on Fri Nov 11, 2016 2:04 pm

I'm having the same issue and really struggling to get it work: The Serial.flush didn't do anything for me.

"Sketch1.ino:In function 'void setup()
Sketch1.ino:10:16: error: 'SerialUSB' was not declared in this scope
:#define Serial SerialUSB
Sketch1.ino:note in expansion of macro 'Serial
:while (!Serial); \\ wait until serial console is open, remove if not tethered to computer. Delete this line on ESP8266
Sketch1.ino:10:16: error: 'SerialUSB' was not declared in this scope"

I'm using 'Adafruit Feather M0 (Native USB Port)' 1.0.13 (latest available).

here is my very simple code:

#define Serial SerialUSB
#define SERIAL_BAUD 115200
#define LED 13 // onboard blinky

void setup() {

while(!Serial); // wait until serial console is open, remove if not tethered to computer. Delete this line on ESP8266
Serial.begin(SERIAL_BAUD);

delay(500);
// initialize digital pin 13 as an output.
pinMode(LED, OUTPUT);
Serial.println("Hello World!");
Serial.flush();

}

maxleclercq
 
Posts: 5
Joined: Sun Dec 27, 2015 8:35 pm

Re: Feather Adalogger M0 SerialUSB vs. Serial

by adafruit_support_mike on Sat Nov 12, 2016 1:34 am

The board support package has changed several times since the posts above were made.

SerialUSB doesn't exist any more. These days, the connection through the M0's USB cable is just called Serial.

adafruit_support_mike
 
Posts: 61206
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.