4 years, 5 months ago.

Specify WiFi Interface Used

I see the latest wifi example uses the general WiFiInterface class. I'm trying to use the ESP8266 which is supported by the OS. How do I specify / configure the interface to use when following the mbed-os-example-wifi example?

1 Answer

4 years, 5 months ago.

If you are using the mbed example:

https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-wifi/

Edit your mbed_app.json file like below, change the 'tx' and' rx' pin setting to match your ESP8266 connections and enter your router ssid and password.

ESP8266.serial-baudrate will work at 230400 and 460800 if you change the baudrate on your ESP8266 to match, the default is 115200.

platform.stdio-baud-rate for your terminal default is 9600, I set mine to 115200.

mbed_app.json

{
    "config": {
        "wifi-ssid": {
            "help": "WiFi SSID",
            "value": "\"your ssid\""
        },
        "wifi-password": {
            "help": "WiFi Password",
            "value": "\"your password\""
        }
    },
    "target_overrides": {
        "*": {
            "platform.stdio-convert-newlines": true,
            "platform.stdio-baud-rate": 115200,
            "target.network-default-interface-type" : "WIFI",
            "esp8266.serial-baudrate"           : 115200,
            "esp8266.tx"                        : "D1",
            "esp8266.rx"                        : "D0",
            "esp8266.provide-default"           : true
        }
    }
}

Accepted Answer

Thanks, this is exactly what I was looking for. On a side note where are we supposed to find this kind of information? There's very little in the driver docs

posted by Mini Momo 31 Oct 2019

Just ask, its the only way really. Mbed library constantly changes which is okay for the guys that know their stuff, I don't and I had to ask much the same question.

Btw, if you are okay to try, use

https://os.mbed.com/users/sarahmarshy/code/SerialPassthrough/

to set your ESP baud rate to 460800, 115200 is just too slow. Check the ESP8266 docs here:

https://www.espressif.com/sites/default/files/documentation/4a-esp8266_at_instruction_set_en.pdf

Page 11/62 shows the default baud rate setting command.

Just use the SerialPassthrough and type in :

AT+UART_DEF=460800,8,1,0,3

This will set the default rate to 460800.

I use my own ESP8266 driver and run mine at 921600 on targets with a clock above 80Mhz (Nucleo-F401 does work at 921600). But I don't have TLS so stick with the Mbed driver.

posted by Paul Staron 31 Oct 2019