Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
5 years, 9 months ago.
How do I specify the Tx/Rx pins for any given board
In my case I want to connect this board
https://os.mbed.com/platforms/MAX32630FTHR/
to the ESP8266 and run the example.
Where do I specify the Tx and Rx pins ?
Edit...
I did see the README.md file but it's not that clear and I'm not sure if it can be done.
Perhaps someone could clarify please, ideally with an example.
Question relating to:
1 Answer
5 years, 9 months ago.
Hello Paul,
That's a very good question. The mbed-os-example-wifi just briefly says that "ESP8266 is a fallback option and will be used if the build is for unsupported platform".
Searching the Mbed OS 5.11 source code then reveals that:
esp8266Interface.h
//.. #ifdef TARGET_FF_ARDUINO #ifndef MBED_CONF_ESP8266_TX #define MBED_CONF_ESP8266_TX D1 #endif #ifndef MBED_CONF_ESP8266_RX #define MBED_CONF_ESP8266_RX D0 #endif #endif /* TARGET_FF_ARDUINO */ //..
esp8266Interface.cpp
//... #if defined MBED_CONF_ESP8266_TX && defined MBED_CONF_ESP8266_RX ESP8266Interface::ESP8266Interface() : _esp(MBED_CONF_ESP8266_TX, MBED_CONF_ESP8266_RX, MBED_CONF_ESP8266_DEBUG, MBED_CONF_ESP8266_RTS, MBED_CONF_ESP8266_CTS), _rst_pin(MBED_CONF_ESP8266_RST), // Notice that Pin7 CH_EN cannot be left floating if used as reset _ap_sec(NSAPI_SECURITY_UNKNOWN), _if_blocking(true), _if_connected(_cmutex), _initialized(false), _conn_stat(NSAPI_STATUS_DISCONNECTED), _conn_stat_cb(NULL), _global_event_queue(NULL), _oob_event_id(0), _connect_event_id(0) { memset(_cbs, 0, sizeof(_cbs)); memset(ap_ssid, 0, sizeof(ap_ssid)); memset(ap_pass, 0, sizeof(ap_pass)); _esp.sigio(this, &ESP8266Interface::event); _esp.set_timeout(); _esp.attach(this, &ESP8266Interface::update_conn_state_cb); for (int i = 0; i < ESP8266_SOCKET_COUNT; i++) { _sock_i[i].open = false; _sock_i[i].sport = 0; } _oob2global_event_queue(); } #endif //...
From that I concluded that for Mbed boards equipped with Arduino headers the ESP8266 TX
pin is specified as D1
and ESP8622 RX
pin as D0
.
To specify TX and RX for unsupported Mbed boards the mbed_app.json
file could look like:
mbed_app.json
{ "config": { "wifi-ssid": { "help": "WiFi SSID", "value": "\"SSID\"" }, "wifi-password": { "help": "WiFi Password", "value": "\"PASSWORD\"" } }, "target_overrides": { "*": { "target.network-default-interface-type": "WIFI", "esp8266.tx": "p9", "esp8266.rx": "p10", "esp8266.socket-bufsize": "1024", "platform.stdio-convert-newlines": true } } }
NOTE: Replace p9
, p10
with actual TX, RX pin names of used Serial port, respectively.
Hello Zoltan,
Thank you for your time investigating, however unfortunately I get:
WiFi example Mbed OS version 5.11.4
ERROR: No WiFiInterface found.
I did also try 3 of the default boards and got the same result so that's it for now, maybe the next revision it will be working again.
For now I will continue with Mbed 2 as that's working well atm.
posted by 20 Feb 2019I've added one more line to the mbed_app.json
file to set the esp8266.socket-bufsize
.
Then after making this modification to the main.cpp
it works fine for me with LPC1768 :)
main.cpp
#include "mbed.h" #include "ESP8266Interface.h" //WiFiInterface *wifi; ESP8266Interface *wifi; //... //wifi = WiFiInterface::get_default_instance(); wifi = new ESP8266Interface(); //...