In this tutorial, the ESP8266 WiFi Module is used with a bmp280 sensor on the SHAKTI Processor. In the previous article, we saw how to use BMP280 with SHAKTI. Now we are going to use 2 two sensors – ESP8266 and BMP280 with SHAKTI. We are going to get the temperature and pressure values from the BMP280 sensor and send it to thingspeak.com over WiFi using ESP8266 WiFi module
The ESP8266 WiFi Module is integrated with a TCP/IP protocol stack that can give any micro controller access to your WiFi network. The ESP8266 is capable of either hosting an application or offloading all WiFi networking functions from another application process. Each ESP8266 module comes pre-programmed with an AT command set firmware i.e you can simply hook this up to your development board and get about as much WiFi-ability as a WiFi Shield offers.
Step 1: Requirements
- Arty7 35t/100T board with either
pinaka, parashu or vajraprogrammed on it.
- shakti-sdk and shakti-tools installed or Platform IO installed and ready
- ESP8266 WiFi Module and BMP280
- Micro USB Cable and Jumper Wires.
- A Hotspot or WiFi for Internet connectivity.
- A channel in thingspeak.com to receive data from ESP8266.
- API key from the configured
Step 2: The Circuit
Firstly, lets see the ESP8266 connections only.
- GND connected with GND.
- TX (GPIO-1) connects with GPIO-0.
- CH_EN connects with 3.3V.
- RX connects with GPIO-1.
- VCC connects with 3.3V(only).
Note: GPIO-0 and GPIO-1 are UART pins. Here we use Arty35t for instance. Also, the connections are the same in Arty100t boards. For better clarity, Check the device pin mapping for
pinaka, parashu and vajra.
Now when we connect both ESP8266 and BMP280 to board,
The connections for BMP280 is as follows,
- VCC to 3.3V
- GND to GND
- SCL to SCL of board
- SDA to SDA of board
- CSB to 3.3V
- SDO to GND
Step 3: Code
Please click here to have a look at the code.We send the temperature and pressure reading from BMP280 to the thingspeak server via ESP8266 WiFi module. The ESP8266 WiFi module uses 115200 as baud rate to communicate with the
Every wireless, as well as the dial up modems, require an AT command to interact with a computer machine.
Therefore AT commands are used here for the communication between the WiFi module and the
thingspeak server. Also, AT stands for attention.
AT commands are required to connect, to set up and to send the data to the server. Please check the source code, where all the commands are used for device set up and configuration.
Steps to connect to WiFi:
- AT+CWJAP=\”WiFi or Hotspot name\”,\”Password of the WiFi\””
Steps to send data to the server:
- AT+CIPSTART=\”TCP\”,\”Server_name or api link\”,Port_No.
- AT+CIPSEND=Number of bits want to send
- GET “Send the value to the server through API keys”
Code can be compiled and run using the following ways,
Step 4.1: Manual Method
4.1.1 Compile and build
- Move to
- Compile using
make software PROGRAM=? TARGET=?. However, type
make list_applnsto list all the applications available in the SDK. Target can be either
parashu, pinaka or vajra.
For instance, use target as
make project PROGRAM=weatherstation_bmp280 TARGET=parashu
Once the application is built, the executable is generated in the output folder. The executable is in
ELF file format and they have the extension
.shakti. Now, open three terminals, one for each of the following,
- One terminal for UART terminal display
- Another for
- And the last one for
Terminal 1 (Optional):
Firstly, Connect to serial output by using miniterm or gtkterm with the baud rate of 19200.
As the main aim of this project is to send the values we get from BMP280 to the
thingspeak server via ESP8266. The serial terminal output is not required since its only for our easy understanding.
$ sudo miniterm.py /dev/ttyUSB1 19200
- “/dev/ttyUSB1” – ttyUSB means “USB serial port adapter”
- The “1” (“0” or “1” or “2”“here means the USB device number on your system. The FPGA board is connected to that USB device number.
Terminal 2: After that, Connect to the FPGA board by using the OpenOCD provided by shakti-tools and its respective configuration file. (Read how OpenOCD and RISC-V GDB work together to establish a connection between our PC and the Microprocessor)
For instance, if we use
$ cd shakti-sdk $ cd ./bsp/third_party/parashu $ sudo $(which openocd) -f ftdi.cfg
pinaka and vajra, Goto
Terminal 3: Now, open either 32bit or 64bit RISC-V GDB based on your architecture i.e
riscv64-unknown-elf-gdb respectively from shakti-tools.
The output executable is created in
Now load up the
.shakti file by following the below steps. For Parashu,
(gdb) set remotetimeout unlimited (gdb) target remote localhost:3333 (gdb) file path/to/executable (gdb) load (gdb) c
4.1.3 Upload to flash
The SHAKTI-SDK has an uploader tool that is used to load content (such as ELF) to flash, after building the image.
- Goto the right directory.
make uploadcommand to build and upload the application to the flash automatically.
make upload PROGRAM = weatherstation_bmp280 TARGET = parashu
Here, the bare metal user application created is
"PROGRAM". The target can be either
parashu, pinaka or vajra. Type
make list_applns to list all the applications available in the SDK.
Step 4.2: Using Platform IO
We can use IDE’s like Platform IO to compile, build, run, upload and debug. Please read the article on Platform IO on SHAKTI to understand the steps.
Open thingspeak website to view the temperature and pressure data transmitted over WiFi using ESP8266 module to
Akshaya currently works at the RISE labs. Her favorite subjects are Web designing and Microprocessors. She loves learning about new things and writing about them!