Blue Chord Keyboard now in Hackspace Magazine

If you use both left handed and right handed keyboards at the same time you can channel your inner Rick Wakeman….

Issue 68 of HackSpace magazine is now out. On page 70 you can find my article that tells you how to create a Bluetooth connected chord keyboard using a PICO-W. There are lots of other great articles too. Well worth a read.

Bluetooth Chord Keyboard

Now avaialble for left and right handed users with adjustable key positions

The Raspberry Pi PICO-W powered Bluetooth Chord keyboard (I call it “Blue Chords”) is now on GitHub. You can find it here. I’ve updated the code to use the latest version of the Raspberry PI PICO SDK and updated the PC design and matching case design.

I used the Kicadstepup plugin to import the board into the design

I’ve built some prototypes (you can see them at the top) but I’ve not built the final design yet. The project will be the basis of an article in an upcoming HackSpace magazine.

Lovely OLED driver for the PICO

It can say other words as well…..

I spent a chunk of the day trying to get the OLED display working on the keyboard I’m building. It works fine under Python, but it was a bit reluctant to work under C++. In the end I found this lovely OLED library: https://github.com/daschr/pico-ssd1306 It's very lightweight and easy to configure and use. It worked a treat. The display that I’m using is the monochrome version and it looks really, really good.

Achievement unlocked: First PCB built

The bag was very hard to undo, but worth it

A parcel arrived from PCBWay today. These are the boards that I designed last week. They turned them round in double quick time and they look great.

These are the key positions for right handed use

I lost no time soldering the key sockets into place and getting a test program into the PICO. I have made a few mistakes with this board. The key spacing is a tiny bit close. I had to file a bit off a couple of keytops to make them move smoothly. The next version will have the keys a mm or so further apart.

It is traditional that your first board needs a fix or two….

I’d also made a mistake with one of the OLD display sockets, reversing the clock and data lines. But I managed to fix that and get the board going with some Python code. The good news is that the left handed versions is wired perfectly. I’m going to build one of those too just to see if it is easy to learn to use the keyboard with your left hand. Now I have to write the C++ code to read the keys and send the keypresses over Bluetooth.

Achievement unlocked: designed KiCad circuit board

I’m rather proud of this. Please don’t find a fault in it…

I’ve finished my design for the chord keyboard. There are lots of key locations but you only put one switch in each column. This makes it easy to make left or right handed versions. I’ve added connections for a tiny OLED screen. You fit the display the the side that you are not using.

Next thing to do is to send it off to get some boards made. Rather exciting.

PICO Examples vs OneDrive - Fight!

Size comparison with an SD card. Remember them?

I’m doing some work on the Raspberry Pi PICO. To make things easier I bought a debug probe. It’s tiny. It comes with all the cables that you need for your PICO, but you do need to solder three pins onto your PICO device to connect it up. That is, unless you get the much sought-after “H” versions of the PICO which come with pre-soldered pins and a tiny socket that connects directly using the cable provided with the kit.

It works a treat. Rob’s pro-tip: read the instructions very carefully and do all the steps, otherwise getting it working takes twice as long.

I installed the PICO SDK using a script you can find here. The script works fine, but by default it installs the examples into one of your document folders (or at least it did for me). I use OneDrive for file synchronisation and the next thing that happend (at least on my machine) is that OneDrive went nuts and started uploading thousands of tiny files into the cloud. I don’t remember seeing an option to install the examples somewhere else when I ran the script, but if you do the install I’d strongly recommend you look for it and put the examples somewhere in a folder which is not being synced with the cloud.

Heading to Driffield

David asked me if I fancied giving a talk to some sixth formers at Driffield. A chance to perform in front of an interested audience? Count me in. I took along a few toys, the trombone controller and my cut-price laptop. Much fun was had. The students were great. Lots of lovely questions (although one person did ask how tall I am - and after I had specifically told them not to do that). Kids eh?

I love telling the tale of embedded development. This is the best time ever to be doing it. Making stuff has never been so easy, so cheap, and so useful for building up your personal brand. I’m looking forward to going back some time in the future to see what they have been making.

David had brought in some trombones for me to look at, including the super shiny one above. It was nice to be able to compare the action of my sensor with something real.

Breath detecting with an environmental sensor

