2 months, 3 weeks ago.

How to change ESP8266 default WiFi baud rate setting in Mbed-OS

The default setting for the ESP8266 WiFi module is 115200 and I need to change this to 921600.

Is it possible to change this in the mbed_app.json file for instance?

Many thanks

Paul

Comment on this question

1 Answer

2 months, 3 weeks ago.

Hi Paul,

You can do a slight modification in ESP8266.cpp

#ifndef ESP8266_DEFAULT_BAUD_RATE
#define ESP8266_DEFAULT_BAUD_RATE   115200
#endif

Then you will be able to define the default baud rate in mbed_app.json

"config": {
        "esp8266-baudrate": {
            "help": "ESP8266 baudrate",
            "macro_name": "ESP8266_DEFAULT_BAUD_RATE",
            "value": 921600
        }
    },

Does this work for you?

Regards, Desmond

Hi Desmond,

I use the online compiler so this mod to the ESP8266.cpp file will need to be done your end.

Could you arrange this for the next Mbed update please?

Then I can modify my mbed_app.json file.

Regards

Edit....

I added an enhancement request on git hub,

https://github.com/ARMmbed/mbed-os/issues/11300

Paul

posted by Paul Staron 23 Aug 2019

Hi, just raised a PR here.

https://github.com/ARMmbed/mbed-os/pull/11302

posted by Desmond Chen 23 Aug 2019

I see the ESP8266 driver has been updated to enable default baud rate override, however I'm having trouble achieving this using the http-example with the on-line compiler:

https://os.mbed.com/teams/sandbox/code/http-example/

I have added the target overrides for the boards I'm using and put the the "serial-baudrate" in the config section but the rate does not change.

mbed_app.json

{
    "config": {
        "main-stack-size": {
            "value": 8192
        },
     "serial-baudrate": {
            "help": "Serial baudrate for ESP8266, defaults to 115200",
            "value": 921600
        }
    },
    "macros": [
        "MBEDTLS_MPI_MAX_SIZE=1024",
        "MBEDTLS_MPI_WINDOW_SIZE=1",
        "MBEDTLS_USER_CONFIG_FILE=\"mbedtls_entropy_config.h\"",
        "MBEDTLS_TEST_NULL_ENTROPY",
        "MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES",
        "MBED_HEAP_STATS_ENABLED=1"
    ],
    "target_overrides": {
        "*": {
            "platform.stdio-baud-rate": 115200,
            "platform.stdio-convert-newlines": true,
            "mbed-mesh-api.6lowpan-nd-channel-page": 0,
            "mbed-mesh-api.6lowpan-nd-channel": 12,
            "mbed-trace.enable": null,
            "mbed-http.http-buffer-size": 2048,
            "nsapi.default-wifi-security": "WPA_WPA2",
            "nsapi.default-wifi-ssid": "\"ssid\"",
            "nsapi.default-wifi-password": "\"password\""
        },
        "DISCO_L475VG_IOT01A": {
            "target.network-default-interface-type" : "WIFI"
        },
        "NUCLEO_F401RE": {
            "target.network-default-interface-type" : "WIFI",
            "esp8266.tx"                        : "D8",
            "esp8266.rx"                        : "D2",
            "esp8266.provide-default"           : true
        },
        "NUCLEO_F767ZI": {
            "target.network-default-interface-type" : "WIFI",
            "esp8266.tx"                        : "D1",
            "esp8266.rx"                        : "D0",
            "esp8266.provide-default"           : true
        }
    }
}

Edit....

So it turns out that the latest Mbed-os actually isn't. If you wind it back to revision 6689 and apply this .json file all is good. However the integrated Mbed-os ESP8266 driver has issues keeping up with HTTP/HTTPS at 921600 but appears stable at 460800 which is a considerable improvement on 115200 default speed. Perhaps Mbed-os v.5.15 will have this applied.

mbed_app.json

{
    "config": {
        "main-stack-size": {
            "value": 8192
        }
    },
    "macros": [
        "MBEDTLS_MPI_MAX_SIZE=1024",
        "MBEDTLS_MPI_WINDOW_SIZE=1",
        "MBEDTLS_USER_CONFIG_FILE=\"mbedtls_entropy_config.h\"",
        "MBEDTLS_TEST_NULL_ENTROPY",
        "MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES",
        "MBED_HEAP_STATS_ENABLED=1"
    ],
    "target_overrides": {
        "*": {
            "platform.stdio-baud-rate": 115200,
            "platform.stdio-convert-newlines": true,
            "mbed-mesh-api.6lowpan-nd-channel-page": 0,
            "mbed-mesh-api.6lowpan-nd-channel": 12,
            "mbed-trace.enable": null,
            "mbed-http.http-buffer-size": 2048,
            "nsapi.default-wifi-security": "WPA_WPA2",
            "nsapi.default-wifi-ssid": "\"***ssid****\"",
            "nsapi.default-wifi-password": "\"****pwd*****\""
        },
        "NUCLEO_F401RE": {
            "target.network-default-interface-type" : "WIFI",
            "esp8266.tx"                        : "D8",
            "esp8266.rx"                        : "D2",
            "esp8266.provide-default"           : true
        },
        "NUCLEO_F767ZI": {
            "target.network-default-interface-type" : "WIFI",
            "esp8266.serial-baudrate"           : 460800,
            "esp8266.tx"                        : "D1",
            "esp8266.rx"                        : "D0",
            "esp8266.provide-default"           : true
        }
    }
}

The information currently shown on Github is a bit misleading,

https://github.com/ARMmbed/mbed-os/blob/master/components/wifi/esp8266-driver/mbed_lib.json

posted by Paul Staron 05 Oct 2019