Hacking the WiFi3 Click

4

There are many ways to add Internet connectivity to a development board with a mikroBUS socket. There are at least three click boards providing wireless Internet connectivity, plus a wired Ethernet click board. Among those wireless click boards we find the WiFi 3 click, based on the popular ESP8266MOD chipset.

Right out of the box the ESP8266MOD communicates on UART interface set to 9600 baud, commands being sent using the AT command set (you will find the most recent list of the AT commands on Expressif’s documentation page, and I’ve also hosted a copy of version 1.4 of the AT command list here).

The problem is that after playing for some time with the original AT firmware you will find out it’s quite limited, and some things are not possible using the AT command set. But what about replacing the firmware with something better, such as LUA scripting or even Arduino? Yes, it’s possible, and I will show you how to do it.

Before going to reflashing the ESP8266 I have to warn you: replacing the firmware can have unexpected consequences, and you can damage your WiFi3 click beyond repair if you do something wrong. In my opinion the advantages of replacing the firmware are worth the risk, and I’m ready to risk one of my WiFi3 clicks only to see what happens.

Firmware Flashing Rig

Below there are some pictures of my firmware flashing rig: I use one USB-UART click for communication and also to provide 3.3V voltage from the USB line.

In the above pictures red wire is 3.3V, green wire is GND. Yellow wire is for UART communication – connect WiFi3 click RX pin to USB-UART TX pin and WIFi3 click TX pin to USB-UART RX pin.

Pins GPIO0, GIPO2 and CH_PD have pull-up resistors to 3.3V (I used 4.7k for pull-ups, but anything in the 3.3k – 10k range will work fine). Two buttons are used to connect pins GPIO0 and CH_PD to ground. Some bloggers suggest that pin GPIO2 can be left floating, some other say it should be pulled-up to 3.3V. I didn’t want to take any chances, so you’ll notice a 4.7k pull-up resistor on pin GPIO2.

Putting the WiFi 3 click into firmware download mode is made by connecting pin GPIO0 to ground and rebooting ESP8266 by pressing the button connected to the CH_PD pin. To prevent the ESP8266 to accidentally enter firmware download mode, some manufacturers are placing a permanent pull-up on GPIO0. In WiFi3 click the GPIO0 pin is left floating, and this leaves place to nasty behavior. If you notice that when using the WiFi 3 click goes from time to time into firmware download mode (or it’s just not responding after reset) then you might wish to try to install a pull-up resistor on pin GPIO0.

Another “nice” thing regards the pin GPIO15, which should act as reset. Well, it doesn’t. Strange!

With the above considerations, to install a new firmware one should press both buttons, then release the reset button while keeping GPIO0 low. One the ESP8266 enters firmware download mode, one can release also the button connected to GPIO0.

Flashing NodeMCU firmware

There’s a dedicated flasher software for NodeMCU which can be downloaded from https://github.com/nodemcu/nodemcu-flasher. Download the utility and run the ESP8266flasher utility.

Put the ESP8266 into firmware loading mode then press Flash. Wait to complete. Now you’re the proud owner of a NodeMCU-based ESP8266, ready to run LUA scripts.

If we connect to the WiFi3 click with a terminal program such as putty we will get:

The “cannot open init.lua” errors appears because we don’t have an init.lua file. So let’s create it:

This will create an empty init.lua file, which can be later populated with whatever commands we desire. Now when we reset the board we don’t get the missing init.lua error anymore.

Scanning for WiFi networks? Simple:

That’s just a proof that it works. I have no plans in the near future to learn LUA scripting, so the tutorial on NodeMCU ends here.

But wait, there’s more:

Programming WiFi3 click in Arduino

Arduino IDE offers support for ESP8266. All you have to do is to go to File – Preferences, and on Additional Boards Manager URL add “http://arduino.esp8266.com/stable/package_esp8266com_index.json”. Multiple .json files can be added, comma separated.

Arduino: ESP8266 boards support

Arduino: ESP8266 boards support

In Arduino IDE, Tools, choose “Generic ESP8266 board” and the corresponding COM port for communication. Don’t forget to put the WiFi3 click into firmware download mode before uploading your code – you will have to do this every time you recompile your code.

WiFi3 click: now with Arduino

WiFi3 click: now with Arduino

The real fun begins now: you have plenty of code examples to start with, plus tons of community code.

Share.

4 Comments

    • Hi Meseret

      The WiFi3 click communicates on serial interface (pins RX and TX of the click board). You can connect it to the Uno using one Arduino Uno click shield, nut you won’t be able to communicate with the PC, as it uses the same pins.

      As an alternative, you can use any digital pins, and use software serial library.

Leave A Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.