errore compilazione gsm arduino uno

Salve ottengo un errore nella compilazione di questo codice ,qualcuno puo aiutarmi ? :smiley:

#include "SIM900.h"
#include <SoftwareSerial.h>
#include "sms.h"

#define DEBUG_ON

int numdata;
boolean started=false;
char smsCHARbuffer[160];
char n[20];
int i,pos;

int LAMPEGGIO[10] = {2,49,87,48,53,44,48,50,182,3};
int AUTOMATICO[10] = {2,49,87,48,53,44,48,48,184,3};

SoftwareSerial mySerial(5, 4); // RX, TX
SMSGSM sms;

void setup()  
{ // Open serial communications and wait for port to open:
  Serial.begin(9600);   
  if (gsm.begin(2400)){
    Serial.println("\nstatus=READY");
    started=true;  
  }
  else Serial.println("\nstatus=IDLE");
  mySerial.begin(9600);
}

void loop() // run over and over
{
  if(started){
    //Read if there are messages on SIM card and print them.
    gsm.listen(); // IMPORTANT!!!!
    delay(200);
    pos = sms.IsSMSPresent(SMS_UNREAD);
    if (pos) 
    { //gsm.readSMS(smsCHARbuffer, 160, n, 20))
      gsm.readSMS(smsCHARbuffer, 160, n, 20)
      Serial.println(n);
      Serial.println(smsCHARbuffer);
      Serial.println("true");
      sms.DeleteSMS(pos);   // cancella il msg
    }
    /*
          sms.GetSMS(3, n, smsCHARbuffer, 160);
          Serial.println("DEBUG SMS phone number: ");
          Serial.println(n);
          Serial.println("SMS text: ");
          Serial.println(smsCHARbuffer);
*/          
/*
          for (i = 0; i < 10; i = i + 1) {
            delay(1);
            //Serial.print(LAMPEGGIO[i]);
            mySerial.write(LAMPEGGIO[i]);
          }
          
          sms.DeleteSMS(3);
          
      }
    */
    delay(1000);    
  }
  mySerial.listen();
  while(mySerial.available()){
      Serial.write(mySerial.read());
      delay(1);
    } 
 while(Serial.available()){
    mySerial.write(Serial.read()); 
    delay(1);  
  
  }
}

