Need to send neo-6m data to thingspeak using esp-01

Hi I need to send neo-6m data to thingspeak using esp-01.
My code is :

#include <SoftwareSerial.h>
#include <TinyGPS++.h>
int GPSBaud = 9600;
String AP = "AndriodAP023";       // Hotspot Name
String PASS = "abcd1234"; // Hotspot PASSWORD
String API = "2JXZK3UQUNGPI5T3";   // Write API KEY
String HOST = "api.thingspeak.com";
String PORT = "80";
int countTrueCommand;
int countTimeCommand;
String Latitude;
String Longitude;
TinyGPSPlus gps;
boolean found = false;
int valSensor = 1;
SoftwareSerial gpsSerial(4,5);
SoftwareSerial esp8266(2,3);
 
void setup() {
  Serial.begin(9600);
 
 esp8266.begin(9600);
   sendCommand("AT",5,"OK");
  sendCommand("AT+CWMODE=1",5,"OK");
  sendCommand("AT+CWJAP=\""+ AP +"\",\""+ PASS +"\"",20,"OK");
  esp8266.end();
}

void loop() {


 gpsSerial.begin(9600);


   Latitude = String(gps.location.lat(), 5);
   Longitude = String(gps.location.lng(),5);

    Serial.print("Latitude: ");
    Serial.println(Latitude);
    Serial.print("Longitude: ");
    Serial.println(Longitude);
gpsSerial.end();
 esp8266.begin(9600);
 String getData = "GET /update?api_key="+ API +"&field1="+Latitude+"&field2="+Longitude;
 sendCommand("AT+CIPMUX=1",5,"OK");
 sendCommand("AT+CIPSTART=0,\"TCP\",\""+ HOST +"\","+ PORT,15,"OK");
 sendCommand("AT+CIPSEND=0," +String(getData.length()+4),4,">");
 esp8266.println(getData);delay(1500);countTrueCommand++;
 sendCommand("AT+CIPCLOSE=0",5,"OK");
 esp8266.end();
}



void sendCommand(String command, int maxTime, char readReplay[]) {
  Serial.print(countTrueCommand);
  Serial.print(". at command => ");
  Serial.print(command);
  Serial.print(" ");
  while(countTimeCommand < (maxTime*1))
  {
    esp8266.println(command);//at+cipsend
    if(esp8266.find(readReplay))//ok
    {
      found = true;
      break;
    }
 
    countTimeCommand++;
  }
 
  if(found == true)
  {
    Serial.println("OYI");
    countTrueCommand++;
    countTimeCommand = 0;
  }
 
  if(found == false)
  {
    Serial.println("Fail");
    countTrueCommand = 0;
    countTimeCommand = 0;
  }
 
  found = false;
 }

My serial monitor output will show that my latitude and longitude is 0.00000
It will also show that the AT Fail.
I am using an arduino uno.
The full serial output is in the attachment.
Thank you in advance.

gpsSerial.begin(9600); Why is that in loop()?

Hi, thank you for your reply. It is in the loop as I need to start the esp01 in the setup first, I am new to this so I am not sure how this might affect the result.

Your lat and long are zero because you never read anything from the gps. Look at an example to see how TinyGPS is used.

Perhaps start with that and once you have reliable position data try to add the code to send it.

Hi thank you for reply. I have a code that can extract the gps data using the TinyGPSPlus library:

#include <SoftwareSerial.h>
#include <TinyGPS++.h>
SoftwareSerial GPS_Serial(4,5);
SoftwareSerial WIFI(2,3);
TinyGPSPlus gps;


//led pin
int ledpin=8;

//buzzer pin
int buzzer=9;

void setup() {
  Serial.begin(9600);
  GPS_Serial.begin(9600);
}

void loop() { 

  digitalWrite(8,LOW);
  digitalWrite(9,LOW);

   Serial.println("Motion detected");
   
   while (GPS_Serial.available() > 0){
    gps.encode(GPS_Serial.read()); 
    if (gps.location.isValid())
   {
    //Serial.print("Motion detected");
    //lat_str=String(gps.location.lat(),6);
    Serial.print("Latitude= ");
    Serial.print(gps.location.lat(),6);
    //long_str=String(gps.location.lng(),6);
    Serial.print(" Longitude= ");
    Serial.print(gps.location.lng(),6);
   }
   else
   {
    Serial.print("Invalid Data");
   }
   Serial.println();
  }

}

This code allows me to get the longitude and latitude.
I am sorry for this request but is there any way I can incorporate sending to thingspeak using esp-01?

The problem is that both the neo-6m and esp-01 uses software serial, so I am really unsure about how to incorporate these 2 modules together. Thanks in advance.

I would follow the same path: get an example that sends static data to Thingspeak and once that's working, combine them a piece at a time.

It looks like you were already aware that you can't use two softwareSerial instances at the same time, which makes combining the two programs a little more complex.

Hi thank you for your reply. I will try that asap.

I wish people would abandon the ESP-01 and spend their valuable time working with a module with built-in wifi.
time = money

ieee488:
time = money

sp. " time == money".

Sheesh! Some people…

TheMemberFormerlyKnownAsAWOL:
sp. " time == money".

Sheesh! Some people...

ha ha
:smiley:

I should have written time is money .

.