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:
- Setting Up Thingspeak.com Account and Channel.
- Making Hardware Connections
- Writing the Code.
- Visualizing the Output.
Step 1: Setting Up ThindSpeak.com Account and Channel.
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:
- 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
- VR Pin 1 ------------> Nucleo +3.3V
- VR Pin 2 ------------> Nucleo A0
- VR Pin 3 ------------> Nucleo GND
- I am Using esp8266 v1. For other versions, you may need to connect some other pins to Vcc/GND.
- DON'T Connect to +5V!
- 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.
We have a be nice policy.
Please be positive and constructive.