TrinketMIDI updated with volume control demo

Just a quick update this time: A long while ago I made a post about using Adafruit Trinket without Arduino and later converted that into a TrinketMIDI Github repository for making a MIDI device with ATtiny:

Now thanks to a contribution by Gerhard Zintel, there is now also a MIDI volume device sample code in the repo. If you want to make a MIDI volume controller, it should be pretty easy with the code as well. Enjoy!

Filco Majestouch-2 TK (MX Blue) with Dolch keycaps

Note: The keyboard and keycaps in this article are bought by me and not a review sample. I have, however worked with KeyboardCo in the past and like them a lot in general. But just so you know!

A new keyboard in the house! Namely the Filco Majestouch-2 TK (MX Blue) Always an exciting happening in the family. After typing happily for a couple of years with superbly compact and slim Apple Magic Keyboard (works fine with Windows btw.) at home, and with my Topre Realforce 88UB at work, I thought it would be fun to get a keyboard with the classic clickly MX blues.

My main reason to get Cherries apart from the amazing blue clicky sound is the fact that one can get a wide selection of custom keycaps, very much unlike the Topre ones where you’re pretty much stuck with the keys they came with, or maybe some with Japanese characters.

After some consultation in Geekhack, I decided that out of the options I had available (in Finland pretty much zero apart from some gaming keyboards), Filco would be a good choice. Knowing they stock it, I headed straight to The Keyboard Company  website and after some deliberation opted for one in Scandinavian layout — easier to swap here in Finland if I want to switch again. The Filcos are in no way inexpensive, but knowing the amount of time I spend typing, I considered the hourly cost to be quite reasonable.

Unboxing Filco Majestouch

The delivery from KeyboardCo arrived promptly as always, and I decided to shoot a classic unboxing video. Notice the great “Code and Life” logo in the thumbnail! There are no audio comments in the video, but you can hear the clickies quite well.

As an “out of the box” experience, here are my major plusses and minuses list:

  • Very solid build, the case will definitely last a lifetime
  • Great MX blue typing experience and satisfying sound
  • Compact layout, it doesn’t expand much outside the keys in any direction
  • It’s a “no frills” workhorse, not much more to be said!
  • Standard keycaps are quite high, making a wrist support pretty much a must
  • There’s nothing particularly exciting or special about they look

Custom Dolch Keycaps: Taking It to Another Level

Now that I got my keyboard, it was time to take step two: Finding proper retro styled keycaps. I wanted to avoid laser engraved ones in order to have the legends around as long as possible. Ideally I would’ve wanted PBT keycaps with very simple, centered legends, but turns out that ISO layout sets with these two attributes are *extremely* hard to find! So I made my peace with getting high quality double-shot ABS caps.

After long time browsing AliExpress and a dozen small suppliers in US (for some reason Europe has a limited vendor selection), plus some group buys, I settled on U.S. quality vendor PimpMyKeyboard and their DSA “Dolch” keyset. I got the red arrow keys and ISO kit as well, for a total of I-don’t-really-want-to-disclose after shipping and EU customs. Let’s just say the caps were more expensive than the keyboard. These baddies are worth their weight in silver.

