Whitterm-220 2.0

June 30, 2019

Having used my clever serial terminal – the WT-220 – for a few years now, I’d identified improvements I wanted to make. I was never that pleased with the cobbled together electronics (based on what I had laying around and ability at the time) and with PCB fabrication accessible to hobbyists now thanks to China, I decided the main win would be a Raspberry Pi Hat.

The rear panel wiring made opening the thing up a dread, so this was the main item I wanted to fix. Thinking about how to simplify the connection between the Hat and the RPi, I came around to the idea of ditching the acrylic rear panel entirely in favour of PCB mount upright connectors – the PCB would be electronically and mechanically part of the design.

As with all good hobby projects, I got quite carried away with adding bells and whistles but the rear panel functionality and resulting WT-220 has been greatly improved overall. It was a nice slow burner project to fill time gaps moving to Switzerland at the start of the year. I enjoy these sorts of projects, cementing knowledge I’ve developed in professional work and exploring ideas one doesn’t always have time for.

WT-220 Rear Panel IO Hat


  • USB-C input for USB-PD high current (3 A) supply to RPi. LEDs indicate detected current profile from UFP. I2C lines made available to SAMD for playing with USB-C device modes.
  • MAX3232 RS232 transceiver provides RS232 level interface to RPi UART and SAMD UART.
  • SAMD21 microcontroller provides boot button control of RPi over I2C and buffered IO (2 0-10 V inputs, 2 OC outputs, 2 24 V inputs and 1 0-5 V output). Can be programmed over USB-C CDC-serial device or ISP.
  • Control of RPi power supply from SAMD. Off by default allows safe start up, only when power input suitable/ready.
  • DIP switch control of device UART connections (SAMD, RPi, RS232).
  • Board replaces laser cut acrylic back piece from original design – it is both electronically and mechanically integrated.
  • Lots of status LEDs 😃.


The original WT-220 with DC jack input going to buck-converter for 5 V wasn’t ideal. It was always frustrating attempting to find the right jack, the jack coming loose or if using Micro B USB, finding an adaptor to supply the > 2.5 A required by a RPi 3 B+ & screen – the worse thing was that if the supply was flaker, it might power up then brown out during use.

I had been wanting to implement a USB-C board in order to understand the interface, so this became the project. The great thing about USB-C is that the upstream device can provide information on the power available to the downstream device. By configuring the CC lines, one can set or detect what current is available and act on this. I opted to use a controller – the TUSB320 – to handle this, with LED indication of current mode detected.

Using the GPIO mode of the TUSB320 and LEDs, one can visually show the USB-C current mode. Here both LEDs indicate full 5 V/3 A. This could be read over I2C and the boot button restricted if power to low.

With the SAMD controlling the power supply to the Pi via a MOSFET swtich and I2C connection to the TUSB320, one can prevent boot up of the Pi until a suitable upstream supply is detected. For something like the WT-220, the LED indication is enough as I’m the only one using it. For a user consumer product however, this is great as it removes the ability to plug in any old phone charger and then the device appearing to not work properly.

Turns out I wasn’t the only one thinking down this path. Since developing this board and in the process of writing this post, the Raspberry Pi 4 has been released with a USB-C port replacing the Micro B. I’m not sure if the new Pi uses current mode detection to prevent start up like suggested above but it would be logical.


The SAMD firmware is pretty simple. As said, it controls the power to the Pi and then an I2C communication between the SAMD and Pi allows LED boot status and shutdown/power off control. See below for a basic (messy) state diagram.

Raspberry Pi maintains I2C link with uC once booted and acts on shutdown request from button press. The LED flashing routines were the most complex part of the firmware development!

The other thing the firmware does is provide interface to the buffered IO.

Raspberry Pi

I opted for Raspbian Lite rather than Arch for this updated build. The support for ARM 64 bit is better and the Lite variant still means I could install only what I wanted.

For the install, I used I3WM since it’s a keyboard based terminal. I then compiled and installed cool-retro-term for the CRT look.

The rest of the image is fairly standard, bar a few services I created and config scripts (all can be found in repo:

  • boot: Runs shell script that displays boot ascii logo.
  • i2c: Runs python I2C script (wt220-i2c.py) that configures case LEDs to act on RX/TX and then maintains link with I2C link with SAMD. Polls shutdown request state and acts on request by issuing system shutdown.
  • poweroff: Runs on shutdown.target and issues the final I2C shutdown command so that SAMD disables RPi 5 V.