Category Archives: ESP8266


ESP-14 experiments – Stage 2: Breadboarding

In order to start using the ESP14, I had to ‘breadboard’ it first.

In the past, I tried various things to solder a plain ESP-12 on veroboard, and that has always been a tedious and time-consuming operation.

There are some ‘backplane’ PCBs available too for ESP-07/12 modules, but they do not bring out the 6 extra pins on the short edge opposite the antenna. This is not much of a problem for ESP-12E/F, but for ESP-14 those pins include the crucial E_GPIO0 required to flash the ESP8266:esp14_pinout

I tried another technique this time with the ESP-14, the idea being to wrap it with copperwire, solder the pads and then remove the extra wires.

For this, I’m using copper wire from a telephony pairs cable such as this one:20160125_182349.jpg

I extract a single copper wire from it, and start wrapping it around the ESP-14, making sure the wires go across the 6 side pins:

After that, wire the 16 other pins the other way round, and solder the pins/pads to the wire:

Once all pads are soldered, start cutting the wire on the bottom side only, so making sure to keep the ones that are pointing down so that they can be used as pins afterwards:

Finally, prepare a veroboard with two rows of header pins:20160125_195027.jpg

Solder the ESP-14 using the made-up pins, and making sure there are no shorts:

Finally, cut and remove the wires that are passing across the top, above the ESP-14 shield:

Et voila, the final result, a breadboarded ESP-14:




ESP-14 experiments – Stage 1: Overview and STM8S

Hardware overview

The ESP-14 is kind of like a multi-core ESP8266, combining an ESP8266 mcu with a STM8S003F3 mcu (内部图 means internal diagram):tb2nrdeefxxxxbmxpxxxxxxxxxx_882680026The purpose of this combination is to provide more I/O pins than a regular ESP8266 based board such as ESP-12x, acting as an I/O extender.
The STM8S003F3 mcu is 20-pin packaged low-cost 8bit mcu running at 16MHz, with 8kb flash memory and 1kb RAM.
It sports 16 GPIOs, of which 5 multiplexed 10-bit ADC channels, and UART Tx (PD5) and Rx (PD6). Well, unfortunately, the UART ports are also two of the ADC ports, so this will restrict to 3 available ADCs, 2UART and 11 digital IOs (configurable as I2C or SPI bus too).
The ESP-14 board’s 22 pins breaks out all of STM8’s pins, plus the ESP8266 VCC and  GPIO0 pins, to control flashing of the ESP.

As found out by Benjamin De Jong, and Mark the STM8’s PD5 and PD6 pins are connected to the ESP8266’s Rx and Tx pins. It is not clear if other pins are connected internally too or not.

Software setup

ESP8266 flashing and programming

Once you know that Rx/Tx of the ESP are pins M_PD5/M_PD6, and GPIO0 is available to set the Flash mode, programming the ESP8266 part of ESP-14 will be  business as usual, using your regular USB/TTL for flashing.
If you are used to Node-MCU’s DTR/CTS-driven automatic reset and flash mode setting, you will need to go back to the good old method of resetting the ESP while pulling down GPIO0.
Here resetting will mean removing power from E_VCC (pin 14) and then putting it back. A bit of a hack…

STM8 flashing and programming

Not so for the STM8, at least not for us ESPers…
Here we enter the world of low-end STMicro MCUs that are flashed and debugged through the Single Wire Interface Module (SWIM) protocol.
20160113_231318.jpgFor this you will need a ST-Link V2 USB dongle, which is required to talk to the STM8 programming (flashing) and in-chip debug interfaces.
SWIM actually uses 4 wires, GND, VCC, RESET and SWIM. See SWIM protocol details. I got myself a cheap dongle on AliExpress and it works great:

It shows in the window peripherals as STM32 STLink



STM8 Tools and information

Reference hardare information can be found on STMicro’s web site.
More specifically, the datasheet for STM8S003F3, and STM8S103F3. Those two chips are essentially the same, but the 103F3 is available in cheap (<$1) boards that I will use for experimenting STM8 programming.

STMicro’s site provides free tools to handle STM8:

  • STVD: ST Visual develop IDE for developing ST7 and STM8 applications.
    This will among other things give the C header files for the STM8Sx03F3 with pin definitions.
    You get a with an installer EXE inside that will install both STVD and STVP (flasher tools).
    You may want to install the USB drivers when prompted. Otherwise they can be installed later with st_toolset\stlink>stlink_winusb_install.bat.

    Use st_toolset\stlink>ST-LinkUpgrade.exe to verify that the STLink can be connected to and upgrade the firmware if need be.
  • STSW-LINK009: ST-Link, ST-Link/V2, ST-Link/V2-1 USB driver signed for XP, Windows7, Windows8 (also included in STVD)
  • STM-Studio: STM Studio run-time variables monitoring and visualization tool for STM8 and STM32 microcontrollers.

The web site has plenty of information on STM8 and STM32 mcus:

STM8 Toolchain/compilers:

There are several ways to get a free compiler to build STM8 code binaries:

I finally elected to use IAR because it is available and has eclipse integration, although most tutorials and the STVD env uses Cosmic (or Raisonnance which does not have free licences). But I could not get the Cosmic download, web site is stuck somehow…

There is no Arduino ‘boards.txt’ support for STM8, and contrarily to STM32 it is not supported by either, so we’re pretty much bare here.

First Blink program

As I mentionned, I used a cheap STM8S103F3P6 (8k) board, available for $1, for testing.

After installing all software, upgrading the STLink dongle firmware to the latest using SVDP, I connected the 4 SWIM pins of the STM8 board to the STLink dongle:20160113_231630.jpg

