ESP8266 WiFi Bee: Uploading Arduino programs

The objective of this post is to briefly explain how to upload custom programs for DFRobot’s ESP8266 WiFi Bee board, using the Arduino IDE.


Introduction

The objective of this post is to briefly explain how to upload custom programs for DFRobot’s ESP8266 WiFi Bee board, using the Arduino IDE.

In order to complete this tutorial, we assume a previous installation of the ESP8266 support for the Arduino environment. The steps needed are outside the scope of this post and can be consulted in this previous tutorial.

In the previous tutorials about the ESP8266 WiFi Bee board, we have been covering the use of AT commands from the firmware that comes with the board. These commands allowed us to  easily control some of the WiFi functionality simply by using the Arduino IDE serial monitor.

Naturally, we could have used another device instead of the serial monitor, such as an Arduino board, to send commands to the WiFi Bee, which is the typical application scenario for a module such as this.

Nevertheless, using AT commands envolves sending and parsing strings, which is not the most optimized way of communicating via serial. On top of that, we are limited by the commands implemented in the firmware, which don’t expose the full functionality of the ESP8266 microcontroller.

So, although AT commands are a good way to start playing with the ESP8266 modules, moving to custom programs allows us to develop more robust applications that suit the needs of our project.

Although there are multiple ways of programming the ESP8266 (MicroPython, Lua, PlatformIO…), one the of the simplest is by using the Arduino environment support.


The Hardware configuration

Since the WiFi Bee doesn’t have a USB header, we will need a serial to USB adapter to be able to connect it to a PC.

The easiest way to do it is by using a Xbee USB adapter. Nevertheless, if you want a more custom approach, you can check this previous tutorial for a way to connect to the device using a simple serial to USB adapter.


Uploading code

After installing the ESP8266 Arduino IDE support, we need to choose a suitable board from the boards manager. At the time of writing, with version 2.3.0 of the ESP8266 libraries, the WiFi Bee is not yet available on the list of boards. Nevertheless, as indicated in figure 1, we can choose the NodeMCU 0.9 board and we will be able to update the code to our WiFi Bee board.

WiFi Bee code from Arduino IDE

Figure 1 – Choosing a board compatible with the flashing configurations of the WiFi Bee.

The code for this tutorial will be a very simple “Hello World program”. We will basically open a serial connection in the setup function and print a “Hello World” message each second, in the main loop.

void setup() {
 Serial.begin(115200);
}

void loop() {
  Serial.println("Hello from WiFi Bee");
  delay(1000);
}

Now, before uploading any of the code, we need to put the board on flashing mode. To do so, we simply pull the switch of the WiFi Bee to the “UART” side. Although I haven’t found in any document that this is necessary, I typically power off the board before changing the switch.

Then, make sure you select the correct COM port for the module and hit the upload button from the Arduino IDE. It may take a while to upload the code. In the end you should get a result similar to figure 2 on the IDE console.

WiFi Bee upload code from Arduino IDE

Figure 2 – Arduino IDE console after a successful upload of code.

Although the module is in boot mode, after a successful upload the code should immediately start running, we can pull the switch of the board back to “BOOT” to ensure that everything runs fine.

After that, just open the serial monitor of the Arduino IDE. You should get an output similar to figure 3.

WiFi Bee Arduino Hello World

Figure 3 – Output of the “Hello World” program.


Related content


Technical Details

  • ESP8266 Arduino IDE libraries: v2.3.0

Leave a Reply