Notifications
Clear all

WiFiNINA ESP32 Error: invalid header: 0xffffffff

4 Posts
3 Users
0 Likes
688 Views
(@ibrahim123)
Member
Joined: 4 months ago
Posts: 1
Topic starter  

I was trying to use WiFi IDP for some Master Slave communication, this error shows up when ever I upload, I tried to use different ESP32 module put it  keeps showing same error after uploading. I am not user about the library I am using if it causing this issue.

here is the error message in serial monitor:
rst:0x7 (TG0WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid he⸮ets Jul 29 2019 12:21:46

Here is my code

#include <SPI.h>
#include <WiFiNINA.h>
#include <WiFiUdp.h>

int status = WL_IDLE_STATUS;
int packetSize;
String MegaMsg;

#include "arduino_secrets.h"
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = SECRET_SSID;        // your network SSID (name)
char pass[] = SECRET_PASS;    // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0;            // your network key index number (needed only for WEP)

unsigned int localPort = 2390;      // local port to listen on

char packetBuffer[256]; //buffer to hold incoming packet
char  ReplyBuffer[] = "acknowledged";       // a string to send back
//char SendMsg[] = "QR Detected";

WiFiUDP Udp;

void setup() {
  //Initialize serial and wait for port to open:
  Serial.begin(9600);
  Serial1.begin(9600);

  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // check for the WiFi module:
  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true);
  }

  //  String fv = WiFi.firmwareVersion();
  //  if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
  //    Serial.println("Please upgrade the firmware");
  //  }

  // attempt to connect to WiFi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
    delay(10000);
  }
  Serial.println("Connected to WiFi");
  printWifiStatus();

  Serial.println("\nStarting connection to server...");
  // if you get a connection, report back via serial:
  Udp.begin(localPort);
}

void loop() {

  // if there's data available, read a packet
  packetSize = Udp.parsePacket();
  if (packetSize) {
    //    Serial.print("Received packet of size ");
    //    Serial.println(packetSize);
    //    Serial.print("From ");
    IPAddress remoteIp = Udp.remoteIP();
    //    Serial.print(remoteIp);
    //    Serial.print(", port ");
    //    Serial.println(Udp.remotePort());

    // read the packet into packetBufffer
    int len = Udp.read(packetBuffer, 255);
    if (len > 0) {
      packetBuffer[len] = 0;
    }
    Serial.println("Contents:");
    Serial.println(packetBuffer);

    if (strcmp(packetBuffer, "w") == 0) {
      Serial.println("Forward");
      Serial1.print("w");
    }
    if (strcmp(packetBuffer, "s") == 0) {
      Serial.println("Reverse");
      Serial1.print("s");
    }
    if (strcmp(packetBuffer, "a") == 0) {
      Serial.println("Turn Left");
      Serial1.print("a");
    }
    if (strcmp(packetBuffer, "d") == 0) {
      Serial.println("Turn Right");
      Serial1.print("d");
    }
    if (strcmp(packetBuffer, "stop") == 0) {
      Serial.println("Stop");
      Serial1.print("ss");
    }

    // send a reply, to the IP address and port that sent us the packet we received
    Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
    Udp.write(ReplyBuffer);
    Udp.endPacket();
  }

  if (Serial1.available() > 0) {
    MegaMsg = Serial1.readString();
    Serial.print(MegaMsg);
    Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
    Udp.print(MegaMsg);
    Udp.endPacket();
  }
  //
  //  Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
  //  Udp.print("Standby");
  //  Udp.endPacket();
  //  Serial.println("Message Sent");
}

   
Quote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6827
 

@ibrahim123 Showing the sketch is pointless. Show us the error log. Do NOT include repeated lines. You have something wrong in the upload setup, cable, port, settings.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
(@dronebot-workshop)
Workshop Guru Admin
Joined: 5 years ago
Posts: 1073
 

Posted by: @ibrahim123

I tried to use different ESP32 module put it  keeps showing same error after uploading.

  As per what Ron said, can you upload ANY ESP32 sketches to your board?  

It might also be helpful to know what platform (Linux, Mac, Windows) you are on, as this certainly sounds like a communications port issue and each operating system handles USB a bit differently.

😎

Bill

 

"Never trust a computer you can’t throw out a window." — Steve Wozniak


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6827
 

@ibrahim123 Try the blink sketch. What board is selected, show us a picture of your board close up so we can identify it. I almost always select the 'DOIT' board (see pic). Also, are you connected via USB or FTDI?

Screenshot 2023 12 15 at 09.25.23

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote