I am attempting to use a Thing Plus SAMD51 [https://www.sparkfun.com/products/14713]. I am having difficulties getting any content to display to the serial monitor. The sketch I am using is meant to write a few lines to the serial monitor via Serial.print() and Serial.println() and blink the builtin LED as evidence the sketch loaded and is running.
#include <Arduino.h>
const unsigned long heartbeatFrequency = 1000;
unsigned long heartbeatTime = 0;
int ledState = 0;
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, ledState);
Serial.begin(115200);
Serial.println("Serial test started");
for (int i = 0; i < 10; i++) {
Serial.print("i = ");
Serial.println(i);
}
}
void loop()
{
heartbeat();
}
void heartbeat(void)
{
unsigned long currentTime = millis();
if (currentTime > (heartbeatTime + heartbeatFrequency)) {
heartbeatTime = currentTime;
ledState = ! ledState;
digitalWrite(LED_BUILTIN, ledState);
}
}
The sketch uploads successfully, and I can see the builtin LED blink as expected. However, nothing displays on the serial monitor. I confirmed the baud rate in the sketch and the baud rate on the monitor are the same. I have closed and reopened the monitor several times. I have pressed the board’s reset button to no avail. I have uninstalled and reinstalled the Arduino IDE 1.8.15. I have confirmed the computer, USB port, USB cable, and sketch all function by using them to successfully upload and run the sketch on a Qwiic Redboard.
I understand there are differences between SAMD and AVR chips. Is the use of Serial one of those differences? If so, I haven’t come across anything saying as much but would happily adjust the sketch as needed if that is indeed the case.
I don’t know what else to try in isolating this issue. My concern now is that the board may have an issue with the TX pin of its USB port. Is there anything else I can be checking before I look to the hardware?
You have to do a couple extra things before the SAMD51 will upload sketches properly; run through the hookup guide here https://learn.sparkfun.com/tutorials/sa … -guide/all which covers the installation steps for the drivers, SparkFun libraries, SAMD Core, etc.
Give that walkthrough a try and see if the serial works
To my knowledge, I have gone through that tutorial. Just to be sure, here are things I can see.
-
I’m using Linux, so the portions covering Windows 7 and MacOS don’t apply.
-
I do see Arduino SAMD Boards available under Tools > Boards. These were installed before the Sparkfun SAMD Boards.
-
I do see Sparkfun SAMD Boards available under Tools > Boards.
-
When I double-tap the SAMD board to enter the bootloader, I do see its LED change.
-
I do see the USB mass storage device 51THINGBOOT mount.
-
I do see the available port change from ttyACM0 to ttyACM1.
-
After selecting the changed port, I am able to upload the sketch, and I do see “Done Uploading”.
-
Upon completing the upload, I do see the port change back to ttyACM0.
-
Having uploaded the Blink example sketch, I do see the LED blinking as expected.
-
Having uploaded my sketch, I do see the LED blink in the manner dictated by it instead of the Blink sketch, but the serial monitor does not display anything.
Have I missed anything from the tutorial?
Try swapping ‘SerialUSB’ for ‘Serial’ in your sketch, I think your printing to pins 0 ans 1 on the board and not the serial that’s connected to the USB port.
I made the swap as suggested. The compiler threw this error.
/home/brian/Documents/Arduino/Simple_Serial_Test/Simple_Serial_Test.ino: In function 'void setup()':
Simple_Serial_Test:12:3: error: 'SerialUSB' was not declared in this scope
SerialUSB.begin(115200);
^
exit status 1
'SerialUSB' was not declared in this scope
SerialUSB is on any SAMD but not on SAMD51. Try adding a delay, like this :
Serial.begin(115200);
do {
delay(500);
}while(!Serial);
That did it! Thank you very much for helping pinpoint what was missing.
TS-Russell:
You have to do a couple extra things before the SAMD51 will upload sketches properly; run through the hookup guide here https://learn.sparkfun.com/tutorials/sa … -guide/all which covers the installation steps for the drivers, SparkFun libraries, SAMD Core, etc.
Give that walkthrough a try and see if the serial works
Successfully completed the tutorials/samd51-thing-plus-hookup-guide/all because I can upload a modified blink.ino sketch using different on and off times which I can see. I then update the comm port the IDE uses and attempt to get Serial.print to output on the Serial Monitor. I confirm that I am using the proper comm port after uploading and the baud rate matches that which I request. However, as this thread has started without joy on Serial.print or Serial.println, I have the same issue. I have tried this on both IDE v1.8.19 and the tutorial V1.8.5 suggestion and no joy.
Further work has identified that the typical time for the serial port to be available is much longer than I expected. I then added this code:
Serial.begin(9600);
while (!Serial); // Wait for serial port to connect
Serial.println(“Testing SparkFun SAMD51 Board”);
and was able to get output on the Serial Monitor when it opened.
I must say that for an Arduino experienced user at the 8 bit level, the jump to using Arduino IDE with the SAMD51 approach:
-
Double tap the reset button to enter the programming mode with a subsequent comm port change in the IDE
-
Upload the code and then when the new Serial port is available, the IDE must be configured to the new Serial port number.
-
The Serial Monitor port must be launched or else the “fix” will never end (while never true) but as I want output on the Monitor, this is a solution but requires the USER to be aware of what is in the code.
My bet: Arduino users will not rush to get to this powerful chip approach unless the process is more efficient. Now I will try the VSC/PlatformIO IDE approach. Good luck to me!