Sending GPS coordinate to thingspeak using GPS module neo 6 and GSM 900a

Here is my coding;
My coding is successfully send data to thinspeak using GSM but it send cordinate 0 0 because the code for GPS not running

What i notice that my coding GPS did not running ss.begin(9600) i dont know why ss.println("Gps read"); and Serial.println("GPS start"); did not print on serial moitor

here is my code



#include <SoftwareSerial.h>
#include <String.h>
#include <TinyGPS++.h>

const int rxPin = 4;
const int txPin = 3;

TinyGPSPlus gps;

SoftwareSerial ss(rxPin, txPin);

SoftwareSerial gprsSerial(9,10);
//const int gsmrxPin = 9;
//const int gsmtxPin = 10;

float MyValue1, MyValue2;

 void setup()
{

  Serial.begin(9600);    // the GPRS baud rate 

  ss.begin(9600);
  Serial.println("GPS start");  
  delay(1000);

  
  gprsSerial.begin(9600);               // the GPRS baud rate 
  Serial.println("GSM start");
  delay(1000);
  
}
 
void loop()
{
      ss.println("Gps read");  
    while (ss.available() > 0) {
    if (gps.encode(ss.read())) {
      // If so, display the current GPS coordinates
      Serial.print("Longitude: ");
      Serial.println(gps.location.lng(), 6);
      Serial.print("Latitude: ");
      Serial.println(gps.location.lat(), 6);

      // Save the coordinates to variables
      float myvalue1 = gps.location.lng();
      float myvalue2 = gps.location.lat();
    }
  }
   
    gprsSerial.println("GsM read");     

  if (gprsSerial.available())
    Serial.write(gprsSerial.read());
 
  gprsSerial.println("AT");
  delay(1000);
 
  gprsSerial.println("AT+CPIN?");
  delay(1000);
 
  gprsSerial.println("AT+CREG?");
  delay(1000);
 
  gprsSerial.println("AT+CGATT?");
  delay(1000);
 
  gprsSerial.println("AT+CIPSHUT");
  delay(1000);
 
  gprsSerial.println("AT+CIPSTATUS");
  delay(2000);
 
  gprsSerial.println("AT+CIPMUX=0");
  delay(2000);
 
  ShowSerialData();
 
  gprsSerial.println("AT+CSTT=\"airtelgprs.com\"");//start task and setting the APN,
  delay(1000);
 
  ShowSerialData();
 
  gprsSerial.println("AT+CIICR");//bring up wireless connection
  delay(3000);
 
  ShowSerialData();
 
  gprsSerial.println("AT+CIFSR");//get local IP adress
  delay(2000);
 
  ShowSerialData();
 
  gprsSerial.println("AT+CIPSPRT=0");
  delay(3000);
 
  ShowSerialData();
  
  gprsSerial.println("AT+CIPSTART=\"TCP\",\"api.thingspeak.com\",\"80\"");//start up the connection
  delay(6000);
 
  ShowSerialData();
 
  gprsSerial.println("AT+CIPSEND");//begin send data to remote server
  delay(4000);
  ShowSerialData();
  
  String str="GET https://api.thingspeak.com/update?api_key=XOY6CRHBEIH04QCM&field1=0"+ String(MyValue1) +"&field2="+String(MyValue2);
  Serial.println(str);
  gprsSerial.println(str);//begin send data to remote server
  
  delay(4000);
  ShowSerialData();
 
  gprsSerial.println((char)26);//sending
  delay(5000);//waitting for reply, important! the time is base on the condition of internet 
  gprsSerial.println();
 
  ShowSerialData();
 
  gprsSerial.println("AT+CIPSHUT");//close the connection
  delay(100);
  ShowSerialData();
 
}

void ShowSerialData()
{
  while(gprsSerial.available()!=0)
  Serial.write(gprsSerial.read());
  delay(5000); 
  
}

and here is my serial monitor

I working this troubleshooting this code almost a week find in the internet to solve the problem. I am really grateful if you guys can help. And sorry about my bad English grammar

Hi.
Have you been able to see the raw GPS output using a simpler sketch?

yes i am able to see the gps coordinate when i am running GPS coding only here is my GPS coding successfully get

#include <TinyGPS++.h>
#include <SoftwareSerial.h>

// NEO 6 GPS module RX and TX pin connections to Arduino Nano
const int rxPin = 4;
const int txPin = 3;

// Create a TinyGPS++ object
TinyGPSPlus gps;

// Create a software serial port
SoftwareSerial ss(rxPin, txPin);

void setup() {
  // Initialize serial communication at a baud rate of 9600
  Serial.begin(9600);
  ss.begin(9600);
}

void loop() {
  // Check if new data is available from the GPS module
  while (ss.available() > 0) {
    if (gps.encode(ss.read())) {
      // If so, display the current GPS coordinates
      Serial.print("Longitude: ");
      Serial.println(gps.location.lng(), 6);
      Serial.print("Latitude: ");
      Serial.println(gps.location.lat(), 6);

      // Save the coordinates to variables
      float myvalue1 = gps.location.lng();
      float myvalue2 = gps.location.lat();
    }
  }
}

Serial output pic

@

Your other topic on the same subject deleted.

Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.

Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.

Repeated duplicate posting could result in a temporary or permanent ban from the forum.

Could you take a few moments to Learn How To Use The Forum

It will help you get the best out of the forum in the future.

Thank you.

Really sorry next time i will read carefully the rule

Actually that question is my past question that system unhidden back my 1st question which not posted before this

Thank you for the caution.

I have a question can we use the void setup like this because what i found that during my troubleshooting my GPS serial read didn't print what i can conclude that my ss.begin didnt running

here is my latest void setup during troubleshooting

void setup()
{

  Serial.begin(9600);    // the GPRS baud rate 

  ss.begin(9600);
  Serial.println("GPS start");
  ss.println("GPS serial read");    
  delay(1000);

  
  gprsSerial.begin(9600);               // the GPRS baud rate 
  Serial.println("GSM start");
  gprsSerial.println("GSM serial read"); 
  delay(1000);
  
}

i am suspecting that this can have may problem from the beginning at the void setup because ss.begin didn't running

here is the serial monitor

I already get the correct codding we need to separate the GPS code and GSM code and create a function for GSM

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.