Using Serial Functions Over USB

I wanted to post this as a (searchable?) reference for anyone out there wanting to output using Serial but not seeing the device connected to your computer.

I wanted to test the USB serial functionality (Serial.begin(), Serial.println(), etc) for debugging code. I had a different sketch running on my Spark when I started to play with Serial. However, if the currently running sketch does not contain Serial.begin(), the Spark will not show up as a COM port/device on your computer (on Mac OS X 10.9 anyways). Once you flash a sketch that contains Serial.begin(), you should see your Spark on your computer after the Spark reboots.

This wasn’t 100% straightforward for me, but it only took about 60 seconds to figure out. Hopefully this tip will help someone else getting started with Serial. It may not hurt to include it with the Serial documentation either.

4 Likes

Thanks @wgbartley, I’ll make a note of this in the documentation.

Thanks for this reminder!

1 Like

This doesn’t work even after rebooting.
I can’t see the device when Ils -la /dev/tty.*.

This is my code:

void setup() {
    Serial.begin(9600);
    Serial.println("started!");
}

void loop() {
    Serial.println("Working!");
    delay(1000);
}

Running OSX 10.9.

I don’t have a mac in front of me, but I’ll give it a shot. Maybe try plugging your core into a different usb port, or try switching the usb cable you’re using? You can also try typing “dmesg” in your terminal, at the very end should be a message about the new Spark Core you’ve plugged in, and hopefully it’ll tell you what device file it assigned. (I’ve seen /dev/ttyACM0, etc)

I’m guessing you know this already as well, but using stock firmware, your core should be breathing cyan before it’ll run that code. :smile:

Thanks!
David

I’m opening a new topic for this - https://community.spark.io/t/cant-see-the-device-on-my-mac-for-serial-communication/1067

1 Like

As I’ve written in the attached topic - I’ve replaced the cable with another one, and it now WORKS.

2 Likes

I found my USB hub was preventing the serial device from activating. Works if I plug directly into the mac.

1 Like