• Partager sur Facebook
  • Partager sur Twitter

problme to send data gps through sms sim 900

    29 juin 2022 à 15:21:34

    I want to send gps data through sim900 but i don't know why the code doesn't work i want your help please

    #include <SoftwareSerial.h>
    #include <TinyGPS++.h>
    SoftwareSerial sim(7, 8);
    int _timeout;
    String _buffer;
    String number1 = "+212684547105";
    String number = "+xxxxxxxxxxxx"; //-> change with your number
    // Choose two Arduino pins to use for software serial
    int RXPin = 2;
    int TXPin = 3;
    int GPSBaud = 9600;
    // Create a TinyGPS++ object
    TinyGPSPlus gps;
    // Create a software serial port called "gpsSerial"
    SoftwareSerial gpsSerial(RXPin, TXPin);
    //SoftwareSerial espSerial(0, 1);
    String str;
    void setup() {
      //delay(7000); //delay for 7 seconds to make sure the modules get the signal
      Serial.println("Sistem Started...");
      Serial.println("Type s to send an SMS, r to receive an SMS, and c to make a call");
      // Start the Arduino hardware serial port at 9600 baud
      // Start the software serial port at the GPS's default baud
    void loop() {
     float lati,longi,Alti;
      // This sketch displays information every time a new sentence is correctly encoded.
      while (gpsSerial.available() > 0)
        if (gps.encode({
           if (gps.location.isValid())
        lati =;
        longi = gps.location.lng();
        Alti = gps.altitude.meters();
        str ="Latitude: " +String(lati)+ "longitude: " +String(longi)+ "Altitude: "+String(Alti); 
        sim.println("AT+CMGF=1\r");    //Sets the GSM Module in Text Mode
      //Serial.println ("Set SMS Number");
        sim.println("AT+CMGS=\"" + number + "\"\r"); //Mobile phone number to send message
        sim.println((char)26);// ASCII code of CTRL+Z
        _buffer = _readSerial();
        Serial.println("Location: Not Available");
      // If 5000 milliseconds pass and there are no characters coming in
      // over the software serial port, show a "No GPS detected" error
      if (millis() > 5000 && gps.charsProcessed() < 10)
        Serial.println("No GPS detected");
    String _readSerial() {
      _timeout = 0;
      while  (!sim.available() && _timeout < 12000  )
      if (sim.available()) {
        return sim.readString();

    • Partager sur Facebook
    • Partager sur Twitter
      6 juillet 2022 à 14:46:26

      I am also searching the same query if any body please discuss here
      • Partager sur Facebook
      • Partager sur Twitter

      problme to send data gps through sms sim 900

      × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
      × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
      • Editeur
      • Markdown