Arm Community
Arm Community
  • Site
  • User
  • Site
  • Search
  • User
Arm Community blogs
Arm Community blogs
Embedded and Microcontrollers blog Getting started with NUCLEO-F411RE and ESP8266
  • Blogs
  • Mentions
  • Sub-Groups
  • Tags
  • Jump...
  • Cancel
More blogs in Arm Community blogs
  • AI blog

  • Announcements

  • Architectures and Processors blog

  • Automotive blog

  • Embedded and Microcontrollers blog

  • Internet of Things (IoT) blog

  • Laptops and Desktops blog

  • Mobile, Graphics, and Gaming blog

  • Operating Systems blog

  • Servers and Cloud Computing blog

  • SoC Design and Simulation blog

  • Tools, Software and IDEs blog

Tags
  • Nucleo
  • Mbed
  • Tutorial
Actions
  • RSS
  • More
  • Cancel
Related blog posts
Related forum threads

Getting started with NUCLEO-F411RE and ESP8266

Jayalaxmi B
Jayalaxmi B
April 7, 2015

I received my STM32F411RE Nucleo board last weekend (Thanks to Carissa for selecting my idea). Overall board looks good and worth it's price with powerful STM32F411RE and on board ST Link debugger. The only drawback I noticed was missing USB OTG connector for STM32F411RE. This platform is Mbed enabled and the on board ST Link debugger provides standard Mbed interface such as drag-drop programming with virtual serial port connected to USART2 too.

Let's get started

To get started, download the ST Link drivers and then download ST Link FW update software. First Install the drivers and then run the debugger FW update software "ST-LinkUpgrade.exe"  and click on "connect device", which will recognise any ST Link debugger connected to host system. This step also retrieves the current debugger FW version. Click on "Yes>>>>" which will initiated the update procedure.

After update the debugger FW, I used this board to achieve something meaningful. I connected Grove temperature sensor along with ultra low cost ESP8266 WiFi module to use as web-server to fetch realtime temperature. Below is my setup.

STM32F411RE Nucleo Board

I used Mbed framework which is easier for prototyping. Communication with ESP8266 WiFi module is using "AT" commands over UART lines. There are lot tutorials available on internet on how to update the ESP8266's FW. The connections are pretty simple. Grove temperature sensor is connected to "A0" of Nucleo board. ESP8266's Rx and Tx is connected to UART1 lines available on D2 and D8 of nucleo board. ESP8266's power lines are connected to 3.3v and GND. Rest of lines should be pulled high. Below is my Mbed code which serves webpage on request.

Mbed Code

#include "mbed.h"


#define BUFFER_SIZE 100


Serial esp(D8, D2);
Serial pc(USBTX, USBRX);
AnalogIn ain(A0);


uint8_t buffer[0x100];
uint16_t buffer_head;
uint16_t buffer_tail;
bool webreq = false;


void rxcallback(void) {
  uint8_t chr;
  static uint8_t state = 0; /* Invalid state */
  while (esp.readable()) {
       chr = esp.getc();
       pc.putc(chr);
       switch(chr) {
      /* look for GET token */
       case 'G':
            state = 1;
            break;
   
       case 'E':
            if (state == 1) {
            state = 2;
            }
            break;

       case 'T':
            if (state == 2) {
            state = 0;
            webreq = true;
            }
            break;
   
       default:
            break;
       }
       buffer[buffer_head++] = chr;
       if (buffer_head == BUFFER_SIZE) {
       buffer_head = 0;
       }
  }
}

void flush_fifo(void) {
  while (esp.readable()) {
  (void)esp.getc();
  }
  buffer_head = 0;
  buffer_tail = 0;
}


int find_response(const char *resp) {
  /* Give some delay for buffer to fill up */
  wait_ms(10);
  int timeout = 0xFFFFFF;
  int len = strlen(resp);
  do {
  if (buffer_head > (buffer_tail + len)) {
  if (!memcmp(&buffer[buffer_tail], resp, len)) {
  flush_fifo();
  return 0;
  }
  buffer_tail++;
  }
  }while(timeout--);
  flush_fifo();
  return 1;
}


float get_temperature(void) {
  int a;
  float temp;
  int B=3975; /* B value of the thermistor */
  float res;

  a=ain*1023;
  res=(float)(1023-a)*10000/a; /* fetch resistance of the sensor */
  temp=1/(log(res/10000)/B+1/298.15)-273.15; /* temperature conversion */
  return temp;
}


int main() {
  char webpage[] = "Temperatue: ";
  flush_fifo();
  esp.attach(&rxcallback, Serial::RxIrq);
  esp.printf("AT+RST\r\n"); /* reset module */
  MBED_ASSERT(find_response("OK") == 0);
  esp.printf("AT+CWMODE=2\r\n"); /* configure as access point */
  /* Error checking is not required */
  wait(2);
  flush_fifo();
  esp.printf("AT+CIFSR\r\n"); /* fetch ip address */
  MBED_ASSERT(find_response("OK") == 0);
  esp.printf("AT+CIPMUX=1\r\n"); /* configure for multiple connections */
  MBED_ASSERT(find_response("OK") == 0);
  esp.printf("AT+CIPSERVER=1,80\r\n");
  MBED_ASSERT(find_response("OK") == 0);
  pc.printf("\r\nESP8266 Initialization done!!!\r\n");
  webreq = false;
  while(1) {
  if (webreq == true) {
  find_response("OK");
  esp.printf("AT+CIPSEND=0,%d\r\n", sizeof(webpage) + 3);
  find_response(">");
  esp.printf("%s", webpage);
  esp.printf("%0.2f", get_temperature());
  find_response("OK");
  esp.printf("AT+CIPCLOSE=0\r\n");
  flush_fifo();
  webreq = false;
  }
  }
  return 0;
}

Anonymous
Embedded and Microcontrollers blog
  • Formally verifying a floating-point division routine with Gappa – part 2

    Simon Tatham
    Simon Tatham
    A method of testing whether a numerical error analysis using Gappa really matches the code it is intended to describe.
    • September 4, 2025
  • Formally verifying a floating-point division routine with Gappa – part 1

    Simon Tatham
    Simon Tatham
    Learn the basics of using Gappa for numerical error analysis, using floating-point division in Arm machine code as a case study.
    • September 4, 2025
  • Building Solutions on Arm: A recap of IEEE Arm Community Technothon project presentation

    Fidel Makatia
    Fidel Makatia
    Read Fidel's account from the Arm Community Technothon!
    • December 4, 2024