How to code GSM-GPS Click Sim808 using STM32F446RE?

Please could someone help me with a suitable library to program my GSM-GPS click sim808 which can send SMS and get exact location ?

Hello,

another MicroE product :slight_smile:

When you check GSM-GPS click - schematic you can see there is a SIM808 module with some necessary components, leds, level convertor and finished with a MicroE MicroBbus.
So again there is not special commponents what can block direct communication with the module and SIM808 datasheet is usable and useful.
In the datasheet you can found the module is able to communicate via AT commands, which is easy. At the end of datasheet it refer to SIM808 AT Command Manual. It seems in this manual you can found all necessary commands for control of what you will need and also with a description.

In the basic you can use the Nucleo as UART repeater or a FTDI USB To TTL Serial Converter (If you have one) and send AT Commands directly from a PC Terminal for some testing.
For cooperation with Mbed you can use ATCmdParser - API references and tutorials | Mbed OS 6 Documentation

As some inspiration you can try to found some codes of another sides

BR, Jan

Good Afternoon Sir, I’m really happy you responded . Thanks a lot
Well understood . I don’t really know if I would be able to get it right since these are my first attempts with all these components and also new to the platform. But definitively , will try something with your guidance and come back to you ASAP .

Was also wondering , please do you train if yes, can we chat through mail ? my email is as follow : Abenasam27@gmail.com

thanks and have good day …

Nope I don’t do anything like that.

Theoretically, you can start directly with the ATCmdParser example. Change only UART pins according to your wiring.

BR, Jan

Oh ok Sir, well noted, thank you so much.

Hello Sir
Please I have tried several times to use the ATCmdParser example, but it keep telling me BufferedSerial is undefined .Is it not a class part of mbed library already ? or should I need to include any library ?

Thank you

By the way Sir , I don’t have any of this , can it be the reason ?
I’m also using the ARDUINO shield on top of my STM32F446RE as I did with the ecg , will it be the same way to code it ?

Thank you

I have also checked the mikroe example, I have found it great, but don’t really know how to translate it for for it to be suitable to mbed compilers. Can please help with that ?
As I have just begun with this , I don’t know how to work with my various components when I don’t have a suitable library, this is my main problem .

BuffredSerial is part of MbedOS 6+, so you probably have and older version of MbedOS. You need to update your MbedOS or just use older docs ATCmdParser - APIs | Mbed OS 5 Documentation

No that is not necessary it was an alternative.

BR, Jan

The Microe shiled is only like a bridge between Arduino header and MicroBus header, if I remember.
However, you again need to check where is the UART connected.
I already fast checked it and it seems the UART of Microe Shield is connected to the D0 & D1 of Arduino Header but that is already reserved by STDIO on Nucleo. So then you need other pins but they will not be compatible with Microe shield, so again you need to connect it by some wires.

BR, Jan

Hello Sir, I have updated but still not working . And as for the old docs, there is a file to include for it to work, I search for it around as well but did not find it .

