Nucleo and Serial Communication with GSM/GPRS shield

11 Dec 2018

Hello, i have a problem with nucleo board. I want to send a SMS with GSM module connected with serial PA_9 (TX) and PA_10 (RX) line of Nucleo with RX pin and TX of modem. The circuital scheme provides two line on gsm to UART of Nucleo Board. TX Nucleo -> RX GSM RX Nucleo -> TX GSM besides VCC and Ground. The SMS have to send when the ir sensor try to discover an fire. I have wrote a code

#include "mbed.h"
#include "string.h"
int main () { 
   Serial pc (USBTX,USBRX);
   Serial gsm (D1,D0);
   DigitalIn din(D4);
   //int sensore;
   pc.baud(9600);
   gsm.baud(9600);
    char *text="Allarme Incendio Intevenire\0x1a";
   // Occorre lavorare solo con stringhe AT che devono terminare sempre con \r\nn//
   char *at1="AT\r\n";
   char *at2="AT+SMSTEST\r\n";
   char *at3="AT+CGMF=1 \r\n";
   char *at4="AT+CMGS=3511651227\r\n";
   while(1) {
   gsm.printf("%s",at1);
     
        if(gsm.readable()) {
            pc.putc(gsm.getc());
        }
     gsm.printf("%s",at2);
     
        if(gsm.readable()) {
            pc.putc(gsm.getc());
        
        }
      gsm.printf("%s",at3);
     
        if(gsm.readable()) {
            pc.putc(gsm.getc());
        }
      gsm.printf("%s",at3);
    
        if(gsm.readable()) {
            pc.putc(gsm.getc());
        }
          gsm.printf("%s",at4);
     
        if(gsm.readable()) {
            pc.putc(gsm.getc());
        }
    gsm.printf("%s",text);
 }

Can someone help me ? Thank for attention