{,not} easy things

<-- home

Projects: Own little neat ESP8266 development board

3D render of the board

Continuing from the last time…

Another year, another old project digged from the forest of many folders.

This time, it’s ESP8266 board! I really liked this chip, for me it sparkled some kind of revolution in the microcontroller world. For the first time device with WiFi capabilities was so easy to build. It pushed the limits, defined what was really possible on small 32-bit chip with so little RAM (for today standards of those kinds of MCUs). To this day I can’t really believe that this tiny thing could actually make TLS connection, with full certificate chain verification. It doesn’t matter that it would need to run at 160MHz to even have a chance to make it before network timeout, it could do it.

Back to the topic - why this project even was made? It’s not like in year 2021 there was lack of ESP8266 development boards.

Warum?

From what I can remember the reason was really simple - I obtained more than 10 ESP-01 modules for cheap and tried to do something with them. Those modules have really only 2 pins that are useful for anything, there was no way to go to Deep Sleep with them (to be precise: MCU could jump to this state, but with no additional pin connected, there is no way to wake up). So I decided to make something myself.

Looking back at this project: The Good

Constrains

Back then I made some set of requirements on what I want this board to be: A better WeMos D1 mini clone. I was really surprised when they showed D1 Mini Lite that had all the elements on one side. I decided that I would try to do the same. I also decided to make some improvements: use DC/DC instead of LDO, bigger antenna and better protection. So, requirements in bullet-point list were:

  • WeMos D1 mini form factor with the same pin-out
  • DC/DC for 3.3V line
  • Better antenna
  • Components from single side
  • be cheap, preferably re-use as many components from ESP-01 as possible

I managed to find really nice PCB antenna design from TI, and not knowing much about antennas I decided that based on the measurements in the datasheet it seemed like the best candidate: wide bandwidth, 50-Ohm matched, just right dimensions.

Project Log

I wouldn’t be able to make this post with all those details without the one text file that I found within the project folder - it was the log where I’ve basically made a diary per-day basis. When no work on project was done during the day, I would also take a note of that. Looking back it was really good idea to actually keep this kind of log book. While I wish I would make some more detailed descriptions and skip some opinions written in this file, I think it’s nice to look back and be able to understand the way of thinking of past-self.

Thanks to those notes I know that designing this module took about 20 afternoons with some day-offs.

Being based on schematics from other projects

The schematic is nothing special - most of the diagram is a clone of D1 Mini or D1 mini pro, including some seemingly unnecessary components. Thanks to this approach I was more confident that it should work first time, And indeed,the board worked first time, including WiFi, USB-UART and programming. It has a SMD Fuse, back-power protection, LEDs indicating UART activity, Solder jumper for Deep-Sleep, protection for USB data lines and the same pin-out as D1 mini.

At the time I was really proud of the PCB and routing I’ve done. I managed to fit all components on one side and two chips with the same package at 45 degree ange looks really neat.

The Bad

I should’ve published this project sooner. Really - there was no reason to not do so. Better late than never I guess…

Oh, and and lack lack of photos. I never documented my projects aside from some notes and one photo of one of soldered boards during tests.

The Ugly

Looking back, I now know much more abut KiCad - for example, using global net labels on single-sheet schematic is just wrong. Also, there was no reason to cramp everything into one sheet - readability suffers greatly. Back then I knew nothing about antennas, now having access to world-class 3D EM simulation software I know even less. I haven’t really checked how good the matching really was, but even now I don’t think it would be possible. ESP8266 doesn’t have any S params aside from typical driver impedance. I don’t have any equipment to do a load-pull test, so I would have to rely on this single information from Espressif.

Looking at the layout one again after 3 years, I’ve made some small mistakes: Mediocre DC/DC layout (feedback not in the best place), usage of 0.8mm/0.4mm vias instead of 0.65mm/0.3mm or similar ones, little things in routing.

About ESP8266 itself…

This chip has very interesting history and for the time it was unmatched for IoT WiFi solutions. Really, many other manufacturers tried but most of them had even worse public documentation, was more costly or required complicated impedance matching and many additional components. The biggest problem was lack of hardware debugging tools from Espressif (the only mention of JTAG even existing on this chip was from here, so the best you could to was to include gdbstub and debug it via the only UART present on the chip (nitpick: there was one UART TX present, but no RX - what a odd design choice). At least programming the chip was easy and it was not possible to brick the device in any way. Still, I cannot imagine working on MCUs today with no access to either emulator or proper debugger, especially when things as complicated as TLS handshake were involved.

This chip was also the real step-up for some embedded developers like me - no more “dynamic allocation to be avoided”. To get functionalities like proper HTTPS or MQTT with TLS, dynamic allocation was inevitable. Memory fragmentation problem became very real and sometimes resetting a chip was not an option. Fortunately, there were projects like umm_malloc that made the problem less severe.

There are to this day couple of incredible projects around it:

  • Arduino port for the chip - This one is a really good demonstration of power of C++ in embedded. Many neat C++/Linker tricks that allow to save Flash and RAM, really good integration of BearSSL and other libraries. It would be a sin to not mention ESPAsyncWebServer that just works.
  • NodeMCU firmware - Probably the most advanced integration of Lua in embedded MCU. The interpreter is heavily modified to add support for read-only constants and code present only in flash. This allowed to save so much RAM that this firmware could handle real applications, with OTA and stuff.
  • Sming which is still active, gaining support for other chips like ESP32, RP2040 etc.
  • esp82xx-nonos-linklayer This project is a perfect example on how to solve hard things properly. LwIP was a mess on ESP8266 and work of d-a-v and other contributors finally made it possible to use stable, upstream TCP/IP stack.

Many others like ESPhome, espurna are also still going strong, but I haven’t used them that much.

I owe many home automations to this chip, even one unit of this board I made was used to monitor temperature in a greenhouse. I would still recommend looking into above projects to see an excellent example on how to deal with complicated architecture problems and closed-source binary blobs.

Link to the project: neatboard-esp8266 Updated symbols to newest KiCad version, suppressed some DRC warnings and errors] that I was comfortable with and uploaded both versions of gerber files.

Until next time…