Introduction: STM32103: Esp8266 NodeMCU ThingSpeak [using Mbed.h]

In this tutorial, we will be going to send analog value of our Variable Resistor to a Remote Server (ThingSpeak.com) using our STM32F103RB Nucleo Board via esp8266 which will be programmed using mbed.h.

This Project is divided into following steps:

  1. Setting Up Thingspeak.com Account and Channel.
  2. Making Hardware Connections
  3. Writing the Code.
  4. Visualizing the Output.

Note:

  1. Please Follow this Tutorial First, to make sure that all your hardware connections are in place and your are not having any trouble with your hardware connections or Softwares etc.
  2. My esp8266 is running NodeMCU is you haven't flash NOdeMCU firmware onto your esp8266 yet, Click HERE to see how to.

Step 1: Setting Up ThindSpeak.com Account and Channel.

Creating ThingSpeak account is one of the easiest things to do. Click Here to go to SignUp Page.

Now, Click Here to open Your Channel Pages. Now, Click on that Green New Channel button. Here, Enter Channel Name in front to name, some description and Name field1 as variableResistance. As we want to store only variable resistance for now, so we are going to have only one field for now. If you want to enter more than one field just click on checkbox next to that field number and write the name of that field. You can leave remaining things empty or you can fill them as you wish. Just, Scroll down and click on Save Channel button.Now, you will be redirected to private_show window. Here you can see an Empty chart and above that is written the total number of entries. i.e. 0. Now, click on API Keys tab to get your Read/Write API Keys. Note Down these keys, we are going to use these very soon.

Step 2: Setting Up Hardware

Hardware Connections are pretty much same as were in last tutorial. I would highly recommend you to first go through that tutorial. Anyways, Make Hardware Connection as Stated below:

  1. esp8266 Vcc ------>Nucleo +3.3V
  2. esp8266 CH_PD -> Nucleo +3.3V
  3. esp8266 GND ----> Nucleo GND
  4. esp8266 Tx -------> Nucleo D2
  5. esp8266 Rx -------> Nucleo D8
  6. esp8266 RESET -> Nucleo D3
  7. VR Pin 1 ------------> Nucleo +3.3V
  8. VR Pin 2 ------------> Nucleo A0
  9. VR Pin 3 ------------> Nucleo GND

Note:

  1. I am Using esp8266 v1. For other versions, you may need to connect some other pins to Vcc/GND.
  2. DON'T Connect to +5V!
  3. As you have to connect multiple pins to single output pin, make sure that all connections are connected!

Step 3: Writing 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.

This code will simply read analog value from the variable resistor and send it to our thingspeak channel every time you it boots up (starts up).

Now, Compile and Download/Copy the .bin file onto your Nucleo Board.

Step 4: 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. Once downloaded, now 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.

Now, that we once you see that POSTed! line on your putty, switch to your thingspeak private_show window and on graph you will see the current value of Variable Resistance multiplied by 500 being displayed. To get more values, simply edit the code or Press that Black Reset button on your Nucleo Borard!

Congratulations! you have successfully sent variable Resistance to your thingspeak channel.