Programming the ESP8266 12F Module

ESP8266 WiFi Module

1/25/2023

I recently re-visited a device that I had only briefly messed with back in 2020.

If you haven't heard of these you’re in for a big surprise. You can get these modules 

for around $2 each and pretty much use them without programming right away.

They are shipped with default “AT firmware” which allows one to simply connect a 

USB-Serial adapter and a terminal to control the various WiFi features through “AT” commands
(much like the AT modem commands some of us remember). 

If you’re looking to automate a bit further without re-programming the device you can 

use an Arduino or whatever microcontroller you’re comfortable with to send the 

serial commands programmatically.


However, the device has a very capable 32bit processor that you can program yourself 

There’s a decent amount of RAM (~32K) and available flash (~3MB) for your custom programming.  

The initial version of the ESP8266 (ESP01S) was a tiny thing with only a couple of I/O pins so it really needed to be paired with another microcontroller, but the 12F module pictured above 

provides 10 GPIO pins for you to play with. (their latest device, the ESP32 has even more)

Furthermore there's an active online community at https://www.esp8266.com/ if you need help.  


 A lot of folks are using the Arduino IDE and environment to program this device but I chose 

to use standard C and the eclipse IDE since I’ve been using that for other 32bit devices.


I found a nice guide on how to do the entire eclipse setup for ESP8266 here:

 https://blogs.sap.com/2015/06/08/esp8266-programming-from-eclipse/


This guide involved download of a few third party setup programs but they all ran smoothly 

for me.


Programming the device is done through the serial port and built in bootloader which is 

activated by holding a specific GPIO pin low during reset. One of the packages in the eclipse environment setup mentioned above installs the tools necessary to upload programs to the device.



But let’s back up a bit….

The ESP8266 is a low-cost Wi-Fi chip with full TCP/IP stack and an integrated Tensilica L106 32-bit RISC processor running at speeds up to 160mhz. The Espressif SDK provides access to all the hardware and WiFi network functionality the device contains.


But what’s all this mean to me?

Well for starters, with very little programming, the device can become a (very limited) stand-alone webserver.  


The features I think are more usable for the hobbyist like myself are:

1. TCP/UDP/SSL server:    This feature allow simple data transfer supported by many

   terminal applications (like PuTTY)  over a WiFi connection when combined with one or 

   both of the modes described next.


2. WiFi Station Mode:   In this mode the device can connect to your existing router/network

    and through that connection another device (PC, Laptop, Phone or another ESP8266) 

    can exchange data with the device. Of course in this mode the device needs to be 

    provided with the network name (SSID) and network password.


3. WiFi Soft Access Point Mode: In this configuration the device appears as it’s own 

    router/network with it’s own SSID , optional password and IP address. 

    Other WiFi capable devices can, for instance, connect to the TCP server and exchange 

    data or messages. This mode is great for using WiFi to connect to a device when no 

    other network is available.



I’ve included sample projects that use the features described above as well as one that

simply uses the MCU to drive a common OLED display module.


ESP8266 Breadboard Setup 

CPU connection map
Note the clever LED circuit on pin 15/CS. This pin needs to be
pulled LOW for programming but afterwards it can be used
for anything else so we added this indicator LED setup.
Same is true for the programming switch / pin. Once programmed, we can use GPIO0 for input or output.

Module with header pins soldered on

Description of download links:

2c-esp8266_non_os_sdk_api_reference_en.pdf    SDK Reference
esp-12f_product_specification_en.pdf ESP8266 12F Datasheet
uart_ap_connect.zip Router connected  TCP Server example
uart_sap_tcp_server.zip Soft Access Point & TCP Server example
uart_ssd1306_OLED.zip Driving a SSD1306 OLED Display example