I made a cp2102n-based UART programmer.

Oh cool, another USB-UART bridge. I can get one for 1$ on aliexpress. Nice time and moneywaster bro. ~You

Oh no, no. This board comes with a twist that makes it like 100x better.

Take a closer look at that 3v3-out!

What do we use our UART-based programming boards for? 3-sigma of times it’s either Arduino board, or ESP8266/ESP32 - based device. These rarely require more than 500mA of continous power, and therefore can be powered with standard USB port. But USB gives you 5V, and modern electronics tend to work off 3V3.

Yet all the programming boards I came upon either provide no 3V3 output, or expose shitty LDO built into USB-UART bridge chips. These usually won’t provide more than 100mA.

I decided to create a device with integrated 500mA LDO, and it costed me like 10C.

You can have a look here: https://github.com/cr1tbit/lichtenprog

Schematic

Since the programming device is designed to work with ESP32 chips, the schematic is actually based on a standard ESP32 devkit: https://dl.espressif.com/dl/schematics/ESP32-Core-Board-V2_sch.pdf

The LDO used is AMS1117-3.3, a perfectly-generic piece of silicon that works just fine as a 5.0v->3.3v converter.

The exposed I/O pins are:

  • 3v3 and GND
  • UART Tx, Rx lines
  • UART DTR and RTS lines, which are needed for ESP8266/ESP32 programming. RTS line is also useful for programming arduino boards.
  • Additional 5v and GND pair

This set of I/O provides a minimal set of features needed to interface with most of projects.

On the newest revision, I added a super-simple current-measurement circuit based on a cheap opamp and some leds. Gives you some feedback on what’s happening on your board.

curremt measurement

How does it work? Assuming maximum draw of 500mA, the voltage drop on R7 is 0.5V, giving AMS1117 a 4.5V on input, eneough to generate stable 3.3V on output.

The voltage drop is then compared with a resistor ladder, by 4-channel opamp.

This is by no means a very accurate method of current measurement - but I tested it, and it seems to be working fine. It’s certainly cheap. I’m keeping it.

A primer on CP2102n

OK, let’s take a look at our options for a USB-UART bridge:

  • CH340x (~0.5$) - the cheapest possible option, seems to work fine, but I’m not sure the drivers for it are included in recent windows revision
  • CP2102n (~1.2$) - comes with some nice features, bulit-in eeprom allows setting some custom parameters (like USB devices’ name), relaiable drivers
  • FT232 (~4$) - the most relaiable but costs an arm and leg
  • bootleg FT232 from aliexpress(?$) - remember FTDIgate? Yeah, nope.
  • STM32F070 series chip (~1.5$) - These are quite cheap and implement USB interface that can act as a VCP (virtual com port) - If you need your USB-UART bridge to be somehow “smart”, these are great option. Be prepared to spend some time on implementing the firmware first, though.

Ok, so I went for the CP2102n option. The chip itself works great, but by default all of the fancy features (like leds blinking on Tx/Rx) are disabled - the chip must be programmed first.

SiLabs prepared an “IDE” just for this - Simplicity Studio. I hate it, properietary peace of crap I couldn’t convince to work under my manjaro linux. I mean, thanks for remembering about linux users, SiLabs, you’re almost there. More CLI, less eclipse.

Luckily I’ve found an open project on github, that implements some of the features needed for this IC configuration.

It has a nice feature of dumping the chip’s whole EEPROM content. I used it, along with cross-referencing with datasheet, and a Simplicity Studio on my Windows gaming rig, to reverse-engineer stuff like enabling Tx/Rx led blinking. It was so much fun, like babby’s first hack.

Have a look: https://github.com/cr1tbit/cp210x-cfg

Also, did some tests with “charging port detection” feature. If you ever feel like it could be useful in your case, don’t bother. I gave it a try, it’s super unrelaiable, sometimes detects a wallplug, sometimes not. When connected to a “smart” host, the deriver tells it to turn off after couple of seconds of inactivity. One solution I’ve found - write your own driver. Sure.

One more thing - the device can enumerate its’ maximum current draw - it’s a feature of USB standard. Regarding this matter, I feel like leaving you with this link: https://www.medo64.com/2016/11/100-ma-is-a-myth/

Usecases for the lichtenprog

Making your devices cheaper

So, let’s imagine you want to make a shitty IoT project with 10s of DIY boards spread across your flat. You want them to be as cheap as possible, yet easily programmable, let’s say, via Arduino IDE.

Deciding to go for an “external programmer” approach means, that you now need just 1 USB-UART IC for N devices.

What’s more, if you plan ahead, you can adjust your end device to be in synergy with your programming board, using a strategy that for me might be the biggest discovery of 2020: the misaligned goldpin holes.

misaligned goldpin holes

Now, one-time programming of your boards is rather simple, and if you require more reaiable connection, you can either solder a female header in, or simply permanently solder it onto one of your prototypes (they’re rather cheap anyways). Now you have the choice.

Barebones power supply for a BLE device

I’m currently working on a bluetooth-based temperature measurement system. It’ll be powered by a coin cell, but for development purposes it’s more useful to have a more sustainable power supply.

The device needed ~3V to work. Well, I had no lab supply on site. So I just took a lichtenprog board, connected it via USB cable to a wallplug and used the 3V3/GND pair only. It worked.

Raspberry pi debug header

I was making a raspberry pi-based smart intercom project (long story) - since I already had my favourite USB-UART board, with a defined, legit pinout, I just added the mentioned before misaligned pinholes so I could debug linux bringup issues and such.

Does anyone have UART bridge to borrow?

Yes I have, like 15.

Conclusion

Being hobbyist electronics designer on the verge of 3rd decade is all about USB-UART bridging. You should never settle for a low quality, generic ones. You’re worth it. I love you.

I planned to sell some kits on 37C3 this year. That went well. I think I’ll put the lichtenprog on tindie or sth., but 1st I want to finish a couple of different projects I actually designed this device for.