Crazy thing happening to my ESP32 WeMos

This is a really good, solid, working script. I’m just moving things around on the OLED.
I swapped out the first one, because I started getting this type of garbage in the serial monitor, so this is D1 Mini #espressif32

Backtrace: 0x4008cc88:0x3ffb1dc0 0x4008ceb9:0x3ffb1de0 0x40089089:0x3ffb1e00 0x40129332:0x3ffb1e40 0x4012960e:0x3ffb1e60 0x4011835c:0x3ffb1e80 0x401183c5:0x3ffb1ea0 0x4012ae72:0x3ffb1ec0 0x40129b08:0x3ffb1ee0 0x4011738c:0x3ffb1f20 0x400d5363:0x3ffb1f40 0x400d12f7:0x3ffb1f80 0x400d73ef:0x3ffb1fb0 0x4008939d:0x3ffb1fd0

Rebooting…
�RN!��0�␛E9OH��␌C `���R/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/queue.c:1442 (xQueueGenericReceive)- assert failed!
abort() was called at PC 0x40089089 on core 1

I don’t want this to keep happening. I have a few more D1s, but I don’t want to destroy their brains. Can you see anything in my code that would drive processor 1 insane?

I know there are ways to delete everything on an ESP32 chip. I have not uploaded 10,000 times yet.

/*********
  Rui Santos
  Complete project details at https://randomnerdtutorials.com  
*********/

// Load Wi-Fi library
#include <WiFi.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_BME680.h"
#include "Adafruit_GFX.h"
#include "Fonts/FreeSansBold9pt7b.h"
#include "Fonts/Org_01.h"
#include "Adafruit_SSD1306.h"
#include "Wire.h"
#include "FS.h"
#include "Adafruit_SI1145.h"

#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_SSD1306 display(128, 32, &Wire, 8); //Declaring the display name (display)
Adafruit_BME680 bme;                         // I2C
Adafruit_SI1145 uv = Adafruit_SI1145();

// Replace with your network credentials
const char *ssid = "Fishing24";
const char *password = "Fishing$602";
float uvindex;
// Set web server port number to 80
WiFiServer server(80);

// Variable to store the HTTP request
String header;

// Current time
unsigned long currentTime = millis();
// Previous time
unsigned long previousTime = 0;
// Define timeout time in milliseconds (example: 2000ms = 2s)
const long timeoutTime = 2000;

#define AnalogPin A0
#define LED 5

float sensorValue1 = 0;
float sensorValue2 = 0;
float sensorValue3 = 0;
int limit = 10;

void setup()
{
  Serial.begin(9600);
  Wire.begin();
  server.begin();
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  
pinMode(LED_BUILTIN, OUTPUT);
pinMode(13, OUTPUT);
pinMode(A0, INPUT);

WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
  delay(500);
  Serial.print(".");
}
WiFi.begin(ssid, password);
while (WiFi.status() == WL_CONNECTED)
{
digitalWrite(LED_BUILTIN, HIGH);
}


  while (!Serial)
    ;
  Serial.println();
  Serial.println("BME680 Test");
  Serial.println("SI1145 Test");
  
  if (!uv.begin())
  {
    Serial.println("No Si1145 found");
    while (1)
      ;
  }
  if (!bme.begin())
  {
    Serial.println("No BME680 found");
    while (1)
      ;
  }
}

void displayData(){
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
  display.setFont(&Org_01);
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(1, 5);
  display.print("IP:  ");
  display.setCursor(25, 25);
  display.setFont(&FreeSansBold9pt7b);
  display.setTextSize(1);
  display.println(WiFi.localIP());
  display.display();
  Serial.print("IP:  ");
  Serial.println(WiFi.localIP());
}

void loop()
{ 
  


  bme.setTemperatureOversampling(BME680_OS_8X);
  bme.setHumidityOversampling(BME680_OS_2X);
  bme.setPressureOversampling(BME680_OS_4X);
  bme.setIIRFilterSize(BME680_FILTER_SIZE_3);
  bme.setGasHeater(320, 150);
  
  digitalWrite(LED, LOW);


  
//  display.print("Temperature:  ");
  //display.print(bme.temperature, 1);
  //display.println(" C");
  Serial.print("Temperature:  ");
  Serial.print(bme.temperature, 1);
  Serial.println(" C");

  //display.print("Humidity:      ");
  //display.print(bme.humidity, 0);
  //display.println(" %");
  Serial.print("Humidity:      ");
  Serial.print(bme.humidity, 0);
  Serial.println(" %");

  //display.print("Mositure:     ");
  //display.print(sensorValue1, 0);
  //display.println("%");
  Serial.print("Mositure:     ");
  Serial.print(sensorValue1, 0);
  Serial.println("%");
  if (sensorValue1 < limit)
  {
    digitalWrite(LED, HIGH);
  }
  else
  {
    digitalWrite(LED, LOW);
  }

  //display.print(F("Pressure:     "));
  //display.print((bme.pressure / 100.0) * 0.03, 0);
  //display.println(F(" in Hg"));
  Serial.print(F("Pressure:     "));
  Serial.print((bme.pressure / 100.0) * 0.03, 0);
  Serial.println(F(" in Hg"));

  //display.print("Altitude:      ");
  //display.print(bme.readAltitude(SEALEVELPRESSURE_HPA), 0);
  //display.println(" m");
  Serial.print("Altitude:      ");
  Serial.print((2.75*bme.readAltitude(SEALEVELPRESSURE_HPA)), 0);
  Serial.println(" m");

  //display.print("Gas:         ");
  //display.print(bme.gas_resistance / 1000.0, 0);
  //display.println(" KOhm");
  Serial.print("Gas:         ");
  Serial.print(bme.gas_resistance / 1000.0, 0);
  Serial.println(" KOhm");

  float UVindex = uv.readUV();
  // the index is multiplied by 100 so to get the
  // integer index, divide by 100!
  UVindex /= 100.0;

  //display.print("UV Index:    "); //250Serial.print("UV Index:   ");
  //display.print(UVindex, 2);      //250
  //display.display();
  Serial.print("UV Index:    ");  //250Serial.print("UV Index:   ");
  Serial.print(UVindex, 2);       //250

  if (uv.readUV() >= 0 && uv.readUV() < 689)
  {

    Serial.println(" LOW");
    //display.println(" LOW");
    //display.display();
  }
  else

      if (uv.readUV() >= 690 && uv.readUV() < 1379)
  {

    Serial.println(" Moderate");
    //display.println(" Moderate");
    //display.display();
  }
  else

      if (uv.readUV() >= 1380 && uv.readUV() < 1839)
  {
    Serial.println(" High");
    //display.println(" High");
    //display.display();
  }
  else

      if (uv.readUV() >= 1839 && uv.readUV() < 2529)
  {
    Serial.println(" HIGH!");
    //display.println(" HIGH!");
    //display.display();
  }

  if (uv.readUV() >= 2530 && uv.readUV() < 2760)
  {
    Serial.println(" Get shade!");
    //display.println(" Get shade!");
    //display.display();
  }
Serial.println();


  WiFiClient client = server.available(); // Listen for incoming clients

  if (client)
  { // If a new client connects,
    currentTime = millis();
    previousTime = currentTime;
    Serial.println("New Client."); // print a message out in the serial port
    String currentLine = "";       // make a String to hold incoming data from the client
    while (client.connected() && currentTime - previousTime <= timeoutTime)
    { // loop while the client's connected
      currentTime = millis();
      if (client.available())
      {                         // if there's bytes to read from the client,
        char c = client.read(); // read a byte, then
        Serial.write(c);        // print it out the serial monitor
        header += c;
        if (c == '\n')
        { // if the byte is a newline character
          // if the current line is blank, you got two newline characters in a row.
          // that's the end of the client HTTP request, so send a response:
          if (currentLine.length() == 0)
          {
            // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
            // and a content-type so the client knows what's coming, then a blank line:
            client.println("HTTP/1.1 200 OK");
            client.println("Content-type:text/html");
            client.println("Connection: close");
            client.println();

            // Display the HTML web page
            client.println("<!DOCTYPE html><html>");
            client.println("<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">");
            client.println("<link rel=\"icon\" href=\"data:,\">");
            // CSS to style the table
            client.println("<style>body { text-align: center; font-family: \"Trebuchet MS\", Arial;}");
            client.println("table { border-collapse: collapse; width:450; margin-left:auto; margin-right:auto; }");
            client.println("th { padding: 12px; background-color: #0043af; color: white; }");
            client.println("tr { border: 1px solid #ddd; padding: 12px; }");
            client.println("tr:hover { background-color: #bcbcbc; }");
            client.println("td { border: none; padding: 12px; }");
            client.println(".sensor { color:white; font-weight: bold; background-color: #bcbcbc; padding: 1px; }");

            // Web Page Heading

            

           client.println("</style></head><body><h1>Monster Laboratories Weather Station</h1>");

           client.println("<img src=/Ben_Grin_glasses.JPG width=180>");
           client.println("<img src=/Ben_Grin_glasses.jpg width=180>");
           client.println("<img src=Ben_Grin_glasses.JPG width=180>");
           client.println("<img src=Ben_Grin_glasses.jpg width=180>");
           client.println("<table><tr><th>MEASUREMENT</th><th>VALUE</th></tr>");

           client.println("<tr><td>Temp. Centigrade</td><td><span class=\"sensor\">");
           client.println(bme.temperature, 1);
           client.println(" *C</span></td></tr>");

           client.println("<tr><td>Temp. Fahrenheit</td><td><span class=\"sensor\">");
           client.println((1.8 * bme.readTemperature() + 32), 0);
           client.println(" *F</span></td></tr>");

           client.println("<tr><td>Soil Moisture:</td><td><span class=\"sensor\">");
           client.println(sensorValue1, 0);
           client.println("%</span></td></tr>");

           client.println("<tr><td>Humidity</td><td><span class=\"sensor\">");
           client.println(bme.humidity, 0);
           client.println(" %</span></td></tr>");

           client.println("<tr><td>Pressure</td><td><span class=\"sensor\">");
           client.println((bme.pressure / 100.0) * 0.03, 0);
           client.println(" in Hg</span></td></tr>");

           client.println("<tr><td>Approx. Altitude</td><td><span class=\"sensor\">");
           client.println((5.5 * bme.readAltitude(SEALEVELPRESSURE_HPA)), 0);
           client.println(" m</span></td></tr>");

           client.println("<tr><td>Uv Index</td><td><span class=\"sensor\">");
           client.println(UVindex);
           client.println(" </span></td></tr>");

           client.println("<tr><td>Uv </td><td><span class=\"sensor\">");
           client.println(uv.readUV() / 230);
           client.println(" </span></td></tr>");

           client.println("</body></html>");

           // The HTTP response ends with another blank line
           client.println();
           // Break out of the while loop
           break;
          }
          else
          { // if you got a newline, then clear currentLine
            currentLine = "";
          }
        }
        else if (c != '\r')
        {                   // if you got anything else but a carriage return character,
          currentLine += c; // add it to the end of the currentLine
        }
      }
    }
    // Clear the header variable
    header = "";
    // Close the connection
    client.stop();
    Serial.println("Client disconnected.");
    Serial.println("");
  }
}

I plugged in #3, and it’s putting out the same stuff.

The sister program is working. It’s a copy with only the soil moisture sensor.

I can’t believe there is any material change between the two that should cause the aborts.

/*********
  Rui Santos
  Complete project details at https://randomnerdtutorials.com  
*********/

// Load Wi-Fi library
#include <WiFi.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_BME680.h"
#include "Adafruit_GFX.h"
#include "Fonts/FreeSansBold9pt7b.h"
#include "Fonts/Org_01.h"
#include "Adafruit_SSD1306.h"
#include "Wire.h"
#include "FS.h"
#include "Adafruit_SI1145.h"

#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_SSD1306 display(128, 32, &Wire, 8); //Declaring the display name (display)
Adafruit_BME680 bme;                         // I2C
Adafruit_SI1145 uv = Adafruit_SI1145();

// Replace with your network credentials
const char *ssid = "Fishing24";
const char *password = "Fishing$602";

// Set web server port number to 80
WiFiServer server(80);

// Variable to store the HTTP request
String header;

// Current time
unsigned long currentTime = millis();
// Previous time
unsigned long previousTime = 0;
// Define timeout time in milliseconds (example: 2000ms = 2s)
const long timeoutTime = 2000;

#define AnalogPin A0
#define LED 0
#define LED1 0

float sensorValue1 = 0;
float sensorValue2 = 0;
float sensorValue3 = 0;
int limit = 600;

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

  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(13, OUTPUT);
  pinMode(A0, INPUT);

  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
  }
  WiFi.begin(ssid, password);
  while (WiFi.status() == WL_CONNECTED)
  {
    digitalWrite(LED_BUILTIN, HIGH);
  }
  
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());  
 
  Wire.begin();
  while (!Serial)
    ;
  Serial.println();
  Serial.println("BME680 Test");
  Serial.println("SI1145 Test");
  if (!uv.begin())
  {
    Serial.println("No Si1145 found");
    while (1)
      ;
  }
  if (!bme.begin())
  {
    Serial.println("No BME680 found");
    while (1)
      ;
  }
  
  server.begin();
  delay(1000);
}

void loop()
{  

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //Start the OLED display
  display.setTextColor(WHITE);
  display.clearDisplay();
  display.setFont(&Org_01);
  display.setTextSize(1);
  display.setCursor(3, 5);

  display.println("IP address: ");
  display.setTextSize(2);
  display.setCursor(3, 20);

  display.println(WiFi.localIP());
  

  display.display();


  bme.setTemperatureOversampling(BME680_OS_8X);
  bme.setHumidityOversampling(BME680_OS_2X);
  bme.setPressureOversampling(BME680_OS_4X);
  bme.setIIRFilterSize(BME680_FILTER_SIZE_3);
  bme.setGasHeater(320, 150);

  for (int i = 0; i <= 100; i++)
  {
    sensorValue1 = sensorValue1 + analogRead(AnalogPin);
    delay(1);
  }
  sensorValue1 = sensorValue1 / 100.0;
  sensorValue1 = sensorValue1 / 8;
      delay(30);

  Serial.print("Mositure:     ");
  Serial.print(sensorValue1, 0);
  Serial.println("%");

  if (sensorValue1 > limit)
  {
    digitalWrite(LED, HIGH);
    delay(500);
    digitalWrite(LED, LOW);
    delay(500);
  }
  else
  {
    digitalWrite(LED1, HIGH);
    delay(1000);
  }
  Wire.begin();
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //Start the OLED display
  display.clearDisplay();
  display.setFont(&Org_01);
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(1, 5);



  WiFiClient client = server.available(); // Listen for incoming clients

  if (client)
  { // If a new client connects,
    currentTime = millis();
    previousTime = currentTime;
    Serial.println("New Client."); // print a message out in the serial port
    String currentLine = "";       // make a String to hold incoming data from the client
    while (client.connected() && currentTime - previousTime <= timeoutTime)
    { // loop while the client's connected
      currentTime = millis();
      if (client.available())
      {                         // if there's bytes to read from the client,
        char c = client.read(); // read a byte, then
        Serial.write(c);        // print it out the serial monitor
        header += c;
        if (c == '\n')
        { // if the byte is a newline character
          // if the current line is blank, you got two newline characters in a row.
          // that's the end of the client HTTP request, so send a response:
          if (currentLine.length() == 0)
          {
            // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
            // and a content-type so the client knows what's coming, then a blank line:
            client.println("HTTP/1.1 200 OK");
            client.println("Content-type:text/html");
            client.println("Connection: close");
            client.println();

            // Display the HTML web page
            client.println("<!DOCTYPE html><html>");
            client.println("<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">");
            client.println("<link rel=\"icon\" href=\"data:,\">");
            // CSS to style the table
            client.println("<style>body { text-align: center; font-family: \"Trebuchet MS\", Arial;}");
            client.println("table { border-collapse: collapse; width:450; margin-left:auto; margin-right:auto; }");
            client.println("th { padding: 12px; background-color: #0043af; color: white; }");
            client.println("tr { border: 1px solid #ddd; padding: 12px; }");
            client.println("tr:hover { background-color: #bcbcbc; }");
            client.println("td { border: none; padding: 12px; }");
            client.println(".sensor { color:white; font-weight: bold; background-color: #bcbcbc; padding: 1px; }");

            // Web Page Heading
            client.println("</style></head><body><h1>Monster Laboratories Weather Station</h1>");
            client.println("<table><tr><th>MEASUREMENT</th><th>VALUE</th></tr>");

            client.println("<tr><td>Temp. Centigrade</td><td><span class=\"sensor\">");
            client.println(bme.temperature, 1);
            client.println(" *C</span></td></tr>");

            client.println("<tr><td>Temp. Fahrenheit</td><td><span class=\"sensor\">");
            client.println((1.8 * bme.readTemperature() + 32), 0);
            client.println(" *F</span></td></tr>");

            client.println("<tr><td>Soil Moisture:</td><td><span class=\"sensor\">");
            client.println(sensorValue1, 0);
            client.println("%</span></td></tr>");

            client.println("<tr><td>Humidity</td><td><span class=\"sensor\">");
            client.println(bme.humidity, 0);
            client.println(" %</span></td></tr>");

            client.println("<tr><td>Pressure</td><td><span class=\"sensor\">");
            client.println((bme.pressure / 100.0) * 0.03, 0);
            client.println(" in Hg</span></td></tr>");

            client.println("<tr><td>Approx. Altitude</td><td><span class=\"sensor\">");
            client.println(bme.readAltitude(SEALEVELPRESSURE_HPA), 0);
            client.println(" m</span></td></tr>");

//          client.println("<tr><td>Uv </td><td><span class=\"sensor\">");
//          client.println(uv.readUV() / 230);
//          client.println(" </span></td></tr>");

            client.println("</body></html>");

            // The HTTP response ends with another blank line
            client.println();
            // Break out of the while loop
            break;
          }
          else
          { // if you got a newline, then clear currentLine
            currentLine = "";
          }
        }
        else if (c != '\r')
        {                   // if you got anything else but a carriage return character,
          currentLine += c; // add it to the end of the currentLine
        }
      }
    }
    // Clear the header variable
    header = "";
    // Close the connection
    client.stop();
    Serial.println("Client disconnected.");
    Serial.println("");
  }
}

Rui started this mess. It’s his/her fault.

I flashed the working sister script onto the other two WeMos- they’re both fine. But what’s that insanity?

You can get a better understanding of the error when you activate

monitor_filters = esp32_exception_decoder

(docs) in the platformio.ini.

The xQueueGenericReceive is quiete a generic one since many things use a queue (or a mutex, which is a 1-element queue). Some issues hint at the WiFi being disconnected at the moment something is supposed to be done over WiFi (boot crash: /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/queue.c:1442 (xQueueGenericReceive)- assert failed! · Issue #3467 · espressif/arduino-esp32 · GitHub, https://gitter.im/espressif/arduino-esp32?at=5d3b5e9b09575942228c0cd2). Other topics (OTA fails with xQueueGenericReceive- assert failed! (IDFGH-1121) · Issue #3439 · espressif/esp-idf · GitHub) suggest that if a library call acquires a mutex for too long it might block and interfere with other tasks. That then depends on library code.

The stacktrace will give you a better idea what happens.