Category Archives: ESP-14

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