Whitterm-220 2.0

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

Features

  • 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 😃.

USB-C

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.

Firmware

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.

state-mermaid
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.

Boblight Web GUI Control RaspBMC

Boblight GUI Control

Since setting up an boblight on my RaspBMC, I’ve been wanting a nice gui to manage it; turn it on and off, change colours.

I was going to make a plugin to improve my Python knowledge but decided a web plugin would be more flexible as it would be controllable from any device. Using Chris Oattes’ TV Control page as base, I moulded the PHP to be compatible with the standard RaspBMC setup, which currently uses the boblight-dispmanx service. The standard XBMC web server doesn’t support PHP and I couldn’t figure a way of getting it to, so my solution requires setup of another lightweight webserver: lighttpd:

You’ll get an error as lighttpd will try to assign to the default web port 80 but libmicrohttpd will already be running on that. You could disable it but I use for remote control. Instead change the default port to something else, I use 3000:

Change server.port = 80 to 3000. Then sudo service lighttpd force-reload

Set the permissions for the server folder:

Now all that is left is to copy my boblight control page to the /var/www directory:

Visit http://[your raspbmc ip]:3000/boblight to set any static LED colour, disable the dynamic lights or turn off the lights all together. I plan on adding function to edit the boblight.conf settings and implementing some more visual effects.

Boblight with Raspbmc – Ambilight Clone

When I first started seeing the Ambilight (Philips’s lighting system that allows the display to bleed out) clones popping up I knew I wanted to create one myself. The open-source system has been fairly well refined to this point, such that it is pretty much plug and play with Raspbmc (XBMC for the Raspberry Pi). ‘nadnerb’ has already created a tutorial for the process, which I followed, so I won’t go into the process here. This post is just to share my results.

Testing before install to avoid any aggravation!
Testing before install to avoid any aggravation!
I opted for some old trunking to hold the LEDs, held using hot glue. The trunking is stuck using double-sided duck tape.
I opted for some old trunking to hold the LEDs, held using hot glue. The trunking is stuck using double-sided duck tape.

AirPi: DIY Airplay Speakers using Shairport and a Raspberry Pi Updated

My last AirPi post has been popular – and still is – but part of why of like Arch linux is that it is constantly updating so you must be hands on, learning a new part of the OS the hard way!

Since my post a year ago, Shairport has some new features and dependencies, and Arch has moved to the systemd service manager, changing the tutorial process somewhat. In order to update it, I have run through the process with the current build (2013-02-11).

Continue reading AirPi: DIY Airplay Speakers using Shairport and a Raspberry Pi Updated

Setting Up a USB WiFi Dongle on Raspberry Pi Arch

For my AirPi, I needed to make my Raspberry Pi wireless. Being the man of thrift that I am, I found the cheapest dongle on eBay: a (Digitaz) RaLink RT5370.

Now Arch isn’t exactly plug and play, but that’s part of the fun. Plugging it in, the only way you’ll know it is there is using:
Continue reading Setting Up a USB WiFi Dongle on Raspberry Pi Arch

AirPi: DIY Airplay Speakers using Shairport and a Raspberry Pi

We have speakers in all the ground floor rooms of our house, all driven from the same amp. It’s neat but controlling the input requires going back to the amp.

Surrounded by iDevices too and with apps like iPlayer, Spotify and home share on iTunes, being able to throw audio to the speaker system had to be done. Que Airplay, however, this requires a nice Airplay amp or getting an AirPort. I then found out about Shairport, a program that emulates an AirPort’s Airplay function. With a Raspberry Pi kicking around, I had just found its new job.
Continue reading AirPi: DIY Airplay Speakers using Shairport and a Raspberry Pi