# How to use serial.print

**URL:** <https://community.particle.io/t/how-to-use-serial-print/4456>\
**Category:** Firmware\
**Created:** [May 20, 2014, 1:05am UTC](https://community.particle.io/t/how-to-use-serial-print/4456 "2014-05-20T01:05:13Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![kiwibird1](https://avatars.discourse-cdn.com/v4/letter/k/ce73a5/32.png) [@kiwibird1](https://community.particle.io/u/kiwibird1)\
**Post date:** [May 20, 2014, 1:05am UTC](https://community.particle.io/t/how-to-use-serial-print/4456/1 "2014-05-20T01:05:13Z")

</div>

Im new to spark, and dont know how to see the console. Can someone please inform me how? Sample code below.

// Define the pins we’re going to call pinMode on  
int led = D0;&nbsp; // You’ll need to wire an LED to this one to see it blink.  
int led2 = D7; // This one is the built-in tiny one to the right of the USB jack  
int cnter=0;  
// This routine runs only once upon reset  
void setup() {  
&nbsp; // Initialize D0 + D7 pin as output  
&nbsp; // It’s important you do this here, inside the setup() function rather than outside it or in the loop function.  
&nbsp; pinMode(led, OUTPUT);  
&nbsp; pinMode(led2, OUTPUT);  
}

// This routine gets called repeatedly, like once every 5-15 milliseconds.  
// Spark firmware interleaves background CPU activity associated with WiFi + Cloud activity with your code.  
// Make sure none of your code delays or blocks for too long (like more than 5 seconds), or weird things can happen.  
void loop() {  
&nbsp;&nbsp;&nbsp; cnter++;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Serial.println(cnter);  
&nbsp; digitalWrite(led, HIGH);&nbsp;&nbsp; // Turn ON the LED pins  
&nbsp; digitalWrite(led2, HIGH);  
&nbsp; delay(310);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Wait for 1000mS = 1 second  
&nbsp; digitalWrite(led, LOW);&nbsp;&nbsp;&nbsp; // Turn OFF the LED pins  
&nbsp; digitalWrite(led2, LOW);  
&nbsp; delay(300);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Wait for 1 second in off mode  
&nbsp; digitalWrite(led, HIGH);&nbsp;&nbsp; // Turn ON the LED pins  
digitalWrite(led2, HIGH);  
delay(1000);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Wait for 1000mS = 1 second  
digitalWrite(led, LOW);&nbsp;&nbsp;&nbsp; // Turn OFF the LED pins  
digitalWrite(led2, LOW);  
delay(1000);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Wait for 1 second in off mode  
//}  
&nbsp;  
&nbsp;  
&nbsp;  
&nbsp;  
}

---

<div class="post-metadata">

**Author:** ![kennethlimcp](https://avatars.discourse-cdn.com/v4/letter/k/c0e974/32.png) [@kennethlimcp](https://community.particle.io/u/kennethlimcp)\
**Post date:** [May 20, 2014, 2:01am UTC](https://community.particle.io/t/how-to-use-serial-print/4456/2 "2014-05-20T02:01:31Z")

</div>

You need something like this:

```
void setup(){
      serial.begin(9600);
    }

void loop(){
      serial.println("");
}

```

---

<div class="post-metadata">

**Author:** ![kiwibird1](https://avatars.discourse-cdn.com/v4/letter/k/ce73a5/32.png) [@kiwibird1](https://community.particle.io/u/kiwibird1)\
**Post date:** [May 20, 2014, 4:53am UTC](https://community.particle.io/t/how-to-use-serial-print/4456/3 "2014-05-20T04:53:58Z")

</div>

thanks for prompt reply.  
your code doesnt complie and serial begin doesnt work in mine either.  
Im familiar with arduino. I just go to serial console as see the serial output.  
I dont have a clue how to do this on spark

/blink\_an\_led.cpp:2:7: error: ‘serial’ was not declared in this scope

```
  /blink_an_led.cpp: In function 'void loop()':

  /blink_an_led.cpp:6:7: error: 'serial' was not declared in this scope
```

---

<div class="post-metadata">

**Author:** ![kennethlimcp](https://avatars.discourse-cdn.com/v4/letter/k/c0e974/32.png) [@kennethlimcp](https://community.particle.io/u/kennethlimcp)\
**Post date:** [May 20, 2014, 5:27am UTC](https://community.particle.io/t/how-to-use-serial-print/4456/4 "2014-05-20T05:27:36Z")

</div>

Sorry you need a capital S 😃

`Serial.begin(9600)`

---

<div class="post-metadata">

**Author:** ![kiwibird1](https://avatars.discourse-cdn.com/v4/letter/k/ce73a5/32.png) [@kiwibird1](https://community.particle.io/u/kiwibird1)\
**Post date:** [May 20, 2014, 5:32am UTC](https://community.particle.io/t/how-to-use-serial-print/4456/5 "2014-05-20T05:32:26Z")

</div>

Hi Kennith  
that now compiles:)  
How to get to to see terminal output?

---

<div class="post-metadata">

**Author:** ![Moors7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/moors7/32/588_2.png) [@Moors7](https://community.particle.io/u/Moors7)\
**Post date:** [May 20, 2014, 6:36am UTC](https://community.particle.io/t/how-to-use-serial-print/4456/6 "2014-05-20T06:36:42Z")

</div>

This topic kinda shows it all 😉

> **[Installing the USB Driver on Windows & Serial Debugging](https://community.particle.io/t/installing-the-usb-driver-on-windows-serial-debugging/882)**
>
> NOTE: These steps are outdated and no driver is required for the latest Windows 10 !!! This installer will clean up old drivers and install a combined driver though if you’d like to try it: ...

---

<div class="post-metadata">

**Author:** ![kennethlimcp](https://avatars.discourse-cdn.com/v4/letter/k/c0e974/32.png) [@kennethlimcp](https://community.particle.io/u/kennethlimcp)\
**Post date:** [May 20, 2014, 7:34am UTC](https://community.particle.io/t/how-to-use-serial-print/4456/7 "2014-05-20T07:34:35Z")

</div>

You can use a terminal like `Putty` on Windows to open up a COM port 😉

---

<div class="post-metadata">

**Author:** ![Moors7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/moors7/32/588_2.png) [@Moors7](https://community.particle.io/u/Moors7)\
**Post date:** [May 20, 2014, 7:36am UTC](https://community.particle.io/t/how-to-use-serial-print/4456/8 "2014-05-20T07:36:11Z")

</div>

The arduino IDE would work as well, in case you’re used to that one.

---

<div class="post-metadata">

**Author:** ![sej7278](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@sej7278](https://community.particle.io/u/sej7278)\
**Post date:** [May 20, 2014, 7:47am UTC](https://community.particle.io/t/how-to-use-serial-print/4456/9 "2014-05-20T07:47:51Z")

</div>

or GNU screen: `screen /dev/ttyACM0 9600` or minicom

---

<div class="post-metadata">

**Author:** ![kiwibird1](https://avatars.discourse-cdn.com/v4/letter/k/ce73a5/32.png) [@kiwibird1](https://community.particle.io/u/kiwibird1)\
**Post date:** [May 21, 2014, 3:11am UTC](https://community.particle.io/t/how-to-use-serial-print/4456/10 "2014-05-21T03:11:26Z")

</div>

Thanks for replies.  
IM aware how to do com port serial.print, but was hoping for wifi.  
If this is ide, or gnu, can someone show the steps that need to be done?

---

<div class="post-metadata">

**Author:** ![kennethlimcp](https://avatars.discourse-cdn.com/v4/letter/k/c0e974/32.png) [@kennethlimcp](https://community.particle.io/u/kennethlimcp)\
**Post date:** [May 21, 2014, 3:17am UTC](https://community.particle.io/t/how-to-use-serial-print/4456/11 "2014-05-21T03:17:24Z")

</div>

You want to see serial output via wifi?

---

<div class="post-metadata">

**Author:** ![kiwibird1](https://avatars.discourse-cdn.com/v4/letter/k/ce73a5/32.png) [@kiwibird1](https://community.particle.io/u/kiwibird1)\
**Post date:** [May 21, 2014, 4:21am UTC](https://community.particle.io/t/how-to-use-serial-print/4456/12 "2014-05-21T04:21:33Z")

</div>

Correct, else some other way for wifo to communicate to me. web page, phone app etc

---

<div class="post-metadata">

**Author:** ![bko](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bko/32/20704_2.png) [@bko](https://community.particle.io/u/bko)\
**Post date:** [May 21, 2014, 4:29am UTC](https://community.particle.io/t/how-to-use-serial-print/4456/13 "2014-05-21T04:29:03Z")

</div>

Hi @kiwibird1

Have your seen the Tutorials section here in the fourm? There are a lot great ways to get data to and from your core.

The Spark.publish() method is probably the easiest way to get data out but Spark.variables also work great.

[https://community.spark.io/category/project-share/tutorials](https://community.spark.io/category/project-share/tutorials)

---

<div class="post-metadata">

**Author:** ![kiwibird1](https://avatars.discourse-cdn.com/v4/letter/k/ce73a5/32.png) [@kiwibird1](https://community.particle.io/u/kiwibird1)\
**Post date:** [May 21, 2014, 5:08am UTC](https://community.particle.io/t/how-to-use-serial-print/4456/14 "2014-05-21T05:08:44Z")

</div>

spark publish looks good.  
I tried the instructions at [https://community.spark.io/t/sprint-7-spark-publish-released-lets-build-a-cloud-connected-motion-detector/3391](https://community.spark.io/t/sprint-7-spark-publish-released-lets-build-a-cloud-connected-motion-detector/3391)  
When I do npn install -g spark-cli i get “…” and it hangs.

---

<div class="post-metadata">

**Author:** ![Moors7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/moors7/32/588_2.png) [@Moors7](https://community.particle.io/u/Moors7)\
**Post date:** [May 21, 2014, 7:30am UTC](https://community.particle.io/t/how-to-use-serial-print/4456/15 "2014-05-21T07:30:12Z")

</div>

Try this tutorial to get the CLI up and running:

> **[Tutorial: Particle-cli on Windows \[07 Jun 2015\]](https://community.particle.io/t/tutorial-spark-cli-on-windows-06-may-2014/3112)**
>
> Instructions to install PARTICLE-CLI on Windows \*please install to the default directory as they are hardcoded to read them and changing the PATHS require more work and complicate matters for the 1st time \*All installations must be the same system...

Shouldn’t be too difficult, and the CLI is extremely useful!  
Good luck.

---

<div class="post-metadata">

**Author:** ![sej7278](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@sej7278](https://community.particle.io/u/sej7278)\
**Post date:** [May 21, 2014, 8:48am UTC](https://community.particle.io/t/how-to-use-serial-print/4456/16 "2014-05-21T08:48:12Z")

</div>

[https://github.com/spark/spark-cli](https://github.com/spark/spark-cli) has the unix commands for installing spark-cli

i had to do the following as root on Debian7, as one of the dependencies expects to find the binary “node” not “nodejs”:

```auto
apt-get install node
cd /usr/bin
ln -s nodejs node
npm install -g spark-cli

```
