# How to display data on Terminal?

**URL:** <https://community.particle.io/t/how-to-display-data-on-terminal/35255>\
**Category:** Troubleshooting\
**Created:** [August 11, 2017, 2:56am UTC](https://community.particle.io/t/how-to-display-data-on-terminal/35255 "2017-08-11T02:56:47Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![manlin](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/manlin/32/15222_2.png) [@manlin](https://community.particle.io/u/manlin)\
**Post date:** [August 11, 2017, 2:56am UTC](https://community.particle.io/t/how-to-display-data-on-terminal/35255/1 "2017-08-11T02:56:47Z")

</div>

I am working on a temperature measuring project. I already flashed the firmware to the Electron successfully but having trouble to see the data it gathered on Terminal.

After flashed the code, I ran the command `ls /dev/tty.*`, found the serial port, then `screen /dev/tty.usbserial-A700eWEe 9600`. First time Terminal generated a “1.screen” window and I could see all the data that printed out! Yay! But then I closed the Terminal, plugged out the Electron, and ran the same commands again (flash codes -\> screen the data) but it didn’t work! The error was “ **Couldn’t find PTY** ”. I tried to look up online but nothing helpful. I’ve been stumped for hours. Does anyone know what’s going on? Thank you for your help in advance!

I am using Macbook (Sierra, Version 10.12.1) and iTerm2 (Build 3.0.15).

Manlin

---

<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:** [August 11, 2017, 2:58am UTC](https://community.particle.io/t/how-to-display-data-on-terminal/35255/2 "2017-08-11T02:58:59Z")

</div>

> [@manlin](#):
>
> But then I closed the Terminal, plugged out the Electron,

The data is via USB from Electron using a serial port. If you plug it out then there's no way to get data from the Electron?

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [August 11, 2017, 6:52am UTC](https://community.particle.io/t/how-to-display-data-on-terminal/35255/3 "2017-08-11T06:52:40Z")

</div>

I don’t think even MacBook supports _wireless USB_ yet 😉

---

<div class="post-metadata">

**Author:** ![manlin](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/manlin/32/15222_2.png) [@manlin](https://community.particle.io/u/manlin)\
**Post date:** [August 11, 2017, 7:10am UTC](https://community.particle.io/t/how-to-display-data-on-terminal/35255/4 "2017-08-11T07:10:06Z")

</div>

Hi @kennethlimcp @ScruffR thank y’all for the reply!!

Sorry I forgot to mention I plugged them back on haha. I plugged them out to turn them off, then plugged them back, flashed the code again, ran the two commands to find the serial port and screen again, like how I did the first time! But could never see the data from Terminal again T-T

---

<div class="post-metadata">

**Author:** ![manlin](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/manlin/32/15222_2.png) [@manlin](https://community.particle.io/u/manlin)\
**Post date:** [August 11, 2017, 7:12am UTC](https://community.particle.io/t/how-to-display-data-on-terminal/35255/5 "2017-08-11T07:12:22Z")

</div>

BTW this is my forth day learning particle and first time posting my question and already feeling the love from the particle community! Thank you! You guys are lit!!

---

<div class="post-metadata">

**Author:** ![nrobinson2000](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/nrobinson2000/32/15624_2.png) [@nrobinson2000](https://community.particle.io/u/nrobinson2000)\
**Post date:** [August 11, 2017, 1:57pm UTC](https://community.particle.io/t/how-to-display-data-on-terminal/35255/6 "2017-08-11T13:57:44Z")

</div>

> [@manlin](#):
>
> I am using Macbook (Sierra, Version 10.12.1) and iTerm2 (Build 3.0.15).

Shouldn't you be using `/dev/cu.usbmodem*`?  
That's how it shows up on every Mac I've used Particle with.

I see that `/dev/tty.usbmodem*` shows up as well like you mentioned, but try using `/dev/cu.usbmodem*`

---

<div class="post-metadata">

**Author:** ![Ric](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/ric/32/514_2.png) [@Ric](https://community.particle.io/u/Ric)\
**Post date:** [August 11, 2017, 4:14pm UTC](https://community.particle.io/t/how-to-display-data-on-terminal/35255/7 "2017-08-11T16:14:54Z")

</div>

Using the Mac built in Terminal program, I sometimes get an error of **“Sorry, could not find a PTY”**. This happens if the Photon is already running, and plugged into USB **before** I launch the Terminal window and send the **screen /dev/tty.usbserial\*** command. If I launch the Terminal window first, restart the Photon (or reset it), then send the screen command, it does find the PTY.

@nrobinson2000, I’ve always used **/dev/tty.usbserial\*** on my iMac (Sierra10.12.6 and older versions), but **/dev/cu.usbserial\*** also works for me.

---

<div class="post-metadata">

**Author:** ![cermak](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/cermak/32/14174_2.png) [@cermak](https://community.particle.io/u/cermak)\
**Post date:** [August 11, 2017, 5:51pm UTC](https://community.particle.io/t/how-to-display-data-on-terminal/35255/8 "2017-08-11T17:51:20Z")

</div>

Using the Particle CLI, my favorite in Terminal is just to do:

`particle serial monitor --follow`

If you hit the reset, it will automatically reconnect and continue displaying output.

The only drawback with this is do not disconnect the USB before control-C’ing out of this command. It will lock up the Terminal. If you do, you can plug it back in and then Ctrl-C. If you need to force it to shutdown, you will have to put it into the background Ctrl-Z and then kill the background process. Usually: `kill -9 %1`

%1 being the 1st background job. You can find out using the `jobs` command.

---

<div class="post-metadata">

**Author:** ![manlin](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/manlin/32/15222_2.png) [@manlin](https://community.particle.io/u/manlin)\
**Post date:** [August 11, 2017, 6:39pm UTC](https://community.particle.io/t/how-to-display-data-on-terminal/35255/9 "2017-08-11T18:39:51Z")

</div>

Thank you @nrobinson2000 @Ric and @cermak !! THANK YOU!

It is displaying data on 1.screen on iTerm right now but I am having trouble to kill it - control-c doesn’t work, and I can’t even type anything. I also tried what @cermak said and whatever I googled but the thing is I can’t type D:::

How can I kill the process on 1.screen window without closing Terminal, and get back to the 1.bash window? Thank you!!

---

<div class="post-metadata">

**Author:** ![cermak](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/cermak/32/14174_2.png) [@cermak](https://community.particle.io/u/cermak)\
**Post date:** [August 11, 2017, 6:45pm UTC](https://community.particle.io/t/how-to-display-data-on-terminal/35255/10 "2017-08-11T18:45:12Z")

</div>

Oh! You are trying to do two way communication 🙂

---

<div class="post-metadata">

**Author:** ![cermak](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/cermak/32/14174_2.png) [@cermak](https://community.particle.io/u/cermak)\
**Post date:** [August 11, 2017, 6:49pm UTC](https://community.particle.io/t/how-to-display-data-on-terminal/35255/11 "2017-08-11T18:49:42Z")

</div>

screen basics:

`control-a` begins the command sequence in screen

Next character:

- d - disconnect from session
- k - terminate session

If you disconnect, you can reconnect using `screen -r`

---

<div class="post-metadata">

**Author:** ![manlin](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/manlin/32/15222_2.png) [@manlin](https://community.particle.io/u/manlin)\
**Post date:** [August 11, 2017, 6:56pm UTC](https://community.particle.io/t/how-to-display-data-on-terminal/35255/12 "2017-08-11T18:56:34Z")

</div>

Thank you!! I control-a’ed in screen but it said “No other window”, and continued displaying data. What’s wrong?

---

<div class="post-metadata">

**Author:** ![cermak](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/cermak/32/14174_2.png) [@cermak](https://community.particle.io/u/cermak)\
**Post date:** [August 11, 2017, 6:57pm UTC](https://community.particle.io/t/how-to-display-data-on-terminal/35255/13 "2017-08-11T18:57:34Z")

</div>

That is if you hit Control-A followed by an “a”. If you want to kill that session, use Control-A then “k”.

---

<div class="post-metadata">

**Author:** ![manlin](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/manlin/32/15222_2.png) [@manlin](https://community.particle.io/u/manlin)\
**Post date:** [August 11, 2017, 7:00pm UTC](https://community.particle.io/t/how-to-display-data-on-terminal/35255/14 "2017-08-11T19:00:23Z")

</div>

Woaaaaahh it works!!! Thank you @cermak :DDDD

---

<div class="post-metadata">

**Author:** ![nrobinson2000](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/nrobinson2000/32/15624_2.png) [@nrobinson2000](https://community.particle.io/u/nrobinson2000)\
**Post date:** [August 11, 2017, 7:34pm UTC](https://community.particle.io/t/how-to-display-data-on-terminal/35255/15 "2017-08-11T19:34:42Z")

</div>

> [@cermak](#):
>
> Using the Particle CLI, my favorite in Terminal is just to do:
> 
> particle serial monitor --follow

Thanks for mentioning this. [I've added it to my Particle tab completion.](https://github.com/nrobinson2000/particle-cli-completion)

---

<div class="post-metadata">

**Author:** ![cermak](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/cermak/32/14174_2.png) [@cermak](https://community.particle.io/u/cermak)\
**Post date:** [August 11, 2017, 9:07pm UTC](https://community.particle.io/t/how-to-display-data-on-terminal/35255/16 "2017-08-11T21:07:52Z")

</div>

@manlin - I am not sure if you actually wanted to send information to your device. I tried a few different `screen` options and could not get the automatic CR/LF working properly when you pressed return/enter on the Mac. I had to build it into the code.

There is timer in there to produce output every 15 seconds on top of being just echoing the characters back to the screen. The “\>” is not necessary, but I needed to determine if the echo was actually coming from the Serial and not being produced by screen.

Sample code:

```auto
/*
 * Project twoWaySerial
 * Description: Test two way communication using Serial interface
 * and screen in MacOSX.
 * Author: Rob Cermak
 * Date: 2017-10-11
 */

void print_counter()
{
  static int count = 0;
  Serial.println(count++);
}

Timer timer(15000, print_counter);

// setup() runs once, when the device is first turned on.
void setup() {
  // Put initialization like pinMode and begin functions here.

  Serial.begin(9600);
  timer.start();

}

// loop() runs over and over again, as quickly as it can execute.
void loop() {
  // The core of your code will likely live here.

}

// Read input from the Serial port, you will
// need to add more code to actually perform
// an action based on provided input.
// Right now, everything read here will be
// echo'ed back to you.
void serialEvent()
{
  char c = Serial.read();
  if (c == 13) {
    // When using screen, we have to convert CR to CR/LF
    Serial.println();
  } else {
    Serial.printf(">%c",c);
  }
}

```

Screen command (match the baud rate and determine the serial port):

```auto
$ particle serial list
Found 1 device connected via serial:
/dev/cu.usbmodem1421 - Photon

$ screen /dev/cu.usbmodem1421 9600

```

Sample output in screen:

```auto
>T>h>i>s> >w>o>r>k>s> >w>e>l>l> >n>o>w>.
2
>W>e> >w>i>l>l> >l>e>t> >t>i>m>e> >t>i>c>k> >b>y> >t>o>o>.
3
4
5

```

---

<div class="post-metadata">

**Author:** ![johnflores619](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/johnflores619/32/15241_2.png) [@johnflores619](https://community.particle.io/u/johnflores619)\
**Post date:** [August 14, 2017, 11:44pm UTC](https://community.particle.io/t/how-to-display-data-on-terminal/35255/17 "2017-08-14T23:44:30Z")

</div>

Hi, I am. working on the same exact project, could we compare notes?

My only additional item is a gyro and accelerometer to measure water movement.

---

<div class="post-metadata">

**Author:** ![manlin](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/manlin/32/15222_2.png) [@manlin](https://community.particle.io/u/manlin)\
**Post date:** [August 15, 2017, 5:46pm UTC](https://community.particle.io/t/how-to-display-data-on-terminal/35255/18 "2017-08-15T17:46:32Z")

</div>

Hi @johnflores619, I am working on a project for my professor. It is confidential so I am afraid I can’t share the codes with you. I am sorry!
