GPS Tracker

[13114] Modem init…
[23148] Cannot init

Esp 32 + Neo 6M GPS + SIM800l

 /* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial

// Select your modem:
#define TINY_GSM_MODEM_SIM800
//#define TINY_GSM_MODEM_SIM900
//#define TINY_GSM_MODEM_M590
//#define TINY_GSM_MODEM_A6
//#define TINY_GSM_MODEM_A7
//#define TINY_GSM_MODEM_BG96
//#define TINY_GSM_MODEM_XBEE

// Default heartbeat interval for GSM is 60
// If you want override this value, uncomment and set this option:
//#define BLYNK_HEARTBEAT 30

#include <TinyGPS++.h> //https://github.com/mikalhart/TinyGPSPlus
#include <TinyGsmClient.h> //https://github.com/vshymanskyy/TinyGSM
#include <BlynkSimpleTinyGSM.h> //https://github.com/blynkkk/blynk-library

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "25ZwzOcZXekXx1d6y5dMP7Um4Yi5PTa1";

#define BLYNK_AUTH_TOKEN "25ZwzOcZXekXx1d6y5dMP7Um4Yi5PTa1"

// Your GPRS credentials
// Leave empty, if missing user or pass
char apn[]  = "dialogbb";
char user[] = "";
char pass[] = "";


//sender phone number with country code.
//not gsm module phone number
//const String PHONE = "Enter_Your_Phone_Number";

//GSM Module Settings
//GSM Module RX pin to ESP32 2
//GSM Module TX pin to ESP32 4
#define rxPin 4
#define txPin 2
HardwareSerial sim800(1);
TinyGsm modem(sim800);

//GPS Module Settings
//GPS Module RX pin to ESP32 17
//GPS Module TX pin to ESP32 16
#define RXD2 16
#define TXD2 17
HardwareSerial neogps(2);
TinyGPSPlus gps;

WidgetMap myMap(V0);
BlynkTimer timer;
int pointIndex = 1;

void setup() {
   
  //Set Serial monitor baud rate
  Serial.begin(115200);
  Serial.println("esp32 serial initialize");
  delay(10);
  
  //Set GPS module baud rate
  neogps.begin(9600, SERIAL_8N1, RXD2, TXD2);
  Serial.println("neogps serial initialize");
  delay(10);

  //Set GSM module baud rate
  sim800.begin(9600, SERIAL_8N1, rxPin, txPin);
  Serial.println("SIM800L serial initialize");
  delay(3000); 
   
  // Restart takes quite some time
  // To skip it, call init() instead of restart()
  Serial.println("Initializing modem...");
  modem.restart();

  // Unlock your SIM card with a PIN
  //modem.simUnlock("1234");

  Blynk.begin(auth, modem, apn, user, pass);
  //timer.setInterval(5000L, sendToBlynk);
}

void loop() {
  
  while(neogps.available())
  {
    if (gps.encode(neogps.read()))
    {
      sendToBlynk();
    }
  }

  Blynk.run();
  //timer.run();
  
} //main loop ends

void sendToBlynk()
{

  if (gps.location.isValid() )
  {
    //get latitude and longitude
    float latitude = (gps.location.lat());
    float longitude = (gps.location.lng());
    //get
    float speed = gps.speed.kmph();
    //get number of satellites
    float satellites = gps.satellites.value();
    
    //Serial.print("Latitude:  ");
    //Serial.println(latitude, 6);
    //Serial.print("Longitude: ");
    //Serial.println(longitude, 6);
    //Serial.print("Speed: ");
    //Serial.println(speed, 6);    
    
    Blynk.virtualWrite(V1, String(latitude, 6));
    Blynk.virtualWrite(V2, String(longitude, 6));
    myMap.location(pointIndex, latitude, longitude, "GPS_Location");
    
    Blynk.virtualWrite(V3, speed);

  }
} 
 

@kaushika_disz Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Copy and paste these if you can’t find the correct symbol on your keyboard.

Pete.

@PeteKnight Okay, i used the triple backticks i guess now it is okay

Are you attempting to use Blynk IoT or Blynk Legacy?

Have you tried a simpler sketch with just the SIM800 and the ESP32?

Are you providing sufficient power to the SIM800 module?

Pete.

I am attempting to use Blynk IoT,
No, I haven’t tried a simple sketch, I need to get the GPS real time location on the Blynk IoT (Lattitude, Longitude, Speed and the Map widget)
I have connected the 3.3V pin of the ESP32 to the SIM800 module.

In that case you4 sketch is missing the template ID and device name from the very top of the code.

You need to begin my getting your SIM800 to initialise, and a simple sketch is the simplest way to get get that part working.

That’s almost certainly a bad idea.
The SIM800 module requires a lot of current (around 2A when transmitting data) and the ESP32’s voltage regulator isn’t built to do that.

Pete.

1 Like
#define BLYNK_TEMPLATE_ID "TMPL5nwqMla5"
#define BLYNK_DEVICE_NAME "Quickstart Template"
#define BLYNK_AUTH_TOKEN "25ZwzOcZXekXx1d6y5dMP7Um4Yi5PTa1"

Can i have an example for a simple sketch?

I used a 3.7V battery for the power supply of the SIM800 and i have connected the 3.3V pin for the NEO6M GPS module and the data cable connected properly, and I included the template ID and the device name but still the same error after uploading the code.

The SIM800 Module blinks 7 times stops for about 3 seconds and blinks 7 times again, The LED of the Neo6M GPS doesn’t even light up.

Look at the TinyGSM GitHub page and you’ll see plenty of examples.

Are you using a common GND from that battery to the ESP32?
Can the battery supply 2A ?

I think you need to remove the GPS module from the setup and test the SIM800 with a basic sketch first.

Pete.

void setup() {
  Serial.begin(9600);
  Serial2.begin(9600);
  delay(3000);
  test_sim800_module();
  send_SMS();
}
void loop() {
  updateSerial();
}
void test_sim800_module()
{
  Serial2.println("AT");
  updateSerial();
  Serial.println();
  Serial2.println("AT+CSQ");
  updateSerial();
  Serial2.println("AT+CCID");
  updateSerial();
  Serial2.println("AT+CREG?");
  updateSerial();
  Serial2.println("ATI");
  updateSerial();
  Serial2.println("AT+CBC");
  updateSerial();
}
void updateSerial()
{
  delay(500);
  while (Serial.available())
  {
    Serial2.write(Serial.read());//Forward what Serial received to Software Serial Port
  }
  while (Serial2.available())
  {
    Serial.write(Serial2.read());//Forward what Software Serial received to Serial Port
  }
}
void send_SMS()
{
  Serial2.println("AT+CMGF=1"); // Configuring TEXT mode
  updateSerial();
  Serial2.println("AT+CMGS=\"+94760926269\"");//change ZZ with country code and xxxxxxxxxxx with phone number to sms
  updateSerial();
  Serial2.print("Circuit Digest"); //text content
  updateSerial();
Serial.println();
  Serial.println("Message Sent");
  Serial2.write(26);
}

I used this code with the ESP32 and the sim 800l and it doesn’t work

I have used the 3.7V battery for the SIM800 and the power supply of the USB port to the ESP32, only the data pins of the SIM800 are connected with the ESP32.

That doesn’t look like any of the TinyGSM examples from the GitHub page to me, and it looks like half a sketch.

It really would help if you copied/pasted the serial monitor output text between triple backticks rather than posting screenshots.

So I guess that means you don’t have a common GND between the two power supplies then? If that’s the case then it won’t work, as the data signals are all relative to the GND reference, and if the grounds are not connected across the two boards then the data signals will mean nothing to the ESP32.

Pete.

1 Like