By the way I found a piece of code online as well, I have tried it and connected it specified in the code , it was able to compile , but it does not connect to the GSM. I believe the issue is the connection, `/*#################################################################################

Program Name : SIM808 GPS
Author : Crispin Mukalay
Date Modified : 31/08/2018
Compiler : ARMmbed
Tested On : NUCLEO-F446RE

Description : Demonstrates the use of the SIM808 Shield to read the GPS
satellite fix, latitude, longitude, MSL altitude,
speed (Km/Hour) over ground coordinates and heading (0-360deg).

Requirements : * NUCLEO-F446RE Board
* SIM808 GSM/GPS Module

Circuit : * The SIM808 module is connected as follows:
VCC/5V/VIN - 5V
GND - GND
RXD - PA0 (F446’s Serial4_TX pin)
TXD - PA1 (F446’s Serial4_RX pin)

####################################################################################*/

#include “mbed.h”
#include “Adafruit_FONA.h”

Adafruit_FONA gps(PA_0, PA_1, PA_6, PA_7); //Create a Adafruit_FONA object called gps
// TX RX RST RI
//Not all SIM808-based boards have a RST (Reset) and RI (Ring Indicator) pin,
//but when initializing the object one needs to specify them, even if they
//are not there. In our case we just used two unused pins (PA_6 & PA_7) as “dummy” pins.

Serial pc(SERIAL_TX, SERIAL_RX); //to use the PC as a console (display output)

int main() {

int SIM808Success;
bool gpsSuccess, gpsCoordinates;
float fix, latitude, longitude, MSL_altitude, speed_kph, heading;
  
pc.printf("Program Started...\n");

/* create connection to SIM808 */
pc.printf("\nConnecting to SIM808...\n");
SIM808Success = gps.begin(9600);              //connect to SIM808 device at 9600 baud rate and return if successful(=1) or not (=0) 

if(SIM808Success == 1) 
    pc.printf("\nSIM808 detected successfully...\n");
else {
    pc.printf("\nSIM808 not detected!\n");
    while(1);                           //program stops/freezes at this point if SIM808 not detected
}

/* Enable GPS*/
gpsSuccess = gps.enableGPS(true);
 
if (gpsSuccess == true) 
   pc.printf("\nGPS enable successful...\n");
else
   pc.printf("\nGPS enable failed!\n");


while(1) {
    wait(2);
    
    /* Read coordinates from GPS*/
    gpsCoordinates = gps.getGPS(&fix, &latitude, &longitude, &MSL_altitude, &speed_kph, &heading);
    
    if(gpsCoordinates == true){
        
        if(fix == 1.0f){
            pc.printf("\n");
            pc.printf("Latitude: %.6f\n", latitude);
            pc.printf("Longitude: %.6f\n", longitude);
            pc.printf("MSL altitude: %.6f\n", MSL_altitude);
            pc.printf("Speed: %.6f kph\n", speed_kph);
            pc.printf("Heading: %.6f \n", heading);
        }else{
            pc.printf("Waiting for satellite fix...\n");
        }
             
    }else{
        pc.printf("Waiting for satellite fix...\n");
    }
}

}

so wondering how to specify the connection of the following pins STAT, PWRKEY, RTS, RS, and CTS in the code to enable communication with the chip .
Can you help please ? or is this code not suitable for my gsm-gps click ?

Then you still not have it updated to correct version. Source - [Arm Mbed OS (github.com)]

Both were part of MbedOS 5.15 but your are right, it throw the error.
Anyway when you delete lines below, then the code will be compilable.

#include "platform\ATCmdParser.h"
#include "drivers\UARTSerial.h"

Probably.

First start to use it only with RX & TX, if it will not work then just check the datasheet.
The code what you shared above required only RX, TX, RST and RI - gsm-gps-click-schematic-v100 (mikroe.com)

BR, Jan

Thanks for all the info!

God day Sir
Please I have tried everything with the help of the shematic, but still saying Sim808 not detected . any idea of the issue again ?

Good day to you too.
Just for sure, do you have UART pins crossed? RX to TX and vice versa.

BR, Jan

Perfect, this has worked now … But I tried to run a code I have written, but does not give me any suitable result. Cheick it below
`#include “mbed.h”
#define GSM_DEFAULT_BAUD_RATE 9600

UARTSerial *_serial;
ATCmdParser *_parser;

int main()
{
printf(“\nATCmdParser with GSM example”);

_serial = new UARTSerial(D1, D0, GSM_DEFAULT_BAUD_RATE);
_parser = new ATCmdParser(_serial);
_parser->debug_on( 1 );
_parser->set_delimiter( "\r\n" );

//Now get the FW version number of ESP8266 by sending an AT command 
printf("\nATCmdParser: Retrieving Message");
_parser->send("AT+CMGS=?"); 
int version;
if(_parser->recv("SDK version:%d", &version) && _parser->recv("OK")) {
    printf("\nATCmdParser: success");
} else { 
    printf("\nATCmdParser: failed");
    return -1;
}

printf("\nDone\n");

}
`Above is the code ( Was testing it to see if it will generate success as written in the code) . Below is the result .

I don’t understand why the AT command still displaying , can you help please ?

Please Sir , are you talking of the GSM-GPS ?

If I can be honest, It seems you more focusing to test various of test codes instead of focus to the correct things.

  • You can test what do you want but if you have it badly connected physically the result will be always same. You need change pins of UARTSerial constructor. Pins D1, D0 are already used by STDIO = your printfs to your terminal app for debuging. This I already wrote somewhere above.
  • The default baud rate of GSM-GPS click SIM808 MIKROE should be 115200 not 9600
  • Also your change of the AT command in the example. You have no verified the connection and not understand the code, but you changed it and tried to ask about Send SMS. The example code was wrote only for AT version check so you must send “AT+GMR” and not “AT+CMGS”.

BR, Jan

You have UART on both sides, the modul has RX/TX and also Nucleo board has also RX/TX. It can not be connected RX to RX but it must be crossed, so RX to TX and vice versa.

BR, Jan