The STM8 I had was initially flashing its red Test LED, but after I connected STVP to it it stopped, presumably I had reset the flash…

To verify the SWIM is working, start the STVP UI, Select STLink/SWIM/STM8S003F3. Then try to Read/current Tab the memory. You may get an error stating that ROP is ON, but at least this validates the connectivity to the STM8 chip.

IAR setup:

Need to setup, from Options context menu in workspace:

  • include files to point to st_toolset\include (C/C++ compiler/Preprocessor/additional includes)
  • debugger to use SWIM: Driver set to STLink rather than Simulation
  • compiler, disable optimization otherwise empty ‘wait’ loops will be removed!
First blinky code

Create a new C project, replace main code with this one:

#define __CSMC__
#include "STM8S003F3.h"
int main() {
        int d;
        // Configure pins
        PB_DDR = 0x20;
        PB_CR1 = 0x20;
        // Loop
        do {
                PB_ODR ^= 0x20;
                for(d = 0; d < 29000; d++) { }
        } while(1);

(taken from

Run make, then Download and Debug

=> the test LED blinks!

Now, one thing that’s becoming obvious is that the programming model is closer to the metal on STM8 than when you have a neat and cosy Arduino board definition for it… No digitalRead(pin) here, just plain low-level memory-mapped I/O instead.

Using STM8S Libraries

STMicro provides a set of libraries at STSW-STM8069 STM8S/A Standard peripheral library, with higher-level macros to drive the various interfaces.

Now, while writing this, I realized that using the STM8 as a I/O slave, I would have to find ‘drivers’ coded for the STM8 for the various peripherals we commonly use, e.g DS18B20, WS2812, DHT11, HX711, …

What’s Next

To be continued… Next instalments will deal with making use of ESP14’s STM8S, now that I know how to deal with that little fella, and having ESP8266 and STM8 talk to each others…

See ESP-14 experiments – Stage 2: Breadboarding


ESP Witty

A new ESP8266 board has emerged recently, dubbed ESP Witty, which currently sells for $2.60 on AliExpress:


ESP Witty top view

The board is produced by a chinese company called GizWits, their website which requires registration has some content in english, but documentation remains scarce.

The novelty of this board vs other ESP8266 boards, is that it is made of two stacked boards:rgb_thermistor_esp8266

  1. a simple lower board holding a CH340G USB/TTL converter, two Flash&Reset push buttons, two transistors and a micro-USB socket:


  2. an upper board holding on the top side an ESP12-F,  a RGB LED in 5050 SMD package, a photo resistor, and on the underside, a LM1117 3.3V regulator, another micro-USB socket and one push button:

The board can be powered from either USB sockets, only the underboard one providing USB/COM bridge of course.
The main upper board can operate stand-alone without the lower board, and exposes the useful ESP8266 pins in two breadboardable 1/10″ 8-pin headers.

Built-in I/O wiring:

As found out by sej7278 in this post, the wiring is as follows:

  • Push Button on GPIO04
  • Red LED on GPIO15
  • Green LED on GPIO12
  • Blue LED on GPIO13
  • Photo Resistor on ADC/TOUT/A0 pin

Firmware setup and Control UI:

The board boots with its UART set at 115200 bps, and spits out a ESP SmartConfig sequence, similar as:

mode : sta(5c:cf:7f:11:97:80) + softAP(5e:cf:7f:11:97:80)
add if0
add if1
dhcp server start:(ip:,mask:,gw:192.16)bcn 100
SDK version:bcn 0
del if1
mode : sta(5c:cf:7f:11:97:80)
SC version: V2.5.0
f 0, scandone
f 0, scandone

If the button is pressed, a message button_press_3s! is output too.
The ESP8266 does not put a new SSID up, although I’ve briefly seen a WOWSTAR_something SSID poping up and then going away.

Instead, it uses the TI CC3000 SmartConfig protocol (or hack) which involves sending SSID and PW encoded in UDP packets length, and does not require the chip to be authentified yet on the WPA2 Access Point, but has the side effect of letting anyone listening to SmartConfig traffic know your SSID and its password…

Anyhow, GizWits provides an Android (or iPhone) app that allows to setup the ESP Witty onto your Access Point using SmartConfig, and bidirectional connectivity to the GizWits cloud once setup:

Get the app from

Launch it on your tablet or phone, then select Add Device from the menu, this takes you to the AirLink Configuration page. The ESP boots in config mode so just press Next.
The next page should show the current AP’s SSID and ask for the password: ESPWitty_SmartConfig
Select Wifi Module Type ESP, enter the password and click Configure. If you have a COM terminal connected to your ESP, you will see the connection sequence:

 T|PHONE MAC: bc 72 b1 xx yy zz
 T|AP MAC   : 76 ae b1 xx yy zz
 f 0, scandone
 state: 0 -> 2 (b0)
 state: 2 -> 3 (0)
 state: 3 -> 5 (10)
 add 0
 aid 3
 pm open phy_2,type:2 0 0
 connected with SOMESSID, channel 1
 dhcp client start...
 Phone ip:
 TCP: Connect to ip
 MQTT: Connected to broker
 MQTT: Sending, type: 1, id: 0000
 TCP: Sent
 TCP: data received 4 bytes

You will then have the ability to register the device, and will be directed to a control panel in Chinese with cursors that control the Witty’s IOs, the first one controls the RGB LED brightness, and the 3 others the R,G,B channels:ESPWitty_ControUI

Sliding the bottom cursors will change the RGB light’s color and brightness: