<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[M5Atom Echo issues with ESP-WIFI-MESH]]></title><description><![CDATA[<p dir="auto">I'm using platformio / arduino framework / espressif32 platform with an M5Atom Echo.</p>
<p dir="auto">I'm trying to get the <a href="https://www.espressif.com/en/products/sdks/esp-wifi-mesh/overview" target="_blank" rel="noopener noreferrer nofollow ugc">ESP-WIFI-MESH</a> working. I'm using the guide on espressif.<br />
The werid thing is my code compiles and works fine on other ESP32's like a TTGO-display board for instance.<br />
On this M5 it compiles fine but when I set the mesh config, it give an argument error implying the struct is invalid.</p>
<pre><code>#include &lt;Arduino.h&gt;
#include &lt;esp_wifi.h&gt;
#include &lt;esp_mac.h&gt;
#include &lt;esp_event.h&gt;
#include &lt;esp_log.h&gt;
#include &lt;esp_mesh.h&gt;
#include &lt;esp_mesh_internal.h&gt;
#include &lt;nvs_flash.h&gt;
#include &lt;ArduinoJson.h&gt;

#include &lt;FastLED.h&gt;


/*******************************************************
 *                Macros
 *******************************************************/

/*******************************************************
 *                Constants
 *******************************************************/
#define RX_SIZE (1500)
#define TX_SIZE (1460)
#define IS_ROOT false
#define MESH_ID {0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC}
#define MESH_CHANNEL 2
#define MESH_MAX_LAYER 6
#define SENDLOOP_INTERVAL 1000

#define LED_PIN 27
#define NUM_LEDS 1
CRGB led[NUM_LEDS];

/*******************************************************
 *                Variable Definitions
 *******************************************************/

static const char *TAG = "mesh_test";
static esp_netif_t *netif_sta = NULL;
bool is_mesh_connected = false;

mesh_addr_t mesh_parent_addr;
int mesh_layer = -1;
/*******************************************************
 *                Function Declarations
 *******************************************************/

/*******************************************************
 *                Function Definitions
 *******************************************************/

void setup_led()
{
    FastLED.addLeds&lt;NEOPIXEL, LED_PIN&gt;(led, NUM_LEDS);
    led[0] = CRGB::Black;
    FastLED.show();
}

void blink_led(uint8_t r, uint8_t g, uint8_t b, int delay_ms = 200)
{
    led[0] = CRGB(r, g, b);
    FastLED.show();
    delay(delay_ms);
    led[0] = CRGB::Black;
    FastLED.show();
    delay(delay_ms);
}

void flash_led(uint8_t r, uint8_t g, uint8_t b,int delay_ms = 100)
{
    int i = 0;
    while (i &lt; 3)
    {
        led[0] = CRGB(r, g, b);
        FastLED.show();
        delay(delay_ms);
        led[0] = CRGB::Black;
        FastLED.show();
        delay(delay_ms);
        i++;
    }
   
}

void ip_event_handler(void *arg, esp_event_base_t event_base,
                      int32_t event_id, void *event_data)
{
    ip_event_got_ip_t *event = (ip_event_got_ip_t *)event_data;
    ESP_LOGI(MESH_TAG, "&lt;IP_EVENT_STA_GOT_IP&gt;IP:" IPSTR, IP2STR(&amp;event-&gt;ip_info.ip));
}

void mesh_event_handler(void *arg, esp_event_base_t event_base,
                        int32_t event_id, void *event_data)
{
    switch (event_id)
    {
    case MESH_EVENT_STARTED:
    {
        ESP_LOGI(MESH_TAG, "&lt;MESH_EVENT_MESH_STARTED&gt;ID:" MACSTR "", MAC2STR(id.addr));
        mesh_layer = esp_mesh_get_layer();
        Serial.printf("Event: MESH_EVENT_STARTED, Layer %d\n", mesh_layer);
    }
    case MESH_EVENT_PARENT_CONNECTED:
        ESP_LOGI(TAG, "MESH_EVENT_PARENT_CONNECTED");
        mesh_layer = esp_mesh_get_layer();
        esp_mesh_get_parent_bssid(&amp;mesh_parent_addr);
        ESP_LOGI(TAG, "Layer %d, Parent %02x:%02x:%02x:%02x:%02x:%02x",
                 mesh_layer,
                 mesh_parent_addr.addr[0], mesh_parent_addr.addr[1], mesh_parent_addr.addr[2],
                 mesh_parent_addr.addr[3], mesh_parent_addr.addr[4], mesh_parent_addr.addr[5]);
        Serial.println("Parent connected");
        Serial.printf("Layer %d, Parent %02x:%02x:%02x:%02x:%02x:%02x\n",
                      mesh_layer,
                      mesh_parent_addr.addr[0], mesh_parent_addr.addr[1], mesh_parent_addr.addr[2],
                      mesh_parent_addr.addr[3], mesh_parent_addr.addr[4], mesh_parent_addr.addr[5]);
        break;
    case MESH_EVENT_PARENT_DISCONNECTED:
        ESP_LOGI(TAG, "MESH_EVENT_PARENT_DISCONNECTED");
        mesh_layer = esp_mesh_get_layer();
        Serial.printf("Layer %d, Parent disconnected\n", mesh_layer);
        break;
    case MESH_EVENT_CHILD_CONNECTED:
    {
        mesh_event_child_connected_t *child_connected = (mesh_event_child_connected_t *)event_data;
        ESP_LOGI(TAG, "&lt;MESH_EVENT_CHILD_CONNECTED&gt;aid:%d, " MACSTR "",
                 child_connected-&gt;aid,
                 MAC2STR(child_connected-&gt;mac));
        Serial.println("Child connected");
        break;
    }
    default:
        ESP_LOGI(TAG, "Unhandled event ID: %d", event_id);
        Serial.println("Unhandled event ID");
        Serial.println(event_id);
        break;
    }
}

void setup_mesh()
{
    esp_err_t ret = nvs_flash_init();
    if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND)
    {
        ESP_ERROR_CHECK(nvs_flash_erase());
        ret = nvs_flash_init();
        Serial.println("NVS flash erased and re-initialized.");
    }
    ESP_ERROR_CHECK(ret);
    //ESP_ERROR_CHECK(nvs_flash_init());
    /*  tcpip initialization */
    ESP_ERROR_CHECK(esp_netif_init());
    /*  event initialization */
    ESP_ERROR_CHECK(esp_event_loop_create_default());
    /*  create network interfaces for mesh (only station instance saved for further manipulation, soft AP instance ignored */
    ESP_ERROR_CHECK(esp_netif_create_default_wifi_mesh_netifs(&amp;netif_sta, NULL));

    /*  wifi initialization */
    wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
    ESP_ERROR_CHECK(esp_wifi_init(&amp;cfg));
    ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &amp;ip_event_handler, NULL));
    ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_FLASH));
    esp_err_t wifi_start_err = esp_wifi_start();
    if (wifi_start_err == ESP_OK)
    {
        Serial.println("WiFi started successfully.");
    }
    else
    {
        Serial.printf("Failed to start WiFi: %s\n", esp_err_to_name(wifi_start_err));
    }

    /*  mesh initialization */
    Serial.println("Init mesh");
    esp_err_t mesh_init_err = esp_mesh_init();
    if (mesh_init_err == ESP_OK)
    {
        Serial.println("Mesh initialized successfully.");
    }
    else
    {
        Serial.printf("Failed to initialize mesh: %s\n", esp_err_to_name(mesh_init_err));
    }
    ESP_ERROR_CHECK(esp_event_handler_register(MESH_EVENT, ESP_EVENT_ANY_ID, &amp;mesh_event_handler, NULL));

    mesh_cfg_t mesh_config = MESH_INIT_CONFIG_DEFAULT();
    uint8_t mesh_id[] = MESH_ID;
    memcpy(&amp;mesh_config.mesh_id, mesh_id, 6);
    mesh_config.channel = MESH_CHANNEL;
    mesh_config.router.ssid_len = 0; // No router connection
    //mesh_config.mesh_ap.max_connection = 2;



    if (IS_ROOT)
    {
        ESP_ERROR_CHECK(esp_mesh_set_self_organized(true, true));
        ESP_ERROR_CHECK(esp_mesh_set_type(MESH_ROOT));
        ESP_LOGI(TAG, "Node set as root.");
        Serial.println("Node set as root.");
    }
    else {
        ESP_ERROR_CHECK(esp_mesh_set_self_organized(true, true));
        ESP_ERROR_CHECK(esp_mesh_set_type(MESH_IDLE));
        Serial.println("Node set as leaf.");
    }

    esp_err_t set_config_err = esp_mesh_set_config(&amp;mesh_config);
    if (set_config_err == ESP_OK)
    {
        Serial.println("Mesh configuration set successfully.");
    }
    else
    {
        Serial.printf("Failed to set mesh configuration: %s\n", esp_err_to_name(set_config_err));
    }

    esp_err_t err = esp_mesh_start();
    if (err == ESP_OK)
    {
        ESP_LOGI(TAG, "Mesh started successfully.");
        Serial.println("Mesh started successfully.");
        is_mesh_connected = true;
        flash_led(0,0,255,100);
    }
    else
    {
        ESP_LOGE(TAG, "Failed to start mesh: %s", esp_err_to_name(err));
        Serial.println("Failed to start mesh.");
        is_mesh_connected = false;
        flash_led(255,0,0,100);
    }

    
}
</code></pre>
<p dir="auto">As you can see this even follows the structure from ESP.</p>
<p dir="auto">It failes here:</p>
<pre><code>    esp_err_t set_config_err = esp_mesh_set_config(&amp;mesh_config);

</code></pre>
<p dir="auto">No matter how basic I make it, this ALWAYS fails on the M5.<br />
Again, this just works on other ESP32s.<br />
In essense the config struct contains only the mesh ID and the channel.</p>
<p dir="auto">Any reason this fails on this architecture and not on others?</p>
]]></description><link>https://community.m5stack.com/topic/7539/m5atom-echo-issues-with-esp-wifi-mesh</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 01:05:11 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/7539.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 01 May 2025 08:14:17 GMT</pubDate><ttl>60</ttl></channel></rss>