Turns you can do it. I’ve been wondering how I can detect people blowing into a trombone. As you do. A microphone is one possibility, but that involves analogue to digital conversion and sound processing and stuff. And owning a suitable microphone. I do however have a bunch of BMP20 environmental sensors. These contain an air pressure detector. They are supposed to be used for weather data and determining your height above sea level. Would it work for breath?

The answer is yes. If you put a sensor in a closed box (see above) and then blow into the box you can make a detectable difference to the pressure inside. All you have to do is sample the air pressure at the start and then look for a change of around 5 or so during gameplay.

It worked really well for a while. Then the BMP280 stopped working. I had a look in the box and discovered why. It was rather disgusting. Breathing into a box produces not just air, but a lot of water vapour too. The inside of the box and the sensor itself was covered in what you could politely call “dew” but was actually something slightly different. Trombones have a “spit valve” on one end to release all the stuff that accumulates. I’m happy to have proved the principle. I guess I could engineer some baffles or a waterproof membrane over the sensor to keep it dry, but the thought has occurred that in these virus laden times, passing around some thing that you take in turns to breath into might not be a great idea.

So I’m building a version of the controller that uses buttons rather than breathing.

Add graphs to your IoT projects

I’m building a trombone controller. And why not? I’m using a distance sensor to track the position of the trombone slide. The output is a bit noisy. But how noisy? A graph would help, but how do I get that? Very easily as it turns out. I just added a print statement to my Circuit Python application:

print(raw,",",average)

This prints out my raw and averaged values with a comma between them. Then I used Thonny to run the program in the trombone for a while and moved the slider. Then I stopped the program, copied the output of the terminal window into notepad and saved it with the file extension “.csv”. (Comma separated values).

Then I opened the file with Excel (other spreadsheets are available) and made the above graph. It shows how my rolling average (the red trace) cleans up a lot of noise but makes the values lag slightly (look at the how the red trace rises slightly after the blue one).

If you aren’t sure what your signals look like this is a very easy way to do it. The Arduino IDE has a graphing feature built in that I’ve used once or twice, but there’s nothing like dropping your values into a proper spreadsheet for analysis. And it is very easy to do using the magic of cut and paste.

Rob at Dot Net North

I’m back on the road again. Dot Net North have kindly invited me to be the speaker at their first in-person event since the pandemic kicked off. Really looking forward to the event. I’m going to be talking about making music with hardware. There will be devices you can build, devices you can marvel at and hopefully devices that work in front of an audience.

The event is in Manchester on the evening of Tuesday 20th September. You can sign up here.

Got my PICO W

My PICO W devices arrived today. They look really nice. I’ve soldered a bunch of pins onto one of them and plugged it into my PICO Display Pack with the intention of making a tiny wireless message board. Unfortunately the Pimoroni image with the drivers for the display on it doesn’t support WiFi just yet. I’ve tried using this library with the WiFi enabled Micro Python firmware but I can’t get it to work. With a bit of luck Pimoroni will catch up soon and I can make something that displays a message each time I make a new blog post….

Raspberry Pi PICO W brings Bluetooth and WiFi to the PICO

The shiny box is the wireless antenna

The Raspberry Pi PICO is an awesome device. Super cheap, super easy to program and super easy to connect to stuff. The only thing about it that I didn’t like about it was the lack of any wireless connectivity. That’s changed now, with the launch of the PICO W. This adds a Infineon CYW43439 wireless chip to the PICO which brings Bluetooth and WiFi connectivity. The new PICO W is physically compatible with the old one. The pins are pretty much the same, although three of them (ones you don’t use much) are now accessed slightly differently.

At the moment there are no drivers for Bluetooth and you can only use the WiFi from Micro Python programs (not C++ or Circuit Python). But I expect that to change pretty quickly once folks get to grip with the device.

There’s a really good description of the new PICO W plus sample code in this month’s MagPi magazine which you can find here.

Linking a Raspberry Pi 4 and a PICO over a serial connection

I want the Pure Data patches in my Chocolate Synthbox to be able to display lights that flash in time with the music. The lights in question are a bunch of neopixels connected to a Raspberry Pi PICO which is handing all the inputs and outputs for the device. I’ve done this to keep the design simpler and to remove any chance of issues with the sound code on the Pi interfering with the pixel animations.

However, to make it work I have to connect the Pi and the PICO together. Both devices have plenty of serial ports, so the best way is just to use one of those.

On the Raspberry Pi 4 (note that this only works for the 4) there are four serial ports which are surfaced on the “hat” connector. You have to enable them and they surface as devices you can use.

