Gboard 800 (SIM900 + ATmega 328) Greetings dear reader!

I have some trouble storing my IMEI code inside a variable. It always returns an error: "void value not ignored as it ought to be".

Since then I tried to write it to the serial line by just running the gsm.SimpleWriteln("AT+GSN"); AT command, but I am stuck at storing this displayed value inside a variable. Does anyone here know a way to store a serial value into a variable? I just want to send the IMEI code as an identifier to the cloud application...

Thanks in advance, your response is really appreciated.

The code:

#include "SIM900.h"
#include &lt;SoftwareSerial.h&gt;
//#include "inetGSM.h"
//#include "sms.h"
//#include "call.h"

//To change pins for Software Serial, use the two lines in GSM.cpp.

//GSM Shield for Arduino
//www.open-electronics.org
//this code is based on the example of Arduino Labs.

//Simple sketch to communicate with SIM900 through AT commands.

//InetGSM inet;
//CallGSM call;
//SMSGSM sms;

int numdata;
char inSerial[40];
int i=0;
boolean startUp = false;

void setup() {
  Serial.begin(9600);
  Serial.println("GSM Shield testing.");

  //Start configuration of shield with baudrate.
  //For http uses it is recommended to use 4800 or slower.
  if (gsm.begin(9600)) {
    Serial.println("\nstatus=READY");
    getIMEI();
  } else Serial.println("\nstatus=IDLE");
};

void loop() {
  //Read for new byte on serial hardware,
  //and write them on NewSoftSerial.
  serialhwread();
  //Read for new byte on NewSoftSerial.
  serialswread();
};

void serialhwread() {
  i=0;
  if (Serial.available() &gt; 0) {
    while (Serial.available() &gt; 0) {
      inSerial[i]=(Serial.read());
      delay(10);
      i++;
    }
    inSerial[i]='\0';
    if(!strcmp(inSerial,"/END")) {
      Serial.println("_");
      inSerial[0]=0x1a;
      inSerial[1]='\0';
      gsm.SimpleWriteln(inSerial);
    }
    //Send a saved AT command using serial port.
    if(!strcmp(inSerial,"TEST")) {
      Serial.println("SIGNAL QUALITY");
      gsm.SimpleWriteln("AT+CSQ");
    } else {
      Serial.println(inSerial);
      gsm.SimpleWriteln(inSerial);
    }
    inSerial[0]='\0';
  }
}

void serialswread() {
  gsm.SimpleRead();
}

void getIMEI() {
  long IMEI = gsm.SimpleWriteln("AT+GSN"); // IMEI code
  Serial.println(IMEI);
  return IMEI
}
The SimpleWriteln() function just sends an instruction. It doesn't return anything.  Once you have sent the instruction to retrieve the IMEI you then have to actually read the IMEI.

However, fortunately, there is a function that does it for you:

char imei[20];
gsm.getIMEI(imei);


The IMEI should now be in the C string imei. What you do with it then is up to you.