user-1: I'm trying to communicate with the Arduino through the serial port to fade the LED. 
There's the code running on my Arduino:
#include <aJSON.h>
aJsonStream serial_stream(&Serial);

const int localID = 1;
int intensity = 100;        // fadeTo value(0% - 100%)
int currentIntensity = 0;   // how bright the LED actually is (0-100%) 
int time = 0;               // milliseconds
int color[] = {0, 255, 0};

int pinRed = 11;
int pinGreen = 10;
int pinBlue = 9;
int pinPower = 8;

void fadeTo() {
  if(intensity != currentIntensity) {
    if(intensity > currentIntensity)
      currentIntensity+=1;
    else
      currentIntensity-=1;

    analogWrite(pinRed,255-currentIntensity);
    analogWrite(pinGreen,255-currentIntensity);
    analogWrite(pinBlue,255-currentIntensity);
  }
}

aJsonObject *createMsg()
{
    aJsonObject *orbData, *colorData;

    orbData = aJson.createObject();
    aJson.addNumberToObject(orbData, "id", (int)localID);

    aJson.addNumberToObject(orbData, "currentIntensity", (int)currentIntensity);

    //aJson.addNumberToObject(orbData, "time", (int)time);

    colorData = aJson.createIntArray(color, 3);
    aJson.addItemToObject(orbData, "color", colorData);

    return orbData;
}

// echo {\"id\":1, \"intensity\":150, \"time\":10} >> /dev/ttyACM0 in terminal
// {"id":1, "intensity":150, "time":10} in Serial Monitor
void processMsg(aJsonObject *msg)
{
    //Serial.println("Data succefully received.");
    Serial.println("received message: ");
    aJson.print(msg, &serial_stream);

    aJsonObject *idData = aJson.getObjectItem(msg, "id");
    if(idData != NULL) 
    {
        Serial.println("ID data succefully received.");
        if(localID == (idData->valueint)) {

            aJsonObject *intensityData = aJson.getObjectItem(msg, "intensity");
            if(intensityData != NULL) {
                if(intensityData->type != aJson_Int) {
                    Serial.println("Invalid data type for Intensity");
                    return;
                }

                if(intensityData->valueint == currentIntensity) {
                    Serial.println("The received intensity value is already the current LED intensity");
                    return;
                }

                else {
                    Serial.println("Intensity data succefully received");
                    intensity = intensityData->valueint;
                }
            }
            else {
                Serial.println("No intensity value received.");
                return;
            }

            aJsonObject *timeData = aJson.getObjectItem(msg, "time");
            if(timeData != NULL) {
                if(timeData->type != aJson_Int) {
                    Serial.println("Invalid data type for time");
                    return;
                }
                else {
                    Serial.println("Time data succefully received");
                    time = (timeData->valueint);
                }
            }
        }

        else {
          Serial.println("The received ID is not mine.");
          return;  
        }  
    }

    else {
      Serial.println("No ID data received.");
      return;
    }

    Serial.println("received message: ");
    aJson.print(msg, &serial_stream);
}

void setup()
{
    Serial.begin(9600);

    pinMode(pinRed,OUTPUT);
    pinMode(pinGreen,OUTPUT);
    pinMode(pinBlue,OUTPUT);
    pinMode(pinPower,OUTPUT);

    digitalWrite(pinPower,HIGH);
    digitalWrite(pinRed,HIGH);
    digitalWrite(pinGreen,HIGH);
    digitalWrite(pinBlue,HIGH);
}

void loop()
{
    aJsonObject *orbData = createMsg();

    Serial.println("current status: ");
    aJson.print(orbData, &serial_stream);

    Serial.println();

    aJson.deleteItem(orbData);
    delay(100);

    fadeTo();

}


void serialEvent()
{
    if(serial_stream.available())
    {
        // first, skip any accidental whitespace like newlines
        serial_stream.skip();
    }

    if(serial_stream.available())
    {
        aJsonObject *msg = aJson.parse(&serial_stream);

        processMsg(msg);

        aJson.deleteItem(msg);
    }
}

The problem is, I can open my Serial Monitor in the Arduino IDE and send json data to the Arduino and I see live the changes through the output and the LED on the board. I can also send data through terminal to /dev/ttyACM0 while running Serial Monitor in the IDE and it works fine too. But as soon as I close the Serial Monitor and send data to the device through terminal, it breaks down. I can then open Serial Monitor and every time I get the ERROR from json parser --> ("No ID data received.").
Has anyone any idea why this is happening?

user3793: I had a similar problem trying to use the commands such as :

echo 1 > /dev/ttyACM0

and found that I needed privileges to perform serial communication in this way like:

sudo echo 1 > /dev/ttyACM0

You could also try setting the baud rate you are communicating at :

sudo echo 1 > /dev/ttyACM0 9600

GOOD LUCK!

-1: <p>I'm trying to communicate with the Arduino through the serial port to fade the LED. 
There's the code running on my Arduino:</p>

<pre><code>#include &lt;aJSON.h&gt;
aJsonStream serial_stream(&amp;Serial);

