ESP8266 NUCLEO-F303RE test

I’m trying to get the ESP8266 working with MBED. I have successfully flashed the AT firmware and if I connect an Arduino (I already had the code for it) in Serial pasthrough mode I can talk AT comands with the module at 115200:

AT

OK
AT+GMR
@T version:1.6.2.0(Apr 03 2018 11:10:59)
SDK version:2.2.1(6ai22eo1

The MBED example I’m using is: mbed-os-example-mbed5-wifi - A quick example of a simple WiFi application usin… | Mbed

Mi mbed_app.json configuration is:

{
    "config": {
        "wifi-ssid": {
            "help": "WiFi SSID",
            "value": "\"XDDDD\""
        },
        "wifi-password": {
            "help": "WiFi Password",
            "value": "\"XDDDD\""
        }
    },
    "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
        } 
    }
}

When I upload and open the serial port on the Nucleo I get:
image

Is it a compatibility issue (involving either the Nucleo or the NodeMCU board I’m using)?

1 Like

Another test:

I’ve tried plugging the Arduino Uno set up as Serial-passthrough and I have connected to the UART pins of the Nucleo that are supposed to go to the ESP8266.
Nothing shows on Serial.
This rules out a problem with the ESP8266 itself. So assuming I have connected the UART lines and GND correctly it has to be something related to the configuration right?

Hello,

why you tried this old one?
Wi-Fi - API references and tutorials | Mbed OS 6 Documentation refer to this example ARMmbed/mbed-os-snippet-TCPSocketWiFi at v6.7 (github.com).
I tried that with Nucleo-L433 and esp8266-01 on MbedOS 6.6 few days ago and the scan was working.

BR, Jan

Could you share the mbed_app.json file?

I’m still struggling with the same (I’m testing the example you proposed)

{
    "config": {
        "wifi-ssid": {
            "help": "WiFi SSID",
            "value": "\"Martin Router King 2.4GHz\""
        },
        "wifi-password": {
            "help": "WiFi Password",
            "value": "\"244466666\""
        },
        "esp8266-tx": {
            "help": "TX pin for serial connection to external device",
            "value": "D1"
        },
        "esp8266-rx": {
            "help": "RX pin for serial connection to external device",
            "value": "D0"
        }
    },
    "target_overrides": {
        "*": {
            "platform.stdio-convert-newlines": true,
            "esp8266.provide-default" : true,
            "esp8266.serial-baudrate"           : 115200,
            "esp8266.tx"                        : "D1",
            "esp8266.rx"                        : "D0"
        },
        "DISCO_L475VG_IOT01A": {
            "target.components_add": ["wifi_ism43362"],
            "ism43362.provide-default": true
        },
        "DISCO_F413ZH": {
            "target.components_add": ["wifi_ism43362"],
            "ism43362.provide-default": true
        }
    }
}

I have D1 and D0 connected to Arduino digital pins set up with Software Serial. I know that the Arduino is working rigth because I can talk with the ESP8266 via the arduino.

Thanks

I not use any configuration for ESP8266 or wifi in mbed_app.json file.

Did you tried also diffrent UART pins?
These D0 and D1 pins are also for VCP of ST-link for debug console - printf output.

BR, Jan

What are the default UART pins for the ESP8266? So if I dont put any config relating to the TX/RX pins to what they will default?

I have already tried with other pins D2/D8 but modifying the config. If you say that no config is needed then I only need to now the default pins :slight_smile: .

Pins for ESP need to be passed in its constructor.

For Example code click HERE
#include "mbed.h" //MbedOS 6.5
#include "ESP8266Interface.h"

#define DEBUG 1

ESP8266Interface wifi(D1, D0); // Nucleo-L433KC

const char *sec2str(nsapi_security_t sec);
void scan_demo(WiFiInterface *wifi);

