How can i reterive the gps information from my pixhawk device using the esp8266 wifi module using Arudnio IDE application ?

#include <mavlink.h>
#include <ESP8266WiFi.h>

const char* ssid = "YourWiFiSSID";
const char* password = "YourWiFiPassword";

WiFiClient client;

void setup() {

  // Connect to WiFi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
  Serial.println("WiFi connected");

  // Setup MAVLink
  mavlink_message_t msg;
  mavlink_status_t status;

  // Initialize MAVLink
  mavlink_msg_gps_raw_int_t gps_data;

  // Setup serial communication with Pixhawk
  Serial1.begin(57600); // Adjust baud rate according to your Pixhawk configuration

void loop() {
  // Receive MAVLink messages
  while (Serial1.available() > 0) {
    uint8_t c =;
    if (mavlink_parse_char(MAVLINK_COMM_0, c, &msg, &status)) {
      // Handle GPS data
      if (msg.msgid == MAVLINK_MSG_ID_GPS_RAW_INT) {
        mavlink_gps_raw_int_t gps_data;
        mavlink_msg_gps_raw_int_decode(&msg, &gps_data);

        // Process GPS data
        // You can access GPS data from gps_data structure (e.g.,, gps_data.lon, etc.)
        // Do whatever you want with the GPS data here
        Serial.print("Latitude: ");
        Serial.print("Longitude: ");
        // Print other GPS data as needed

Here’s an example code we are trying to retrieve GPS information from the Pixhawk device using the ESP8266 WiFi module through the Arduino IDE application. Could someone please help us with this?

@gokula_krishna We can’t help you if you don’t tell us what’s not working