Una banalissima dimenticanza: hai dimenticato di inserire il terminatore di instruzione (:wink: nella riga precedente.

Hai perfettamente ragione !! :cold_sweat:

La funzione listen() non credo ci sia nella libreria. L'ha aggiunta il tipo del link che mi hai dato.
http://code.google.com/p/gsm-shield-arduino/issues/detail?id=43

Bisogna aggiungerla alla libreria. Lo dice al post #8
Dentro alla libreria c'e' gsm.h:

class GSM
{
  public:
    enum GSM_st_e { ERROR, IDLE, READY, ATTACHED, TCPSERVERWAIT, TCPCONNECTEDSERVER, TCPCONNECTEDCLIENT };
    byte comm_buf[COMM_BUF_LEN+1];  // communication buffer +1 for 0x00 termination
    void InitParam (byte group);
    void listen();            // AGGIUNGERE 
  private:

E al fondo del file gsm.cpp aggiungi:

void GSM::listen(void)
{  _cell.listen();
}

si hai ragione , lo avevo gia fatto e ora mi accetta l' istruzione gsm.listen(); ,con cui prima mi dava errore

ora riesco a compilarlo

#include "SIM900.h"
#include <SoftwareSerial.h>
#include "sms.h"

#define DEBUG_ON

int numdata;
boolean started=false;
char smsCHARbuffer[160];
char n[20];
int i,pos;

int LAMPEGGIO[10] = {2,49,87,48,53,44,48,50,182,3};
int AUTOMATICO[10] = {2,49,87,48,53,44,48,48,184,3};

SoftwareSerial mySerial(5, 4); // RX, TX
SMSGSM sms;

void setup()  
{ // Open serial communications and wait for port to open:
  Serial.begin(9600);   
  if (gsm.begin(2400)){
    Serial.println("\nstatus=READY");
    started=true;  
  }
  else Serial.println("\nstatus=IDLE");
  mySerial.begin(9600);
}

void loop() // run over and over
{
  if(started){
    //Read if there are messages on SIM card and print them.
    gsm.listen(); // IMPORTANT!!!!
    delay(200);
    pos = sms.IsSMSPresent(SMS_UNREAD);
    if (pos) 
    { //gsm.readSMS(smsCHARbuffer, 160, n, 20))
      gsm.readSMS(smsCHARbuffer, 160, n, 20);
      Serial.println(n);
      Serial.println(smsCHARbuffer);
      Serial.println("true");
      sms.DeleteSMS(pos);   // cancella il msg
    }
    /*
          sms.GetSMS(3, n, smsCHARbuffer, 160);
          Serial.println("DEBUG SMS phone number: ");
          Serial.println(n);
          Serial.println("SMS text: ");
          Serial.println(smsCHARbuffer);
*/          
/*
          for (i = 0; i < 10; i = i + 1) {
            delay(1);
            //Serial.print(LAMPEGGIO[i]);
            mySerial.write(LAMPEGGIO[i]);
          }
          
          sms.DeleteSMS(3);
          
      }
    */
    delay(1000);    
  }
  mySerial.listen();
  while(mySerial.available()){
      Serial.write(mySerial.read());
      delay(1);
    } 
 while(Serial.available()){
    mySerial.write(Serial.read()); 
    delay(1);  
  
  }
}

ma dal monitor seriale se telefono o mando messaggi ottengo solo questo

status=READY

true

Questo comando a cosa serve ? SoftwareSerial mySerial(5, 4); // RX, TX

Ad abilitare una comunicazione seriale utilizzando i pin 4 e 5.
In quell'articolo lui dice di aver fatto quella modifica perchè, dovendo utilizzare una ulteriore comunicazione seriale (quel comando) lo shield andava nel pallone.
Dubito allora che nel tuo caso possa essere quello il problema.
Tutta quella parte serve a lui per rispedire i dati tra due seriali. Levala o commentala.

mySerial.listen();
  while(mySerial.available()){
      Serial.write(mySerial.read());
      delay(1);
    } 
 while(Serial.available()){
    mySerial.write(Serial.read()); 
    delay(1);  
  }

Quindi questa riga : SoftwareSerial mySerial(5, 4); // RX, TX ,sarebbe la seriale del modulo gsm ?

Ma il modulo che ho io non ha la seriale

Fai pulizia:

#include "SIM900.h"
#include <SoftwareSerial.h>
#include "sms.h"

int numdata;
boolean started=false;
char smsCHARbuffer[160];
char n[20];
int i,pos;

SMSGSM sms;

void setup()  
{ // Open serial communications and wait for port to open:
  Serial.begin(9600);   
  if (gsm.begin(2400)){
    Serial.println("\nstatus=READY");
    started=true;  
  }
  else Serial.println("\nstatus=IDLE");
}

void loop() // run over and over
{
  if(started){
    //Read if there are messages on SIM card and print them.
    gsm.listen(); // IMPORTANT!!!!
    delay(200);
    pos = sms.IsSMSPresent(SMS_UNREAD);
    if (pos) 
    { //if(gsm.readSMS(smsCHARbuffer, 160, n, 20)) {
      gsm.readSMS(smsCHARbuffer, 160, n, 20);
      Serial.println(n);
      Serial.println(smsCHARbuffer);
      Serial.println("true");
      sms.DeleteSMS(pos);   // cancella il msg
    }
/*       sms.GetSMS(3, n, smsCHARbuffer, 160);
          Serial.println("DEBUG SMS phone number: ");
          Serial.println(n);
          Serial.println("SMS text: ");
          Serial.println(smsCHARbuffer);
          sms.DeleteSMS(3);
*/
    delay(1000);    
  }
}

Ora, il comando per abilitare il debug della libreria:
#define DEBUG_ON

Non va nel tuo sketch, ma va messo dentro alla libreria.
File GSM.H riga 20 c'e' già devi solo togliere il commento.
Con quello dovresti su Monitor Seriale vedere una serie di msg che indicano cosa sta ricevendo (spero) :smiley:

In GSM.h c'è gia pero è commentato gli levo le //

#ifndef GSM_H
#define GSM_H

#define UNO
//#define MEGA

#include <SoftwareSerial.h>
#include <inttypes.h>
#include "WideTextFinder.h"

#define ctrlz 26 //Ascii character for ctr+z. End of a SMS.
#define cr    13 //Ascii character for carriage return. 
#define lf    10 //Ascii character for line feed. 
#define ctrlz 26 //Ascii character for ctr+z. End of a SMS.
#define cr    13 //Ascii character for carriage return. 
#define lf    10 //Ascii character for line feed.
#define GSM_LIB_VERSION 308 // library version X.YY (e.g. 1.00)

//#define DEBUG_ON


#ifdef MEGA
	#include "HWSerial.h"
#endif
// if defined - debug print is enabled with possibility to print out 
// debug texts to the terminal program
//#define DEBUG_PRINT

// if defined - debug print is enabled with possibility to print out 
// the data recived from gsm module
//#define DEBUG_GSMRX

// if defined - debug LED is enabled, otherwise debug LED is disabled
//#define DEBUG_LED_ENABLED

// if defined - SMSs are not send(are finished by the character 0x1b
// which causes that SMS are not send)
// by this way it is possible to develop program without paying for the SMSs 
//#define DEBUG_SMS_ENABLED


// pins definition
#define GSM_ON              8 // connect GSM Module turn ON to pin 77 
#define GSM_RESET           9 // connect GSM Module RESET to pin 35
//#define DTMF_OUTPUT_ENABLE  71 // connect DTMF Output Enable not used
#define DTMF_DATA_VALID     14 // connect DTMF Data Valid to pin 14
#define DTMF_DATA0          72 // connect DTMF Data0 to pin 72
#define DTMF_DATA1          73 // connect DTMF Data1 to pin 73
#define DTMF_DATA2          74 // connect DTMF Data2 to pin 74
#define DTMF_DATA3          75 // connect DTMF Data3 to pin 75

// length for the internal communication buffer
#define COMM_BUF_LEN        200

// some constants for the IsRxFinished() method
#define RX_NOT_STARTED      0
#define RX_ALREADY_STARTED  1

// some constants for the InitParam() method
#define PARAM_SET_0   0
#define PARAM_SET_1   1

// DTMF signal is NOT valid
//#define DTMF_NOT_VALID      0x10


// status bits definition
#define STATUS_NONE                 0
#define STATUS_INITIALIZED          1
#define STATUS_REGISTERED           2
#define STATUS_USER_BUTTON_ENABLE   4

// GPRS status
#define CHECK_AND_OPEN    0
#define CLOSE_AND_REOPEN  1



// SMS type 
// use by method IsSMSPresent()
enum sms_type_enum
{
  SMS_UNREAD,
  SMS_READ,
  SMS_ALL,

  SMS_LAST_ITEM
};

enum comm_line_status_enum 
{
  // CLS like CommunicationLineStatus
  CLS_FREE,   // line is free - not used by the communication and can be used
  CLS_ATCMD,  // line is used by AT commands, includes also time for response
  CLS_DATA,   // for the future - line is used in the CSD or GPRS communication  
  CLS_LAST_ITEM
};

enum rx_state_enum 
{
  RX_NOT_FINISHED = 0,      // not finished yet
  RX_FINISHED,              // finished, some character was received
  RX_FINISHED_STR_RECV,     // finished and expected string received
  RX_FINISHED_STR_NOT_RECV, // finished, but expected string not received
  RX_TMOUT_ERR,             // finished, no character received 
                            // initial communication tmout occurred
  RX_LAST_ITEM
};


enum at_resp_enum 
{
  AT_RESP_ERR_NO_RESP = -1,   // nothing received
  AT_RESP_ERR_DIF_RESP = 0,   // response_string is different from the response
  AT_RESP_OK = 1,             // response_string was included in the response

  AT_RESP_LAST_ITEM
};

enum registration_ret_val_enum 
{
  REG_NOT_REGISTERED = 0,
  REG_REGISTERED,
  REG_NO_RESPONSE,
  REG_COMM_LINE_BUSY,
    
  REG_LAST_ITEM
};

enum call_ret_val_enum
{
  CALL_NONE = 0,
  CALL_INCOM_VOICE,
  CALL_ACTIVE_VOICE,
  CALL_INCOM_VOICE_AUTH,
  CALL_INCOM_VOICE_NOT_AUTH,
  CALL_INCOM_DATA_AUTH,
  CALL_INCOM_DATA_NOT_AUTH,
  CALL_ACTIVE_DATA,
  CALL_OTHERS,
  CALL_NO_RESPONSE,
  CALL_COMM_LINE_BUSY,

  CALL_LAST_ITEM
};


enum getsms_ret_val_enum
{
  GETSMS_NO_SMS   = 0,
  GETSMS_UNREAD_SMS,
  GETSMS_READ_SMS,
  GETSMS_OTHER_SMS,

  GETSMS_NOT_AUTH_SMS,
  GETSMS_AUTH_SMS,

  GETSMS_LAST_ITEM
};


class GSM
{
  public:
    enum GSM_st_e { ERROR, IDLE, READY, ATTACHED, TCPSERVERWAIT, TCPCONNECTEDSERVER, TCPCONNECTEDCLIENT };
    byte comm_buf[COMM_BUF_LEN+1];  // communication buffer +1 for 0x00 termination
    void InitParam (byte group);

  private:
    int _status;
    byte comm_line_status;

    // global status - bits are used for representation of states
    byte module_status;

    // variables connected with communication buffer
    
    byte *p_comm_buf;               // pointer to the communication buffer
    byte comm_buf_len;              // num. of characters in the buffer
    byte rx_state;                  // internal state of rx state machine    
    uint16_t start_reception_tmout; // max tmout for starting reception
    uint16_t interchar_tmout;       // previous time in msec.
    unsigned long prev_time;        // previous time in msec.

    // last value of speaker volume
    byte last_speaker_volume; 
    char InitSMSMemory(void);

  protected:
	#ifdef MEGA
		HWSerial _cell;
	#endif
	#ifdef UNO
		SoftwareSerial _cell;
	#endif
    int isIP(const char* cadena);

  public:
	#ifdef UNO
		WideTextFinder _tf;
	#endif
    inline void setStatus(GSM_st_e status) { _status = status; }  
    GSM();
    inline int getStatus(){   return _status; };
    virtual int begin(long baud_rate);   
    inline void SetCommLineStatus(byte new_status) {comm_line_status = new_status;};
    inline byte GetCommLineStatus(void) {return comm_line_status;};
    void RxInit(uint16_t start_comm_tmout, uint16_t max_interchar_tmout);
    byte IsRxFinished(void);
    byte IsStringReceived(char const *compare_string);
    byte WaitResp(uint16_t start_comm_tmout, uint16_t max_interchar_tmout);
    byte WaitResp(uint16_t start_comm_tmout, uint16_t max_interchar_tmout, 
    char const *expected_resp_string);
    char SendATCmdWaitResp(char const *AT_cmd_string,
	uint16_t start_comm_tmout, uint16_t max_interchar_tmout,
	char const *response_string,
	byte no_of_attempts);
	char SendATCmdWaitResp(const __FlashStringHelper *AT_cmd_string,
                uint16_t start_comm_tmout, uint16_t max_interchar_tmout,
                char const *response_string,
                byte no_of_attempts);	
	void Echo(byte state);
	void listen();


	//-----------------------
	// turns off/on the speaker
	void SetSpeaker(byte off_on);
	// checks if module is registered in the GSM network
	// must be called regularly
	byte CheckRegistration(void);

	// User button methods
	inline byte IsUserButtonEnable(void) {return (module_status & STATUS_USER_BUTTON_ENABLE);};
	inline void DisableUserButton(void) {module_status &= ~STATUS_USER_BUTTON_ENABLE;};
	inline void EnableUserButton(void) {module_status |= STATUS_USER_BUTTON_ENABLE;};
	byte IsUserButtonPushed(void);  

	// Phonebook's methods
	char GetPhoneNumber(byte position, char *phone_number);
	char WritePhoneNumber(byte position, char *phone_number);
	char DelPhoneNumber(byte position);
	char ComparePhoneNumber(byte position, char *phone_number);

	// returns registration state
	byte IsRegistered(void);
	// returns whether complete initialization was made
	byte IsInitialized(void);
	//-----------------------

    // debug methods
	#ifdef DEBUG_LED_ENABLED
			void BlinkDebugLED (byte num_of_blink);
	#endif

	#ifdef DEBUG_PRINT
		void DebugPrint(const char *string_to_print, byte last_debug_print);
		void DebugPrint(int number_to_print, byte last_debug_print);
	#endif

};


#endif

va solo li ?

Perfetto ora ottengo il debug :slight_smile:

questo è quello che mi da nel monitore seriale ( lo ho tagliuzzato che era lunghissimo)

ATT: 
OKRIC: AT

OK

DB:ELSE
ATT: 
OKRIC: AT

OK

DB:ELSE
ATT: 
OKRIC: AT

OK

DB:ELSE
ATT: 
OKRIC: AT

OK

DB:CORRECT BR
ATT: 
OKRIC: AT

OK

ATT: 
OKRIC: AT&F

OK

ATT: 
OKRIC: ATE0

OK

ATT: 
OKRIC: 
OK

ATT: 
OKRIC: 
OK

ATT: 
OKRIC: 
OK

ATT: 
OKRIC: 
OK

ATT: 
+CPMS:RIC: 
+CPMS: 1,50,1,50,1,50

OK

ATT: 
OKRIC: 
OK

ATT: 
SHUT OKRIC: 
SHUT OK


status=READY
ATT: 
OKRIC: 

ATT: 
OKRIC: 

ATT: 
OKRIC: 
O
ATT: 
OKRIC: 
OK

ATT: 
+CMGL:RIC: 
OK

ATT: 
OKRIC: 

ATT: 
OKRIC: 

OKRIC: 
O
ATT: 
OKRIC: 
OK

ATT: 
+CMGL:RIC: 
OK

ATT: 
OKRIC: 

ATT: 
OKRIC: 

ATT: 
OKRIC: 
O
ATT: 
OKRIC: 
OK

ATT: 
+CMGL:RIC: 
OK

ATT: 
OKRIC: 

ATT: 
OKRIC: 

ATT: 
OKRIC: 
O
ATT: 
OKRIC: 
OK

ATT: 
+CMGL:RIC: 
OK

ATT: 
OKRIC: 

ATT: 
OKRIC: 

ATT: 
OKRIC: 
O
ATT: 
OKRIC: 
OK

ATT: 
+CMGL:RIC: 
OK

ATT: 
OKRIC: 

ATT: 
OKRIC: 

ATT: 
OKRIC: 
O
ATT: 
OKRIC: 
OK

ATT: 
+CMGL:RIC: 
OK

ATT: 
OKRIC: 

ATT: 
OKRIC: 

ATT: 
OKRIC: 
OK
ATT: 
+CMGL:RIC: 
OK
ATT: 
OKRIC: 

ATT: 
OKRIC: 

ATT: 
OKRIC: 
OK
ATT: 
+CMGL:RIC: 
OK
ATT: 
OKRIC: 

ATT: 
OKRIC: 
----------------------------------------------------------------------
qui ho fatto una telefonata al modulo gsm arduino
ATT: 
OKRIC: 
R
ATT: 
OKRIC: 
RIN
ATT: 
OKRIC: 
RING
ATT: 
OKRIC: 
RING

+CLIP: 
ATT: 
OKRIC: 
RING

+CLIP: "+3934593xxxxx",1
ATT: 
OKRIC: 
RING

+CLIP: "+3934593xxxxx",145,"",,"",0

ATT: 
OKRIC: 
RING

+CLIP: "+3934593xxxxx",145,"",,"",0

ATT: 
OKRIC: 
RING

+CLIP: "+3934593xxxxx",145,"",,"",0

OK

ATT: 
+CMGL:RIC: 
RING

+CLIP: "+3934593xxxxx",145,"",,"",0

OK

ATT: 
OKRIC: 

ATT: 
OKRIC: 

ATT: 
OKRIC: 
O
ATT: 
OKRIC: 
OK

ATT: 
+CMGL:RIC: 
OK

ATT: 
OKRIC: 

ATT: 
OKRIC: 

ATT: 
OKRIC: 
O
ATT: 
OKRIC: 
OK

ATT: 
+CMGL:RIC: 
OK

ATT: 
OKRIC: 

ATT: 
OKRIC: 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
qui ho mandato il messaggio ------ on ----------

ATT: 
OKRIC: 
+
ATT: 
OKRIC: 
+CM
ATT: 
OKRIC: 
+CMG
ATT: 
OKRIC: 
+CMGL: 1,"REC U
ATT: 
OKRIC: 
+CMGL: 1,"REC UNREAD","+39345938
ATT: 
OKRIC: 
+CMGL: 1,"REC UNREAD","+39345938xxxx","","13/06/24,15:07:
ATT: 
OKRIC: 
+CMGL: 1,"REC UNREAD","+39345938xxxx","","13/06/24,15:07:28+08"
on

OK

ATT: 
+CMGL:RIC: 
+CMGL: 1,"REC UNREAD","+39345938xxxx","","13/06/24,15:07:28+08"
on

OK

ATT: 
+CMGLRIC: 
OK

Le ultime righe, "REC UNREAD" è una frase stampata dalla IsSMSPresent() e indica un sms non letto.

+CMGL: 1,"REC UNREAD","+39345938xxxx","","13/06/24,15:07:28+08"

Hai questo messaggio tra gli sms? Cosa gli hai inviato?

Modifichiamo la loop(), secondo me bisogna usare la getSMS() e non la readSMS() e ci facciamo stampare pos

void loop() // run over and over
{
  if(started){
    //Read if there are messages on SIM card and print them.
    gsm.listen(); // IMPORTANT!!!!
    delay(200);
    pos = sms.IsSMSPresent(SMS_UNREAD);
    Serial.print("pos: "); Serial.println(pos);
    if (pos>0) 
    { sms.GetSMS(3, n, smsCHARbuffer, 160);
      gsm.readSMS(smsCHARbuffer, 160, n, 20);
      Serial.println(n);
      Serial.println(smsCHARbuffer);
      Serial.println("true");
      sms.DeleteSMS(pos);   // cancella il msg
    }
    delay(1000);    
  }
}

Ottengo questo

ATT: 
OKRIC: 
OK

DB:ELSE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T: 
OKRIC: 

ATT: 
OKRIC: 

ATT: 
OKRIC: 
+
ATT: 
OKRIC: 
+CM
ATT: 
OKRIC: 
+CMGL
ATT: 
OKRIC: 
+CMGL: 1,"REC UN
ATT: 
OKRIC: 
+CMGL: 1,"REC UNREAD","+393459380
ATT: 
OKRIC: 
+CMGL: 1,"REC UNREAD","+393459380405","","13/06/24,15:46:3
ATT: 
OKRIC: 
+CMGL: 1,"REC UNREAD","+393459380405","","13/06/24,15:46:34+08"
Messaggio

OK

ATT: 
+CMGL:RIC: 
+CMGL: 1,"REC UNREAD","+393459380405","","13/06/24,15:46:34+08"
Messaggio

OK

ATT: 
+CMGRRIC: 
OK

ATT: 
OKRIC: 
OK

ATT: 
+CMGLRIC: 
OK

ATT: 
OKRIC: 
ERROR



true
ATT: 
OKRIC: 
OK

ATT: 
OKRIC: 

ATT: 
OKRIC: 

ATT: 
OKRIC: 
OK
ATT: 
+CMGL:RIC: 
OK
ATT: 
OKRIC: 

ATT: 
OKRIC: 

ATT: 
OKRIC: 
OK
ATT: 
+CMGL:RIC: 
OK
ATT: 
OKRIC: 

ATT: 
OKRIC: 

ATT: 
OKRIC: 
O
ATT: 
OKRIC: 
OK

ATT: 
+CMGL:RIC: 
OK

ATT: 
OKRIC: 

ATT: 
OKRIC: 

ATT: 
OKRIC: 
OK
ATT: 
+CMGL:RIC: 
OK
ATT: 
OKRIC: 

ATT: 
OKRIC: 

ATT: 
OKRIC: 
OK
ATT: 
+CMGL:RIC: 
OK
ATT: 
OKRIC: 

ATT: 
OKRIC: 

ATT: 
OKRIC: 
OK
ATT: 
+CMGL:RIC: 
OK
ATT: 
OKRIC: 

ATT: 
OKRIC: 

ATT: 
OKRIC: 
OK
ATT: 
+CMGL:RIC: 
OK
ATT: 
OKRIC: 

ATT: 
OKRIC: 

ATT: 
OKRIC: 
OK
ATT: 
+CMGL:RIC: 
OK
ATT: 
OKRIC: 

ATT: 
OKRIC: 

ATT: 
OKRIC: 
O
ATT: 
OKRIC: 
OK

ATT: 
+CMGL:RIC: 
OK

ATT: 
OKRIC: 

ATT: 
OKRIC: 

ATT: 
OKRIC: 
O
ATT: 
OKRIC: 
OK

ATT: 
+CMGL:RIC: 
OK

ATT: 
OKRIC:

Scusa, ho lasciato degli errori:

void loop() // run over and over
{
  if(started){
    //Read if there are messages on SIM card and print them.
    gsm.listen(); // IMPORTANT!!!!
    delay(200);
    pos = sms.IsSMSPresent(SMS_UNREAD);
    Serial.print("pos: "); Serial.println(pos);
    if (pos>0) 
    { sms.GetSMS(pos, n, smsCHARbuffer, 160);
      Serial.println(n);
      Serial.println(smsCHARbuffer);
      Serial.println("true");
      sms.DeleteSMS(pos);   // cancella il msg
    }
    delay(1000);    
  }
}

Dovrebbe stamparti un pos: qualcosa

Nelle librerie, nel file GSM.cpp ho letto queste righe (dalla riga 20):
//De-comment this two lines below if you have the
//first version of GSM GPRS Shield
//#define GSM_TXPIN 4
//#define GSM_RXPIN 5

//De-comment this two lines below if you have the
//second version og GSM GPRS Shield
#define GSM_TXPIN 2
#define GSM_RXPIN 3

Non è che tu hai una scheda GSM che utilizza i primi pin? Leggi bene sulla documentazione

Prima del messaggio pos : 0 , nel messaggio pos :3 :slight_smile:

ATT: 
OKRIC: 
O
ATT: 
OKRIC: 
OK

ATT: 
+CMGL:RIC: 
OK

pos: 0
ATT: 
OKRIC: 

ATT: 
OKRIC: 

ATT: 
OKRIC: 
OK
ATT: 
+CMGL:RIC: 
OK
pos: 0
ATT: 
OKRIC: 

ATT: 
OKRIC: 

ATT: 
OKRIC: 
+C
ATT: 
OKRIC: 
+CM
ATT: 
OKRIC: 
+CMGL
ATT: 
OKRIC: 
+CMGL: 3,"REC UN
ATT: 
OKRIC: 
+CMGL: 3,"REC UNREAD","+393459380
ATT: 
OKRIC: 
+CMGL: 3,"REC UNREAD","+393459380405","","13/06/24,16:11:04
ATT: 
OKRIC: 
+CMGL: 3,"REC UNREAD","+393459380405","","13/06/24,16:11:04+08"
Messaggio

OK

ATT: 
+CMGL:RIC: 
+CMGL: 3,"REC UNREAD","+393459380405","","13/06/24,16:11:04+08"
Messaggio

OK

pos: 3
ATT: 
+CMGRRIC: 
+CMGR: "REC READ","+393459380405","","13/06/24,16:11:04+08"
Messaggio

OK

ATT: 
"REC UNREAD"RIC: 
+CMGR: "REC READ","+393459380405","","13/06/24,16:11:04+08"
Messaggio

OK

ATT: 
"REC READ"RIC: 
+CMGR: "REC READ","+393459380405","","13/06/24,16:11:04+08"
Messaggio

OK

+393459380405
Messaggio
true
ATT: 
OKRIC: 
OK

ATT: 
OKRIC: 

ATT: 
OKRIC: 

ATT: 
OKRIC: 
OK
ATT: 
+CMGL:RIC: 
OK
pos: 0
ATT: 
OKRIC: 

ATT: 
OKRIC:

Quindi ha ricevuto ?!

+393459380405
Messaggio
true

Hai spedito "Messaggio" nell'sms ?

Se okay, allora al posto di quel

    Serial.println(n);
    Serial.println(smsCHARbuffer);
    Serial.println("true");

puoi mettere:

    Serial.print("Cell="); Serial.println(n);
    Serial.print("Sms="); Serial.print(smsCHARbuffer); Serial.println("#endmsg#");
    if( strncmp(smsCHARbuffer,"ledon",5)==0 ) 
    { Serial.println("led acceso");
      digitalWrite(ledPin,HIGH);
    }
    if( strncmp(smsCHARbuffer,"ledoff",6)==0 ) 
    { Serial.println("led spento");
      digitalWrite(ledPin,LOW);
    }

Volevi accendere/spegnere un led via sms giusto?
Ricorda di dichiarare in alto const byte ledPin=13;
e nella setup() pinMode(ledPin,OUTPUT);

si è giusto il mio messaggio erea (messaggio)