Introduction: STM32F103: Esp8266 NodeMCU Getting Started [using Mbed.h]
In this tutorial, I will show you how to make internet connection, Send a GET request and receive responce using esp8266 (v1) NodeMCU and mbed.h.
This tutorial is divided into following parts:
- Making Hardware Connections.
- Writting Code
- Visualizing the output
If you haven't yet flashed NodeMCU onto your esp8266, please first flash it as shownHERE.
Step 1: Making Hardware Connections
Connect esp8266 to your Nucleo Board as Stated below:
- esp8266 Vcc ------>Nucleo +3.3V
- esp8266 CH_PD -> Nucleo +3.3V
- esp8266 GND ----> Nucleo GND
- esp8266 Tx -------> Nucleo D2
- esp8266 Rx -------> Nucleo D8
- esp8266 RESET -> Nucleo D3
- I am Using esp8266 v1. For other version you may need to connect some other pins to Vcc/GND.
- DON'T Connect to +5V
- As you have to connect two pins to single +3.3V output, make sure that both pins are connected!
Step 2: Writting Code
I have written some code on mbed compiler. You can get it directly from there and make changes as you like.
To get code, Click HERE. Now, Click on Import this Program (blue button) to import this to your compiler.
What our code will do is that it will send a GET request to Adafruit's testWifi page and will display the response. Using same procedure we can send GET and POST request to any website/API and read the response. In other words, we can easily send our sensor values to any remote server or API.
Now, Compile and Download/Copy the .bin file onto your Nucleo Board.
Step 3: Visualizing the Output
In order to visualize the output, you will need to install the a Software that can read from Serial Port. We will be using Putty, most widely used software. I have attached the .exe file. You can download it from here, or you can from elsewhere.
- Run putty.exe.
- Select Serial.
- Enter the COMport onto which your Nucleo is attached.
- Set Baud Rate to 115200.
- Click OPEN or press Enter.
Now, you should be able to see the connection status on your putty screen. When you will be successful, you will see a output like shown in image attached.
- Hardware intialization failed? Please make sure that you have made connection as stated before.
- Hardware intialization failed? Have you have flashed NodeMCU on esp8266? Please Note that by default it runs on AT Command firmware.
- Hardware intialization failed? What is BaudRate of your NodeMCU? Default BaudRate is 9600. If you haven't changed it explicitly then it must be 9600. Try Changing the BaudRate in Code (where we created object of esp8266)
- Not Connecting to your Network? Please Make sure that you have entered your SSID name and password correclt.