Here’s a set of images for your drooling pleasure. Note also the nice Filco wooden wrist rest that works nicely and leaves the logo visible (it’s the smallest size I originally got for HHKB2. There’s also dedicated TK option but I just reach for cursor keys occasionally, so I don’t mind the narrower form factor.

As you can see, the keys look quite amazing! I especially like the font on these, and the color scheme reminds me of the old MSX computer my friend’s older brother had in the 80s. The red cursor and escape keys are a nice icing on the cake.

The PimpMyKeyboard caps are decidedly lower profile than the quite high originals, and the function keys even are a bit recessed into their deep settings. I think it’s a nice detail, but some might feel the caps a bit low for this Filco.

Main keys are good height and a pleasure to type on. For some reason, I had issues with the D key getting stuck down on my keyboard. I notified PMKB and they promptly sent me a replacement for no cost (and a fun “sorry!” sticker :), which was excellent service. The new D is a bit better, but it still sometimes gets held down, and I suspect my Filco may have its D switch some fractions of a millimeter off center, causing the issue with keycaps of slightly different dimensions. Nothing a quick swipe of a file won’t fix.

Plusses of PMKB Dolch
  • High quality doubleshot ABS caps
  • Excellent font, very legible and very vintage
  • Pleasant neutral color scheme reminiscent of the 70s and 80s
  • Written labels on special keys is very retro
  • Good selection of additional key kits including ISO, color highlights and gamer options
  • Fast shipping, great customer service
  • Darn expensive, cost more than a keyboard when shipped to Europe
  • High Filco original keycaps mean it’s an A- fit instead of straight A
  • No PBT option


I’ve now logged about five months of continuous use with the Filco Majestouch-2 TK and I can say I like the cherry MX blues well. They have a satisfying feel and sound, and there’s a certain feeling it imparts when you are using the keyboard. In mechanical switch realm I still think the Topre switches have a slight edge, but the difference is small and they lack the oldskool feel so I haven’t bothered hauling my Realforce from work over this time.

Main consideration with the MX blues compared to the browns for example is the sound level. The first four months I had the pleasure to type on my Filco while my wife was temporarily in Cambridge, and I could enjoy the clickies. Now that she’s back, the sound doesn’t probably bother her much (no complaints so far) but I am quite aware whenever I’m typing after midnight. In this regard, my previous Apple Magic Keyboard is more clandestine.

If you are on the lookout for a top notch mechanical keyboard, I can give a high recommendation to the Filco. A further recommendation for the MX blue option if you’re in an environment where the clicks won’t be a problem. And of course you can have another late night coding keyboard, so you get some refreshing variety in your life!

Also, thumbs up for the PMKB Dolch keyset, they are 98 % perfect fit for the Filco! I wanted a retro keyboard, and now I have it, and thanks for excellent build quality and good switches, it’s not just shiny exterior, but a pleasure to hack on as well.

Correcting image white balance with Python PIL and Numpy

I started writing another blog post about my new keyboard today, and when uploading the unboxing video to my YouTube channel, I realized they have no “auto white balance” option, not in their new or old video editor either. Shoot. After googling for free video editors, I settled on OpenShot.

And guess what? OpenShot doesn’t have a white balance setting either! The author himself said this on Reddit, asking for help to implement it. I was pretty shocked, as it seems like the first filter I would implement myself, and thought “surely it doesn’t take more than five minutes to implement one, right?”. So I did. Well, it took maybe 15 minutes, plus 45 fiddling with Jupyter notebooks to get PIL and numpy commands right.

The Python 3 code above basically loads an image (either local if you run it with Jupyter notebook locally, or over network), get a small subportion of it to act as a grey reference, and adjusts color channel balance with two alternate methods: RGB or YCbCr. More advanced versions should be easy to add as well.

You can view the above gist in Github or just copy-paste the code to your own / cloud based notebook to try it out:

If you don’t have access to anything that can run a ipynb file, you can just take a look at the PDF version of a sample run. Enjoy!

Visit to the Official Raspberry Pi Store in Cambridge

Two weeks ago I had the chance to visit the official Raspberry Pi store in Cambridge. Apart from those living in the UK, I think not many will it that far, so I thought to share my pictures from the visit for you to enjoy (and maybe evaluate whether it’s worth the trip). Enjoy!

The Store

The Raspberry Pi Store is located in the Grand Arcade shopping mall, and on the second floor. Looks nice and official.

Naturally, it houses an excellent selection of the Pi boards. There was 3B-, 3A2, Zero, Zero W, Zero W+, compute modules, Pi 4 of course (with different memory options), all with good availability. To cheapest Zero boards were limited to 1 per customer, much like in web store. All boards had a good choice of cases as well on sale. Very nice.

You could also get whole computer kits with a nice raspberry themed keyboard and mouse, as well as a case, an SD card, power delivery (UK plug at least on the display version) and a beginner’s guide. Nice combo, although it of course about doubles the price tag of just the unit itself.

The dual monitor capability of the Pi 4 was very much on display, and there were a couple of machines to try out in the central table area of the store. The machines also had network connection, which was nice for test drive purposes, and not something that even mainstream computer stores have.

And if you want to tout your inner pi’ness, there was of course coffee mugs, notepads and t-shirts available. Would definitely have gotten one if I drank coffee, or had arrived to UK with more than just carry-on luggage!

Cool things with the Pi

Another thing prominently shown at the store were all the projects that you could do with Raspberry Pi. Here is a setup with an ultrasound distance sensor wired to the board.

Apart from trendy slogans and on-display unit, it was more than just a show or a “hands off demo”. The machines usually had a Python editor open with a short piece of code showcasing the actual DIY setup on display, which you could run and try out — or even modify! This is something that many kids or programming newbies will hopefully find exciting and maybe inspire them to try it out themselves.

Here’s another one with a Sense HAT from element 14 on top a Pi unit. It had a nice RGB display with the code to run animations in, so I naturally had to take a shot and made an old-school “random red and green blinking lights” progression that you see happening in front of very old mainframes. Was a bit disheartened I could not get my own invented-on-the-spot random number generator working and had to resort to stanrdard Python RNG. :(

Another with basic GPIO demo with a button, and some leds. The exact setup was naturally available for purchase on the shelves. The “project stands” usually also had a small display telling a bit more about what the setup is doing.

For those with less programming ability or maybe familiarity with the visual programming language used in LEGO robotic projects, there was also a Scratch demo in the store.

The Pi Accessories

In addition to the Pi boards, there was a multitude of exciting components and project kits, including but not limited to robotics, OLED and TFT displays, all kinds of Pi sensor hats, basic electronics kits, and sensors. The pricing was also good, and competitive with web, especially with no shipping fees and zero wait time. I spent probably an hour poring through the shelves and trying to decide what to pick!

Particularly tempting were the colorful Picade units on display, with robust controls and great retro feel. The size and price thankfully saved me from hauling these units back to Finland, but it was not an easy temptation to avoid!

There was also a very interesting mechanical “Turing Tumble” kit on display. It’s basically a mechanical “computer” powered by marbles. You can take a look at their website to learn more. Different mechanisms enable simple logic to be built, and even though the space is too limited to make a 16-bit adder or anything of the like, you’ll certainly have fun grasping the fundamentals!

Pi literature

In addition to coffee mugs, you can see a couple of t-shirts that were also available. There were also good hacker and geek friendly magazines with reasonable pricing, definitely something that you might pick up to spend some time with on the train ride back to London for example.

In addition to magazines, there was an excellent array of Pi and programming related books. Had I not switched solely to ebooks myself (and not having read those “Learn C” books already 25 years ago) I’d definitely left the store weighed down with some quality reading material!

Great selection of Raspberry Pi books catering all topics from computer architecture to projects and kids was superb as well. If you’d want to gift your kid, relative or neighbor (or even a co-worker) some Pi knowledge, you’d be well covered here.

All good things must come to an end

After much deliberation, I finally picked some stuff and headed to the counter. And what a counter! Behind the glass there seems to be every model of the Pi produced, as well as some pure boards and probably a couple of prototype ones as well. A mini-museum in itself!

My official Raspberry Pi Store receipt. Yeah I know: A measly Pi4 case! What was I thinking?! Probably mostly the 25+ boards, sensors, cases and other stuff waiting at home for me to work on — while walking the aisles I realized that apart from the Picade and the robotics units, I pretty much had almost every kind of gadget already purchased. So I settled for something light but officially Pi.

I had a superb visit, and considering the great historical landmarks and good pubs and restaurants, I can warmly recommend a trip to Cambridge and the Grand Arcade Pi Store to anyone visiting UK for more than a day or two.

In addition to housing an excellent selection of all things Pi, the official store gets my respect for representing Pi culture and projects in a very easy to approach and inviting manner. I believe the foundation’s goal to bring children to computing is well served with the store, and hopefully they can open a few more to other cities as well. The concept certainly seems strong enough. Five stars out of five.

Power up your computer wirelessly with Wemos D1 mini

Tired of reaching for that power button? Or perhaps you’d like to be able to turn on your PC when travelling? I sometimes like to do that to access some local files (or software via VNC), but dislike leaving the PC on for days “just in case”. This article explains how you can do it with the $3.50 Wemos D1 mini.

Wake-on-LAN is of course a great idea, but it only works if your PC is physically wired to the router. Wake-on-WLAN theoretically should work for WLAN as well, but here’s a shocking revelation: it usually does not, as it requires your PC to power up your WLAN card for it to receive the magic WLAN packet, and router support. At least I’ve never had a combination of network card and router that would work.

I used to have a nice DIY knock-sensor to PS/2 thingy, but the piezo kept dropping out, and got tired of repeating the required sequence of knocks. So I thought it would be cooler to have just a Bluetooth button I could use to do the same. I had a WLAN enabled Wemos D1 mini board lying around, and it only draws less than 100 mA of power, so I thought to find out if I could make it listen to a “magic packet” and boot up my PC. Turns out it was easier than I even thought!

Note that this project involves opening your PC case and playing around with your motherboard power switch wiring. Everything should be relatively hard to screw up, but if done wrong, you may get electrocuted, you may stick a screwdriver where it shouldn’t go and damage your motherboard or other components, so proceed with your own risk!
Continue reading Power up your computer wirelessly with Wemos D1 mini

Solid Angles of Planets and Which Planet to Use to Build a Dyson Sphere?

Time for something completely different from my usual electronics projects. This morning I started to wonder (don’t ask why) a couple of fundamental questions:

  • If you’d convert the planet Mercury to a huge solar panel, would it cover the sun as viewed from earth?
  • How large portion of sun’s energy you’d get for the project if you started by covering the surface of Mercury with solar panels?
  • Assuming hyper advanced technology that could do this, would Venus or some other planet in our solar system perhaps be a better target?

The thought experiment initiated from some Science podcast, probably from Anatomy of Next scientist interviews (or BBC’s Tomorrow’s World), which talked about turning Mercury into solar panels or mirrors — essentially a Dyson Swarm.

Mercury is close to sun, so it’s a clear candidate, but I started thinking “If you were an alien (or future human race) with super advanced technology arriving to solar system, which planet would you pick?”. You could of course harvest gas giants for Helium-3 and use fusion energy to do stuff, or have some not-yet-invented energy source. But let’s focus on the giant fusion reactor in the center of our solar system, and look at some numbers.

Basic Data for Planets

If we think of sun as a perfect sphere putting out energy in form of solar radiation to pretty much uniformly to all directions, the amount of radiation reaching a certain planet is a simple function of the planet’s radius and it’s distance from sun (π*r^2 / d). Surely you can quickly google which planet gets the most radiation? Turns out most articles on the internet for laymen focus on energy per unit of area (square feet or meters), and leave out the size of the planet completely. Well, easy to fix! Let’s start with some basic data from NASA’s planetary factsheet:

Planet Mass (10^24kg) Diameter (km) Distance from Sun (10^6 km)
Mercury 0.33 4,879 58
Venus 4.87 12,104 108
Earth 5.97 12,756 150
Mars 0.642 6,792 228
Jupiter 1898 142,984 779
Saturn 568 120,536 1,434
Uranus 86.8 51,118 2,873
Neptune 102 49,528 4,495
Pluto 0.0146 2,370 5,906

How Big Do Planets Look From The Sun?

Now as all planets are really far away from the sun compared to their radius and diameter, I’m just doing a shortcut and calculating their angle from sun as just the ratio of diameter and distance, owing to the fact that sin(x) ≈ x for very small values of x (second coefficient of Taylor series expansion is x^3/9 so with these numbers we’ll get about 20 significant digits correct). Calculating diameter/distance shows that even the largest planet from the sun, Jupiter, is just 184 microradians, that is 0.000184 radians wide when viewed from the sun! Full sky would be 3.14 radians, so there’s some way to go!
Continue reading Solid Angles of Planets and Which Planet to Use to Build a Dyson Sphere?

DIY Bluetooth Keyboard Breakout for $10

You could get an excellent Bluetooth keyboard controller from Adafruit called Bluefruit EZ-Key which allowed super easy creation of projects that sent keyboard presses (for example a gamepad) just by connecting some switches to the pins. However, the EZ-Key cost $20 and is now discontinued. And in any case, Bluetooth-capable devboards are now available from AliExpress for a few dollars, so $20 today feels on the steep side. “Could it be done cheaper?” I wondered…

I have honestly about a dozen cheap wireless devboards lying around, many based on ESP8266 which only have Wi-Fi, but some also with ESP32 which includes Bluetooth. I spent some time trying to configure a Chinese ZS-040 serial Bluetooth module to function as a keyboard, but the AT command set was a very small subset of what the similar HC-05 / HC-06 modules have. After an evening of trying, I decided to give up on that. There are instructions how to flash HC-05 modules with RN-42 firmware to get Bluetooth HID capability, but it will require quite a few steps.

I also took a look at esp32_mouse_keyboard project, but for some reason or another, abandoned that avenue. Don’t recall if there were obstacles or the project was still incomplete a year ago, might also be that the ESP32 only had BT LE which technically didn’t support HID (Human Interface Device). Throw me a comment if you have that working!

Meanwhile, another idea dawned to me:

A Cheap Bluetooth Keyboard Must Contain A Bluetooth Module

Enter the wonders of AliExpress: While you cannot source an easy BT keyboard module from US under $20, you can get a full mini Bluetooth keyboard for $9.50 (at time of writing) including postage! This package ought to contain:

  • A fully compliant Bluetooth board that pairs with iOS, Android and PC devices
  • Full functioning keyboard and case
  • Presumably, a battery and a way to charge it

Sounds a too good deal to be true? Well, let’s find out! The keyboard has a solid metal backplate that is easily screwed open with micro cross head screwdriver. Once inside, it reveals a very professional layout with a flat ribbon cable (or “FCC cable”) coming from the mechanical part into the controller module, And a small (most likely LiPo) battery.

Taking the tape off and turning the board around reveals a bit spacious, but very professional looking PCB with clear markings. There are easily usable on/off switch and connect button on the PCB, a connector for the keyboard switches, and obviously some kind of microcontroller wired to the connector, as well as another smaller chip that is most likely a voltage regulator or charging chip.

I Googled around to find out if the “YC1026” MCU would have a datasheet to help me along the way, but unfortunately I only got Chinese web pages (most likely the manufacturer) without any documentation. Time to dig out my trusty Picotech 2000 scope and do some old-fashioned reverse engineering!
Continue reading DIY Bluetooth Keyboard Breakout for $10

$8 Bluetooth automation button for Raspberry Pi Zero W

This project was born as a sidetrack of another one (I’m planning on building a $10 DIY Bluetooth page turning pedal for my piano and iPad sheet music app, similar to PageFlip Butterfly). I was looking if AliExpress would have bluetooth pedals, which they don’t — it seems Chinese vendors are REALLY good at copying products but there is little new product innovation combining something as simple as a bluetooth keyboard sending one or two keys with a pedal (two items that they do have)! But while searching, I found this inexpensive gadget (in case the product is removed, you might just search for “bluetooth remote” at

So what is it? It’s an $8 disc with multimedia buttons that pairs with your smartphone and you can use it for example in car to control your music. But maybe it would pair with my Raspberry Pi W which has integrated bluetooth as well? Well it costs about nothing to find out!

Fast forward about two weeks and it arrived. I did not try to use it for its intended purpose, but instead went straight to pair it with my Raspberry Pi Zero W. Turns out the pairing process was quite painless, you can follow for example LifeHacker’s tutorial for pairing quite easily. And it goes a little something like this (your MAC address might vary, just look for output after “scan on”):

# bluetoothctl
power on
agent on
scan on
connect FF:FF:00:45:8D:FF
trust FF:FF:00:45:8D:FF

Continue reading $8 Bluetooth automation button for Raspberry Pi Zero W

Hands-on review of IKALOGIC SQ200

Most electronics DIY projects I’ve worked in the past have involved digital communication protocols such as USB, UART or PS/2. Sometimes when first twiddling with a new protocols, everything works nicely. Other times, things don’t quite work the way they should. In the latter case, a logic analyzer is an invaluable tool, essentially a multi-channel logger of digital signals, which you can use to hopefully pinpoint where things are not going as they should. Nowadays most of these are connected to PC, so you can capture a piece of communications between two devices, and analyze what is happening with a dedicated software.

I started my logic analysis with the inexpensive Bus Pirate, but after a while also got Saleae Logic unit I used to view the PS/2 traffic in my knock sensor project. Later on, I have gotten the PicoScope 2208B which has both analog oscilloscope functionality, as well as digital logic analysis capabilities.

So when I was contacted by IKALOGIC, the makers of ScanaQuad series of logic analyzers, who offered to send me a unit to try out in return for a review, I though I was in a good position to give it a spin and also have previous experience to compare it against. I also had a project in mind to test drive the SQ200 unit I got: my recent MIDI-USB adapter, which is a combination of slow 32 KHz serial signals, and quite fast USB signalling.

Note: I received the review unit from Ikalogic without cost, but with freedom to form my own opinion about the device. I’m giving praise where it’s due, but not pulling any punches where something will nag me or compare unfavorably against the devices I’ve had first-hand experience in the past!

Unboxing the ScanaQuad SQ200

The unit arrived well packaged, and inside the plastic wrapping I uncovered a matte black cardboard box with the unit name. A grade above no-name Chinese vendors, but of course not an iPhone “unwrapping ceremony” kind of thing either. Inside, there was the unit, USB cord and logic probes neatly packed (click for larger images).

There’s nothing complicated in taking the unit into use: Just attach the USB cable, the probes, and you’re set. Build quality of the unit is very good, with grey matte surface with nice finishing, four screws and a product spec sticker on the backside, and logo, markings and a power/activity LED on top.

Size-wise, the SQ200 is slightly larger than the very compact Logic unit I have from Saleae (it’s an old model, don’t recall the exact model code), which I rate as the gold standard in product casing, with Apple-esque metal feel (aluminum?) and solid construction. The Saleae unit actually has 8 channels despite it’s smaller size. On the comparison image you can also see PicoScope 2208B with 16-channel MSO capability. Compared to that, both IKALOGIC and Saleae units are quity tiny (still, the palm-sized 2208B is extremely compact as well, given the 2 high frequency analog channels and waveform generator).

Continue reading Hands-on review of IKALOGIC SQ200

$5 USB MIDI adapter with ATmega32u4

This article will detail how to build a USB MIDI adapter (one-directional: you connect the adapter with USB cable to your computer, and it receives notes and pedal data from your keyboard’s MIDI OUT and transmits them to your computer) with ATmega32u4, 6N137 optocoupler, a few resistors and spare MIDI connector or cable. Read on for details!


Last year I wrote how you can turn Teensy LC into an inexpensive USB MIDI adapter. I used it to replace a non-working Chinese MIDI-USB adapter that did not send controller messages (i.e. piano pedal) properly to PC.

However, since the Teensy still costs $12, and you have to get some additional components, it doesn’t make sense to use it in a dedicated MIDI adapter, since you can get a working USB MIDI adapter for around $15 from Thomann and probably many other places.

But how about other boards? After making my Teensy LC adapter, I actually tinkered with Adafruit Pro Trinket, and got that working as well (the standard Trinket does not have hardware UART so V-USB and software UART is somewhat risky). But there is even a better board for this: The ATmega32u4 board I previously showed how it can be made into USB HID mouse. Let’s see how to turn it into a USB MIDI adapter!

Required hardware

To build this, you will need roughly $5.40 worth of components:

  • SparkFun Pro Micro (clones with ATmega32u4 can be had for $3.50 from AliExpress, eBay, etc.)
  • 6N137 optocoupler, which can be had for ~$0.30 a piece (I suggest sourcing a couple in case you burn one by accident)
  • 330 ohm and 2 kohm resistors ($0.10) and 1N4148 diode if you want to be safe
  • MIDI connector or alternatively you can just cut a short cheap MIDI cable and wire it to your project, let’s say $1.50

Continue reading $5 USB MIDI adapter with ATmega32u4