const int localID = 1;
int intensity = 100;        // fadeTo value(0% - 100%)
int currentIntensity = 0;   // how bright the LED actually is (0-100%) 
int time = 0;               // milliseconds
int color[] = {0, 255, 0};

int pinRed = 11;
int pinGreen = 10;
int pinBlue = 9;
int pinPower = 8;

void fadeTo() {
  if(intensity != currentIntensity) {
    if(intensity &gt; currentIntensity)
      currentIntensity+=1;
    else
      currentIntensity-=1;

    analogWrite(pinRed,255-currentIntensity);
    analogWrite(pinGreen,255-currentIntensity);
    analogWrite(pinBlue,255-currentIntensity);
  }
}

aJsonObject *createMsg()
{
    aJsonObject *orbData, *colorData;

    orbData = aJson.createObject();
    aJson.addNumberToObject(orbData, "id", (int)localID);

    aJson.addNumberToObject(orbData, "currentIntensity", (int)currentIntensity);

    //aJson.addNumberToObject(orbData, "time", (int)time);

    colorData = aJson.createIntArray(color, 3);
    aJson.addItemToObject(orbData, "color", colorData);

    return orbData;
}

// echo {\"id\":1, \"intensity\":150, \"time\":10} &gt;&gt; /dev/ttyACM0 in terminal
// {"id":1, "intensity":150, "time":10} in Serial Monitor
void processMsg(aJsonObject *msg)
{
    //Serial.println("Data succefully received.");
    Serial.println("received message: ");
    aJson.print(msg, &amp;serial_stream);

    aJsonObject *idData = aJson.getObjectItem(msg, "id");
    if(idData != NULL) 
    {
        Serial.println("ID data succefully received.");
        if(localID == (idData-&gt;valueint)) {

            aJsonObject *intensityData = aJson.getObjectItem(msg, "intensity");
            if(intensityData != NULL) {
                if(intensityData-&gt;type != aJson_Int) {
                    Serial.println("Invalid data type for Intensity");
                    return;
                }

                if(intensityData-&gt;valueint == currentIntensity) {
                    Serial.println("The received intensity value is already the current LED intensity");
                    return;
                }

                else {
                    Serial.println("Intensity data succefully received");
                    intensity = intensityData-&gt;valueint;
                }
            }
            else {
                Serial.println("No intensity value received.");
                return;
            }

            aJsonObject *timeData = aJson.getObjectItem(msg, "time");
            if(timeData != NULL) {
                if(timeData-&gt;type != aJson_Int) {
                    Serial.println("Invalid data type for time");
                    return;
                }
                else {
                    Serial.println("Time data succefully received");
                    time = (timeData-&gt;valueint);
                }
            }
        }

        else {
          Serial.println("The received ID is not mine.");
          return;  
        }  
    }

    else {
      Serial.println("No ID data received.");
      return;
    }

    Serial.println("received message: ");
    aJson.print(msg, &amp;serial_stream);
}

void setup()
{
    Serial.begin(9600);

    pinMode(pinRed,OUTPUT);
    pinMode(pinGreen,OUTPUT);
    pinMode(pinBlue,OUTPUT);
    pinMode(pinPower,OUTPUT);

    digitalWrite(pinPower,HIGH);
    digitalWrite(pinRed,HIGH);
    digitalWrite(pinGreen,HIGH);
    digitalWrite(pinBlue,HIGH);
}

void loop()
{
    aJsonObject *orbData = createMsg();

    Serial.println("current status: ");
    aJson.print(orbData, &amp;serial_stream);

    Serial.println();

    aJson.deleteItem(orbData);
    delay(100);

    fadeTo();

}


void serialEvent()
{
    if(serial_stream.available())
    {
        // first, skip any accidental whitespace like newlines
        serial_stream.skip();
    }

    if(serial_stream.available())
    {
        aJsonObject *msg = aJson.parse(&amp;serial_stream);

        processMsg(msg);

        aJson.deleteItem(msg);
    }
}
</code></pre>

<p>The problem is, I can open my Serial Monitor in the Arduino IDE and send json data to the Arduino and I see live the changes through the output and the LED on the board. I can also send data through terminal to /dev/ttyACM0 while running Serial Monitor in the IDE and it works fine too. But as soon as I close the Serial Monitor and send data to the device through terminal, it breaks down. I can then open Serial Monitor and every time I get the ERROR from json parser --> ("No ID data received.").</p>

<p>Has anyone any idea why this is happening?</p>
 3793: <p>I had a similar problem trying to use the commands such as :</p>

<blockquote>
  <p>echo 1 > /dev/ttyACM0</p>
</blockquote>

<p>and found that I needed privileges to perform serial communication in this way like:</p>

<blockquote>
  <p>sudo echo 1 > /dev/ttyACM0</p>
</blockquote>

<p>You could also try setting the baud rate you are communicating at :</p>

<blockquote>
  <p>sudo echo 1 > /dev/ttyACM0 9600</p>
</blockquote>

<p>GOOD LUCK!</p>
