Please help me understand this backtrace stuff

The situation has resolved itself, but I still want to understand this ‘backtrace’ stuff.

My ESP Now sender code used millis, and reported the last reading in millis. I wanted to change that to formattedTime, so I added in all that stuff:

#include <NTPClient.h>
#include <WiFiUdp.h>

#define SEALEVELPRESSURE_HPA (1013.25 + 10)
#define NTP_OFFSET -18000      // In seconds
#define NTP_INTERVAL 60 * 1000 // In miliseconds
#define NTP_ADDRESS "pool.ntp.org"

WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, NTP_ADDRESS, NTP_OFFSET, NTP_INTERVAL);

timeClient.begin();

  timeClient.update();
  String formattedTime = timeClient.getFormattedTime();
  
String str = formattedTime;

    Serial.print(F("Last reading = "));
    Serial.println(str);

Now I get this backtrace stuff: (There is no line 374)

Rebooting...
KR�"�B
�fQs�C)���R�^�L�o���assertion "Invalid mbox" failed: file "/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/api/tcpip.c", line 374, function: tcpip_send_msg_wait_sem
abort() was called at PC 0x400f0707 on core 1

ELF file SHA256: 0000000000000000

Backtrace: 0x40088e68:0x3ffb1d80 0x400890e5:0x3ffb1da0 0x400f0707:0x3ffb1dc0 0x4011cf27:0x3ffb1df0 0x4011c7bd:0x3ffb1e20 0x4011c970:0x3ffb1e40 0x4011371a:0x3ffb1e80 0x400d1c79:0x3ffb1ea0 0x400d1d5d:0x3ffb1ee0 0x40145e11:0x3ffb1f10 0x400d389b:0x3ffb1f30 0x400d093e:0x3ffb1f50 0x400d621a:0x3ffb1fb0 0x4008a0f6:0x3ffb1fd0

Rebooting...
KR��␜Q��␜!�(E��␐<�␖F

Sender code:

#include <Arduino.h>

/*

  Rui Santos

  Complete project details at https://RandomNerdTutorials.com/esp32-esp-now-wi-fi-web-server/

  Permission is hereby granted, free of charge, to any person obtaining a copy

  of this software and associated documentation files.

  The above copyright notice and this permission notice shall be included in all

  copies or substantial portions of the Software.

*/

#include <esp_now.h>

#include <esp_wifi.h>

#include <WiFi.h>

#include <Adafruit_Sensor.h>

#include "Adafruit_BME680.h"

#include "Adafruit_SGP30.h"

#include "Adafruit_VEML6070.h"

#include <NTPClient.h>

#include <WiFiUdp.h>

#define SEALEVELPRESSURE_HPA (1013.25 + 10)

#define NTP_OFFSET -18000      // In seconds

#define NTP_INTERVAL 60 * 1000 // In miliseconds

#define NTP_ADDRESS "pool.ntp.org"

WiFiUDP ntpUDP;

NTPClient timeClient(ntpUDP, NTP_ADDRESS, NTP_OFFSET, NTP_INTERVAL);

Adafruit_VEML6070 uv = Adafruit_VEML6070();

Adafruit_BME680 bme; // I2C

// Set your Board ID (ESP32 Sender #1 = BOARD_ID 1, ESP32 Sender #2 = BOARD_ID 2, etc)

#define BOARD_ID 2

// MAC Address of the receiver

uint8_t broadcastAddress[] = {0x3C, 0x61, 0x05, 0x12, 0x84, 0x28};

// Structure example to send data

// Must match the receiver structure

typedef struct struct_message

{

  int id;

  float completed;

  float temperature;

  float humidity;

  float pressure;

  float altitude;

  float LPG;

  float CO;

  float CO2;

  float NH3;

  float NO2;

  float VOC;

  float UV;

  float TVOC;

  float smoke;

  float H2;

  float EtOH;

  int readingId;

} struct_message;

// Create a struct_message called myData

struct_message myData;

unsigned long previousMillis = 0; // Stores last time temperature was published

const long interval = 10000;      // Interval at which to publish sensor readings

unsigned int readingId = 0;

// Insert your SSID

constexpr char WIFI_SSID[] = "TP-Link_7C28";

int32_t getWiFiChannel(const char *ssid)

{

  if (int32_t n = WiFi.scanNetworks())

  {

    for (uint8_t i = 0; i < n; i++)

    {

      if (!strcmp(ssid, WiFi.SSID(i).c_str()))

      {

        return WiFi.channel(i);

      }

    }

  }

  return 0;

}

// callback when data is sent

void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status)

{

  Serial.print("\r\nLast Packet Send Status:\t");

  Serial.println(status == ESP_NOW_SEND_SUCCESS ? "Delivery Success" : "Delivery Fail");

}

