6 years, 1 month ago.

Problem with GSM.H library and SIM800L

I wrote a code that tries to send Sms to a phone number when it happens a condition. On the Sim card Pin is not enable. On the serial terminal I receive this error AT+CPIN?, I think it wants a pin. It's true ? My code is:

  1. include "GSM.h"
  2. include <string.h> int main () { Serial pc (USBTX,USBRX); DigitalIn din(D4); int sensore; pc.baud(9600); char *text="Allarme Incendio Intevenire"; char *num_emergenza="3440427496"; char *numerosim="3336698060"; char *cmddata="AT+CPIN="; char *pin="3685"; char *messaggio; /*il Codice Pin della scheda*/ strcat(cmddata,""); GSM gsm=GSM(D1,D0,9600,numerosim); /*gsm.sendCmd(cmddata);*/ while (true){ din.read(); sensore = din; printf("%d", sensore); gsm.getSMS(messaggio); pc.printf("%s",messaggio);

/*printf("%d", gsm.checkSIMStatus());*/ if (din) { pc.printf("Rilevata Fiamma nella zona\n"); /*D3 e D4 devono essere i nomi dei pin ove sono collegati tx e rx */

if (0==gsm.checkSignalStrength()) { printf("Segnale GSM presente\n");} if (0!= gsm.init()){ printf("Errore nell'inizializzazione\n"); } else { pc.printf("Inizializzazione Ok\n"); gsm.settingSMS(); if (0 == gsm.sendSMS(num_emergenza,text)) { printf("Messaggio invio con successo \n"); } else { printf("Errore nell'invio SMS \n"); } } } } }

Thanks a bunch for your attention

Be the first to answer this question.