int main(){
    debug_if(DEBUG, "Mbed OS version %d.%d.%d\n\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION);

    scan_demo(&wifi);

    while(true){

    }
}

const char *sec2str(nsapi_security_t sec)
{
    switch (sec) {
        case NSAPI_SECURITY_NONE:
            return "None";
        case NSAPI_SECURITY_WEP:
            return "WEP";
        case NSAPI_SECURITY_WPA:
            return "WPA";
        case NSAPI_SECURITY_WPA2:
            return "WPA2";
        case NSAPI_SECURITY_WPA_WPA2:
            return "WPA/WPA2";
        case NSAPI_SECURITY_UNKNOWN:
        default:
            return "Unknown";
    }
}
void scan_demo(WiFiInterface *wifi)
{
    WiFiAccessPoint *ap;

    printf("Scan:\r\n");

    int count = wifi->scan(NULL, 0);

    // Limit number of network arbitrary to 15
    count = count < 15 ? count : 15;

    ap = new WiFiAccessPoint[count];

    count = wifi->scan(ap, count);
    for (int i = 0; i < count; i++) {
        printf("Network: %s secured: %s BSSID: %hhX:%hhX:%hhX:%hhx:%hhx:%hhx RSSI: %hhd Ch: %hhd\r\n", ap[i].get_ssid(),
               sec2str(ap[i].get_security()), ap[i].get_bssid()[0], ap[i].get_bssid()[1], ap[i].get_bssid()[2],
               ap[i].get_bssid()[3], ap[i].get_bssid()[4], ap[i].get_bssid()[5], ap[i].get_rssi(), ap[i].get_channel());
    }
    printf("%d networks available.\r\n", count);

    delete[] ap;
}

BR, Jan

Alright, here’s where I am:

Running @JohnnyK proposed mbed 6 code and using D1 and D0 as ESP8266 I can see through serial:


We have an error. However we dont want these pins because as he stated D1 an D0 are also used for the comunication with the computer. So I changed the pins to D8 and D2 (ignoring the error).

Changing to D8 and D2 and running (with the old program uploaded) gives an error while flashing:

I have found that flashing the blinky example and then reflashing the Wifi example (with the pins changed) solves the problem.

Then, changing the pins gives nothing through the serial monitor (not even the “Wifi Example” title).

I had little bit more time today.

I tried it the code what I posted above on Nucleo-F303RE (so same like you use) on pins D14 & D15 and also D8 & D2. Both are working.

  • I also encountered the error Operator new[] out of memory but only when I had the ESP modul badly connected.
  • I also encountered the error from your first post -3012. In my case it was caused by not connected GND between Nucleo and ESP module. My module is powered from external power source not from Nucleo board.

BR, Jan

First of I appreciate the assistance.

Second, changed to D8 and D2. I still get the st link error mentioned above when trying to upload to times straight the same wifi example (have to upload blinky in between).

Third, when I finally flash the example I can see the ESP8266 LED blink for some time (supose this is good). However, I don’t see anything on the serial monitor, not even the first title.

  • about the error you can use Clean Build and if it not help, then try to update/reinstall ST-link drivers and firmware and reinstall MbedStudio.
  • you can try to make code based on BufferedSerial as UART repeater and try to send a simple AT commands via St-link to Nucleo and then to ESP. That will tell you, if the connection between Nucleo and ESP is OK or not.
  • you can check if your firmware is compatible

BR, Jan

1 Like

I just got mine working with a NUCLEO-L432KC on mbed 6.15. Different versions of the esp8266 seem to have different pin configurations. I eventually got this to work ESP8266 V2 Firmware update | Mbed
but needed to wire the gpio pins differently because I have an esp12. GPIO15, and 0 were grounded and then EN and 2 were 3.3v. Then to operate with the mbed device GPIO_0 goes HIGH and the rest stay the same. I also needed to give the esp its own 3.3v linear regulator with filtering capacitors.

The other thing I found is to actually connect I had to include the security type so

wifi.connect(“myrouter”, “mypassword”, NSAPI_SECURITY_WPA2);

I also found there appears to be some stuff in the ESP8266Interface.h file that don’t seem to matter like the country code and those default pin assignments.