Sunday 30 August 2015

Particle Photon: Output data over the serial connection

Another useful piece of functionality that the CLI provides is the ability to listen and output data from the serial connection on the photon. This essentially allows you to do printlns.

To output some logging your program you need to initialise the serial connection in the setup:

void setup()
{
    Serial.begin(9600);
}
The 'Serial' object is the connection over USB to your computer. There are other Serial objects you can use to communicate over different channels.

then you are ready to output some logging:

...
Serial.println("Hello World!");
...

 In order to listen to the serial connection, use the following CLI command:
> sudo particle serial monitor
You should start seeing your messages output on the console.

No comments:

Post a Comment