void setup()

{

  Serial.begin(9600);

  uv.begin(VEML6070_1_T);  

  timeClient.begin();

// Init Serial Monitor

  while (!Serial)

    ;

  Serial.println(F("BME680 test"));

  if (!bme.begin())

  {

    Serial.println(F("BME680 not found"));

    while (1)

      ;

  }

  pinMode(A0, INPUT);

  // Set device as a Wi-Fi Station and set channel

  WiFi.mode(WIFI_STA);

  int32_t channel = getWiFiChannel(WIFI_SSID);

  WiFi.printDiag(Serial); // Uncomment to verify channel number before

  esp_wifi_set_promiscuous(true);

  esp_wifi_set_channel(channel, WIFI_SECOND_CHAN_NONE);

  esp_wifi_set_promiscuous(false);

  WiFi.printDiag(Serial); // Uncomment to verify channel change after

  // Init ESP-NOW

  if (esp_now_init() != ESP_OK)

  {

    Serial.println("Error initializing ESP-NOW");

    return;

  }

  // Once ESPNow is successfully Init, we will register for Send CB to

  // get the status of Trasnmitted packet

  esp_now_register_send_cb(OnDataSent);

  // Register peer

  esp_now_peer_info_t peerInfo;

  memcpy(peerInfo.peer_addr, broadcastAddress, 6);

  peerInfo.encrypt = false;

  // Add peer

  if (esp_now_add_peer(&peerInfo) != ESP_OK)

  {

    Serial.println("Failed to add peer");

    return;

  }

  // Set up oversampling and filter initialization

  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); // 320*C for 150 ms

}

void loop()

{

  timeClient.update();

  String formattedTime = timeClient.getFormattedTime();

 

  float UV=0;

  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval)

  {

    if (!bme.endReading())

    {

      Serial.println(F("Failed to complete reading :("));

      return;

    }

    Serial.print(F("Reading completed at "));

    Serial.println(millis());

    float completed = millis();

    

    //float altitude = bme.readAltitude(SEALEVELPRESSURE_HPA) + 103;

    float sensorValue = 0;

    float sensorVolts = 0;

    for (int i = 0; i < 100; i++)

    {

      sensorValue = sensorValue + analogRead(A0); // read analog input pin 0

    }

    sensorValue = sensorValue / 100;        // get average reading

    sensorVolts = sensorValue / 1024 * 5.0; // convert to voltage

    float smoke = sensorVolts / 20;

    String str = formattedTime;

    Serial.print(F("Last reading = "));

    Serial.println(str);

    Serial.print(F("Temperature = "));

    Serial.print(bme.temperature, 0);

    Serial.println(F(" *C"));

    Serial.print(F("Humidity = "));

    Serial.print(bme.humidity, 0);

    Serial.println(F(" %"));

    Serial.print(F("UV = "));

    Serial.print(UV, 0);

    Serial.println(F(" %"));

    Serial.print("Smoke: ");

    Serial.println(smoke);

     if (smoke > 1.0)

    {

      Serial.println("Smoke Detected!");

    }

    // Save the last time a new reading was published

    previousMillis = currentMillis;

    // Set values to send

    myData.id = BOARD_ID;

    myData.completed = completed;

    myData.temperature = (bme.temperature);

    myData.humidity = (bme.humidity);

    myData.pressure = (bme.pressure);

    //myData.altitude = (altitude);

    myData.smoke = smoke;

    myData.LPG = 0;

    myData.UV = UV;

    myData.CO = 0;

    myData.CO2 = 0;

    myData.NH3 = 0;

    myData.NO2 = 0;

    myData.VOC = 0;

    myData.TVOC = 0;

    myData.H2 = 0;

    myData.EtOH = 0;

    myData.readingId = readingId++;

    // Send message via ESP-NOW

    esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *)&myData, sizeof(myData));

    if (result == ESP_OK)

    {

      Serial.println("Sent with success");

    }

    else

    {

      Serial.println("Error sending the data");

    }

  }

  delay(5000);

}

“Something”, probably the NTP library, tried to do something invalid with a TCP socket. mbos is a message box used in the leightweight IP (lwIP) stack.

This is not human readable unless you turn on the backtrace decoder via monitor_filters = esp32_exception_decoder.

Thank you! But I’m still a few degrees away from finding context for that.
I added ’ [monitor_filters = sp32_exception_decoder] to all three of the ESP Now programs.
Senders don’t seem to have issues like the receiver.
But I’m now in a zone where I make a change that wrecks the function and then have to go back and undo what I did without losing the change I wanted to make.

I also added build_mode = debug.

I don’t know what to expect.