Smart Sensor for Firefighter

Hi, I am new in Arduino. I am using ESP32, pulse sensor, gps module, mq-2 gas sensor, k-type thermocouple and oled in my project. I already compile all the coding, but unfortunately when I upload to the board, gps module not functioning, not getting the latitude and longitude reading. Can anybody help me to check the code?

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "WiFi.h"
#include "ThingSpeak.h"
#include "max6675.h"
#include <TinyGPS++.h>

#define wifiname "MYwifi " 
#define wifipassword "testwifi" 
#define timeoutTime 20000

#define ChannelID 2520131 
#define ChannelAPIkey "PBTFO881TXOB98BH" 
WiFiClient client;

#define GPSRX 16
#define GPSTX 17
#define GPSserial Serial2
TinyGPSPlus gps; 



unsigned long attemptTime;


int thermoSO = 19; 
int thermoCS = 23; 
int thermoSCK = 5; 


int analogpin = 32; //AO gas sensor
int buzzerpin = 13; 
int buzzerdelay = 50;
int a = 100;

float valueCelcius; 
float gasvalue; 
float latitude; 
float longitude; 

int ledpin = 18; 

Adafruit_SSD1306 display(128, 64, &Wire, -1);
MAX6675 thermocouple(thermoSCK, thermoCS, thermoSO);
HardwareSerial neogps(1);

void oledsetup(){
  
   if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // don't proceed, loop forever 
   }
}

void connectWiFi(){


  Serial.print("Connecting to wifi");
  WiFi.mode(WIFI_STA);
  WiFi.begin(wifiname, wifipassword);

  attemptTime = millis();

    while(WiFi.status() != WL_CONNECTED && millis() - attemptTime < timeoutTime){

      Serial.print(".");
      delay(100);
    }

  if (WiFi.status()!= WL_CONNECTED){
    Serial.println(" Failed to connect! ");
  }
  else{
    Serial.print(" Connected yeayy ");
      Serial.println(WiFi.localIP());
  }

}

void gpslatlong(){

if(gps.location.isValid() == 1){
  
  latitude = gps.location.lat();
  longitude = gps.location.lng();
  

  display.clearDisplay();

    display.setTextSize(1);
    display.setTextColor(WHITE);

    display.setCursor(0, 0);
    display.println(latitude, 5);

    display.setCursor(50, 0);
    display.println(longitude, 5);

display.display();
}

else{

  display.clearDisplay();
  display.setTextColor(WHITE);
  display.setCursor(0, 50);
  display.setTextSize(1);
  display.println("Waiting for satellite");

display.display();
}



}

void gpsdata(){

  boolean newData = false;
  for (unsigned long start = millis(); millis() - start < 10000;)
  {
    while (neogps.available())
    {
      if (gps.encode(neogps.read()))
      {
        newData = true;
      }
    }
  }

  // if newData is true
  if(newData == true)
  {
    newData = true;
    Serial.println(gps.satellites.value());
    gpslatlong();
  }
  else 
  {
    display.clearDisplay();
    display.setTextColor(WHITE);
    display.setCursor(0, 50);
    display.setTextSize(1);
    display.print(" No data stored");
    display.display();
  }


}

void setup() {

  connectWiFi();
  oledsetup();
  ThingSpeak.begin(client);
  neogps.begin(9600, SERIAL_8N1, GPSRX, GPSTX);


  Serial.begin(9600);
  display.clearDisplay();

  pinMode(ledpin, OUTPUT);
  pinMode(buzzerpin, OUTPUT);


}

void loop() {

  gpsdata();

  gasvalue = analogRead(analogpin);
  valueCelcius = thermocouple.readCelsius();

  ThingSpeak.setField(1, valueCelcius);
  ThingSpeak.setField(2, gasvalue);
  ThingSpeak.setField(3, latitude);
  ThingSpeak.setField(4, longitude);

    ThingSpeak.writeFields(ChannelID, ChannelAPIkey); // need to check this


      Serial.print("Gas: ");
    Serial.print(gasvalue);
      Serial.print ("  Temperature: ");
    Serial.println(valueCelcius);
      Serial.print("  Latitude: ");
    Serial.println(latitude);
      Serial.print(" || Longitude: ");
    Serial.println(longitude);


      

    // display.setTextSize(1);
    // display.setTextColor(WHITE);
    // display.setCursor(0, 0);

    //display.println(gasvalue);
    //  display.display();



  if(gasvalue > 20000){ //change this!

    digitalWrite(ledpin, HIGH);
  }
  else{

    digitalWrite(ledpin, LOW);
  }

  if(valueCelcius < 39){

    display.clearDisplay();

    display.setTextSize(2);
    display.setTextColor(WHITE);
    display.setCursor(0, 28);

    display.println("NORMAL");
      display.display();

      digitalWrite(buzzerpin, LOW);
  }
  if(valueCelcius > 39 && valueCelcius < 60){

    display.clearDisplay();
    display.setTextSize(2);
    display.setTextColor(WHITE);
    display.setCursor(0, 28);

    display.println("CAUTION");
      display.display();

      a = 0; 

 if(a < 100){ // check balik sini

      digitalWrite(buzzerpin, HIGH);
        delay(buzzerdelay);
      digitalWrite(buzzerpin, LOW);

        a = a+1;
 } 



  }
  if(valueCelcius > 60){
    display.clearDisplay();

    display.setTextSize(2);
    display.setTextColor(WHITE);
    display.setCursor(0, 28);

    display.println("DANGER");
      display.display();

      digitalWrite(buzzerpin, HIGH);




  }



delay(300);
}

Put your own code aside and test with known, working example code for the GPS. This will tell you if your GPS is faulty or your wiring is bad.

Run similar tests for each of your other components.

Only when you know all your components are working and wired correctly will you be ready to test your own code.

The problem may exist in your circuit setup too. Not necessarily in your code.