You enable them by editing the /boot/config.txt file:

sudo nano /boot/config.txt

Then, if you want to enable serial port 2 (which I do) add the following line at the end of the file:

dtoverlay=uart2

Save the file and then restart the Pi. You can now ask it which pins it uses with the command

dtoverlay -h uart2

The important part of this information is the “uart 2 on GPIOS 0-3. This means that the pins will be assigned as follows:

Pin 27 GPIO0 UART2 TX
Pin 28 GPIO1 UART2 RX

The other two pins (GPIO2 and GPIO2) can be used for hardware handshaking, but I’ve not enabled that. The device will appear as /dev/ttyAMA1, I’m going to use it in Pure Data (but that’s a different blog post. For this one, let’s discover how to connect the port to a PICO. I’ve decided to use uart1 in the PICO. This can be used on pins GP8 (TX) and GP9 (RX). So the wiring I need is:

Raspberry PI         PICO
Pin 38 GND           Pin 13 GND
Pin 27 GP0 UART TX   Pin 12 GP9 UART1 RX
Pin 28 GP1 UART RX   Pin 11 GP8 UART1 TX

Note that the TX and RX are crossed over. The PIC is running Circuit Python, this is how to connect a program to this port:

serial_port = busio.UART(board.GP8, board.GP9, baudrate=19200,receiver_buffer_size=500)

Now if the Circuit Python program in the PICO sends data to this port it can be picked up in the PI.

PICO Squashing

I like making things slim and low profile. Yesterday I discovered that I’d overdone this, when it turned out that I couldn’t fit the lid onto a box I’d just spent five hours printing. There were two ways to fix this. One way would be to spend a while finding the right-angled header pins, solder them into a new PICO and then spend another while transferring all the wires from one device to another. The other way would be to just bend all the pins flat on the existing device. Guess which I did? 'm not proud of this solution. But I'm very proud that it works.

Improving user interfaces

I’ve been using my PICO Pomodoro timer and I’ve decided that the user interface is rubbish. When I designed the system I thought it would be cool to use the control knob as an input button. That way you can turn the knob to set a value and then press it in to make a selection. Clever eh?

Actually no. Why? Because when a user sees something with a button on it the first thing they will do is press the button. They will expect the button to do things. When it doesn’t do anything they turn the knob. But the user has to know that the knob can be pressed in to make a selection. If they don’t have that crucial fact the whole device is useless to them.

I’ve upgraded the code to version 2.0. This lets you press the button or the knob to make a selection. If you press the button when the time is set to 0 the device now shows a message saying “turn the knob to select a time”. The device still works like it used to, but now it is much easier to get started with it.

In my experience this is how user interface design goes. Things that you think are intuitive frequently aren’t. If I’d shown this to someone before I shipped it they’d have come straight back with the obvious question “Why doesn’t the button do anything?” and I could have fixed it. So the lesson is to show what you’ve made to other people as much as you can.

Update: The original title for this post was “Stupid user interface design by Rob”. After some thought I’ve changed this title and edited this post to remove the word “stupid”. I try not to call people stupid. So I shouldn’t call myself stupid either.

Upgrade your Circuit Python version in the Raspberry PI PICO

My first version of the PICO MIDI Cheesebox used Circuit Python 6. And it worked fine. But I thought I’d upgrade to version 7. This turned out to be harder than I anticipated because of my less than stellar hardware design. The Raspberry PI PICO that I use to control the CheeseBox is locked inside the case with no access to the all-important BOOTSEL button that you hold down during power on to force the device into firmware upload mode.

However, the good news is that you can use a couple of Python statements to get your PICO to reboot into firmware mode so that you can drop in a new version of Circuit Python (or anything else). You can issue the commands down the terminal connection. I used the Thonny program which provides a REPL connection to my Circuit Python powered CheeseBox (or Crackers Controller).

microcontroller.on_next_reset(microcontroller.RunMode.UF2)

This is the first command you type in. It tells your device to reset into UF2 mode next time it is reset.

microcontroller.reset()

This is the second command. It resets the device and makes it appear as as storage device into which you can load the firmware. Note that if you do this you will wipe the contents of your PICO so make sure that you copy anything important off it first.

I’ve upgraded the firmware for the CheeseBox on GitHub to Version 7. You can find it here:

https://github.com/CrazyRobMiles/PICO-MIDI-Cheesebox