Category Archives: Hardware

Low-cost 8 channel MIDI controller

In one of the recent presentations with Per Hüttner we used TouchDesigner for live visuals. The gradual transitions between scenes were implemented using (invisible) sliders in TouchDesigner. However, making a full and smooth transition just having the MacBook touchpad to slide from one to the other side on screen was not so comfortable. Hardware-based MIDI controllers would have much better tactile feedback, like the Novation LaunchControlXL, the Midi Fighter Twister and the Intech controllers. Looking for more affordable options, we found a nicely looking ParksTool 8P on Etsy.

This triggered me to look into DIY options, and I found the M5Stack 8Angle interface, which consists of 8 knobs that connect over a Grove I2C connection to a microcontroller. I ordered the 8Angle interface online for only €15.00 and a matching M5NanoC6 microcontroller for €8.00 which I used to construct a simple 8-potentiometer MIDI interface.

M5NanoC6 microcontroller connected with a 4-wire grove cable to an 8Angle potentiometer controller

MIDI controller based on M5NanoC6+8Angle

The USB interface of the ESP32-C6 does not (yet) allow to do MIDI over USB, but the Control Surface library for Arduino does support MIDI over Bluetooth for the ESP32-C6. To connect it to your macOS computer, you have to start the “Audio MIDI Setup” application.

In the upper right corner you have to click on the Bluetooth symbol to initiate a connection.

The M5NanoC6 shows up as “Control Surface MIDI” and you can connect.

Subsequently it shows in the main panel of the Audio MIDI Setup panel as a Bluetooth device.

Using the excellent MIDI monitor application you can check that the MIDI signals are arriving, and you can assign them to the controls in TouchDesigner or in Ableton Live.

In my Arduino firmware I mapped the 8 knobs of the controller onto Control Change (CC) messages 0 to 7. The small switch on the controller allows switching between MIDI channel 1 and 2. The individual RGB LEDs on the controller change color along with the respective MIDI values.

Hydrophones

With the EEGsynth we are not only working with EEG data but occasionally also with data from trees, from microbes and from cod fish. For the cod fish project we collaborated with Rebekah Oomen and John Andrew Wilhite-Hannisdal on the sounds that cod make during the mating season, using recordings of the “grunting” and “drumming” that were made in previous years at Flødevigen Research Station.

For the Science Festival in Gothenburg we are considering to take it one step further and integrate live video and possibly also sounds from the cod fish that are swimming in the large basin in the Sjöfartsmuseet Akvariet. Recording the sounds to use them live requires hydrophones, i.e., underwater microphones. Commercial hydrophones that are commonly used for marine research purposes are rather expensive, but luckily it is not too difficult to make a hydrophone yourself from a piezo element. I largely followed the process described by Felix Blume. Below I will detail some specific considerations, design steps, and modifications that I made to the original.

I ordered a bunch of 27 mm diameter piezo elements from Amazon. Since I did not have nicely fitting bottle caps, I designed a small round housing that exactly fits the piezo elements. I used my Prusa to 3D-print the housing in PLA, a bioplastic made from corn starch. Copper tape on the inside helps to prevent pick-up from electromagnetic interference. I found out experimentally that the copper tape needs to have a good connection to the copper of the piezo element so that they together form a Faraday cage, otherwise there was still a lot of 50Hz hum.

I ordered two instrument cables of 9 meter each (one red, one blue) and cut them into a 3 meter and a 6 meter section. The stripped cables were then soldered to the Piezo elements.

To ensure that the hydrophones will properly sink, I placed two nuts in the housing and completely filled it with silicone gel. As the hydrophones are to be used in an aquarium, I bought special Seachem silicone sealant in the local tropical aquarium fish store.

I had planned to use a coat of Plasti Dip Multi-Purpose Rubber Coating according to the instruction, but a review of the safety sheet revealed that Plastidip is made from petrol derivates and contains substances that pose a safety hazard to water and marine life. I don’t know whether that is in the solvents which evaporate during the drying process, or also with the remaining solid coating itself. Given the intended use in an aquarium with a closed water recycling system, I don’t want to take a risk and decided to keep the hydrophones bare with the PLA bioplastic and the copper of the piezo element exposed.

With the four hydrophones we will be able to do a four-channel recording of the sound that we record inside the fish tank and play it back spatially on a quadrophonic speaker array.

IR blaster remote control

Previously I wrote how I designed and implemented a 12 Volt trigger for an NAD D-3020 audio amplifier and on the PCB version to automatically switch the amplifier on and off. In response to those posts I occasionally receive comments asking why I am not using an IR remote control instead of the 12V trigger input. The advantage of IR is that it also allows switching to the corresponding input, and allows to control other devices as well.

A lot of the available IR blasters come with some form of cloud-based integration such as Amazon Alexa, Apple Siri, Google Assistant or Tuya. I am not a big fan of those and prefer to implement my home automation without big tech looking along. Tasmota is a great platform for that; it implements a firmware that can be combined with all sorts of sensors, switches and actuators based on the ESP8266 or ESP32 modules. In the past low-cost IR blasters based on Tuya would have an ESP8266 module and could be flashed with Tasmota, but nowadays many Tuya devices use another non-compatible wifi module.

There are also ready-made ESP8285 IR blaster modules, which are very cheap on Amazon or Aliexpress. I decided to implement my own and learn a bit more along the way. I ordered 6 of these IR LEDs and this HX1838 IR receiver. After an initial design and test on a breadboard, I implemented it as a shield for a Wemos D1 mini.

While translating the initial working design from the protoboard to the perfboard, I initially made the error to use pin D3 for “IRsend” and D8 for “IRrecv”. This would not work for both, seemingly because of their special functions and/or internal pull-up or pull-down resistors of the ESP8266. This page has a lot of details and here is a clear list that orders the best input and the best output pins to use. I switched “IRsend” and “IRrecv” to the neighboring pins D2 and D7, after which it worked fine again.

Note that the old Wemos that I still had lying around is a cheap clone with the micro-USB connector on the opposite side as the ESP12F module. Modern ones have the ESP chip directly mounted on the PCB rather than in the form of an ESP12 module with a metal cap, making the whole design more compact. Due to the way I soldered the stacking pin headers, the pinouts on the board are left-right mirrored compared to what I would consider the normal orientation.

This shows the top and bottom of the IR shield:

The photo below shows the IR blaster mounted underneath the corner of our couch, using a paperclip and some safety pins. The couch is about 3 meter distance from the TV and audio setup.

Unicorns are multiplying

This page is part on a series on the Unicorn EEG system, see also the other posts on the design of the alternative case and wet “sponge” electrodes, and on the native Python interface for Linux and macOS.

Following the design and implementation of the 3D printed case for the Unicorn EEG system, I have had some chance to evaluate it and make some design modifications. The most important is that rather than using the 5×2 shrouded male header ( or “box header”) that needs to be soldered to the 10 tiny wires, I switched to an insulation displacement connector (IDC) version that is clamped on the wires. I still need to squeeze each of the individual wires between the teeth (using pointy squeezers), but that already makes the fabrication much easier. The connectors I used are these, which are similar to these but with “ears” that nicely slot in the sides of the 3D printed enclosure, which also means that no glue is needed any more.

I made 4 so far for various projects and collaborators, all using the standard 5×2 male headers.

Recently we did a demonstration at the Tekniska Museum in Stockholm where visitors could try the EEG out. Combining three different sized S, M and L Unicorn caps (each with its own set of dry electrodes connected to a female 5×2 header) and a single Unicorn EEG amplifier (with the new male header) worked like a charm. The back of the enclosure still has the magnetic mount, similar to the original Unicorn case.

Switching the amplifier by unplugging it from one cap and plugging it into another one without even turning off the amplifier or software made it very easy to maintain attention to the visitors and keep a smooth flow in the EEG demonstration, not having to struggle with reconfiguring the hardware for different head sizes.

Unicorn Naked case and connectors for EEG, EMG and ECG

This page is part on a series on the Unicorn EEG system, see also the he other posts for a review of the Unicorn Hybrid Black, and the design and prototyping of alternative wet “sponge” electrodes.

The Unicorn Naked comes with the same dry electrodes and electrode leads (wires) as the Unicorn Hybrid Black. However, there is no real advantage of the Naked version over the Hybrid Black version if you want to use them with the same electrodes, unless you insist on a 3-D printed headset to hold the electrodes in place instead of a cap. We figured that the small size and weight, and it being wireless, made it an ideal candidate for developing a wearable system for EEG research on infants and children. At the same time, we sometimes have other applications where a small and wireless ExG system would be useful, for example to record EMG from the muscles or ECG from the heart.

This first image shows the result, further down on the page you can read more on the details and design considerations.

3d-printed unicorn naked case and connectors

Continue reading

Unicorn Naked EEG system with wet “sponge” electrodes

This page is part on a series on the Unicorn EEG system, see also the other posts for a review of the Unicorn Hybrid Black, and a 3D-printed case for the Unicorn Naked with connectors for EEG, EMG and ECG.

Together with the Unicorn Hybrid Black EEG system that I reported about in another post, I purchased a Unicorn Naked system. It is basically the bare PCB board of the Unicorn Hybrid Black amplifier, including connectors and electrodes, but without the housing and the cap. It comes with a LiPo battery, the cable bundle to connect the electrodes (including the LED strip), a set of 8 dry electrodes, a pack of 50 stick-on electrodes, and a Bluetooth USB dongle. It pairs with the computer just like the Unicorn Hybrid black and uses a unique device name; mine is UN-2022.01.10, which suggests that it includes the date of production and the serial number.

Although it comes with the same g.SAHARA Hybrid dry electrodes as the Unicorn Hybrid Black, the reason for me specifically getting the Naked version is that I want to attach other types of EEG electrodes and also use it for other biosignals like EMG and ECG. For EEG there are four types of electrodes that are common:

  • electrode paste, often combined with cup electrodes
  • electrode gel, usually applied with a syringe
  • wet sponge-like electrodes with saline solution, i.e., salt water
  • dry electrodes

The advantage of dry electrodes and wet sponge electrodes over the others is that you can put them on quickly, you can put them on on yourself, and they don’t leave any residue. Electrodes with gel or paste are more suited for a lab environment where a researcher or clinician applies the electrodes to the participant or patient.

However, they all share the same basic physical principles to pick up the potential differences on the scalp due to activity in the brain. Electric currents that flow through the head due to neuronal activity in the brain consist of ionic currents, i.e., these currents correspond to the displacement of positively charged Na+ and K+ and negatively charged Cl- ions. On the other hand, in the amplifier, the lead (wire) and the electrode the electric current is conducted using electrons. The electrode makes the contact with the nonmetallic part of the circuit, i.e., the scalp. The concept of the electrode as the interface between conductive and non-conductive materials has been long known and also applies to fields outside of neurophysiology; the Wikipedia lemma puts this nicely in perspective and provides links to the electrochemistry that happens at the interface.

On this page I present the details and design considerations for sponge electrodes that I constructed myself, based on Ag/AgCl ring electrodes that I had available. The design that I currently consider the most optimal due to its simplicity is electrode design 7. You can find more details further down on this page, including links to the sponge material.

Continue reading

Review of the Unicorn Hybrid Black 8-channel EEG system

This page is part on a series on the Unicorn EEG system, see also the other posts on the design and prototyping of alternative wet “sponge” electrodes, and a 3D-printed case for the Unicorn Naked with connectors for EEG, EMG and ECG..

I am exited to report on the Unicorn Hybrid Black EEG headset that I received a few weeks ago and that I have now been able to explore. Together with colleagues from the Donders Institute, the Baby and Child research center and the Body Brain Digital Musical Instrument project we are going to explore this system, both for non-intrusive EEG measurements in young children and for EEG biofeedback for creative musical applications.

The Unicorn is a low-cost 8-channel wireless head-mounted EEG device developed by Gtec and first released in 2019. Gtec has been developing research-quality EEG systems for Brain-Computer Interfaces for a long time, and in recent years have been organizing a series of BR41N.IO hackathons that target hackers/makers and creative applications. I have worked with Gtec systems at a number of BCI2000 workshops, and we used the Gtec Nautilus for the Cogito in Space project (see also here) Given this background, I had high expectations for this new system and the Unicorn does not disappoint.

Unboxing

It arrived in a nicely designed and environmentally friendly cardboard packaging, including dry electrodes, a pack of 50 stick-on electrodes for the reference and ground, a medium-sized cap, an USB Bluetooth dongle and a micro-USB cable for charging. The Bluetooth dongle was not needed to get it working, it also works fine with the built-in Bluetooth of the Lenovo Yoga and Lenovo Thinkpad laptops that I tested it with.

Continue reading

Calibrating the Sonoff ZNB02 zigbee temperature and humidity sensor

I recently installed a few Sonoff ZNB02 temperature and humidity sensors around the house. Monitoring them for some time, I noticed that the humidity level was higher that what is recommended for a comfortable and healthy indoor environment. Initially this got me worrying about the indoor climate, but as there are no other indications that it is so humid, it made me think that these sensors are perhaps not so accurate. Therefore I decided to calibrate them.

When you mix half a cup of normal kitchen salt with water into a sludge (i.e., a fully saturated solution) and put that in a closed container, that acts as a sort of constant humidity buffer for quite a wide range of temperatures. For a solution of NaCl at room temperature the relative humidity in the container will be 75%.

Continue reading

Mixing multiple microphones for hybrid meetings

Behringer MX400 as summing mixer

During the last 1.5 year I have been working mostly from home, as all of my direct colleagues. Initially it took us some time getting used to doing our group meetings online, but by now we know how to make those pleasant, inclusive and efficient. Now that many people are vaccinated, we expect/hope that we’ll soon be able to get back to the university for work. However, there are a few aspects of online meetings that I value and hope to can maintain. The travel time is much less, making it easier to quickly join a meeting that otherwise would be held on the other side of campus. It is rather trivial to have people join from abroad, e.g. previous colleagues that want to keep their connection and contribute to the Donders knowledge and culture. Everyone can share their screen much easier. The chat is used to post background material, links to relevant papers, etc. Consequently, I expect that we will not all of a sudden switch back to in real-life meetings, but rather we will have a (possibly infinite) period in which some people attend in real-life, and others online.

In our MEG meeting and the hackathon we have experimented with different aspects of hybrid meetings and documented our findings. We quickly learned that to ensure lively discussions, real-life and online attendees should be able to hear each very well. Spontaneously talk between live participants is easy, but the online participants should be able to hear everything without extra strain and be able to chime in.

Continue reading

Wireless classroom conference microphone system – #5

This post is part of a series on designing a wireless microphone system for hybrid online meetings, i.e. with some people present in person and others present online. See also the previous post in this series.

So far I have built and experimented with 4 wifi microphones, including an on/off switch and a rechargeable LiPo battery. I also added a magnetic name tag holder like this to the back of each of the microphones, allowing them to be mounted on a shirt or the the lapel of a jacket. The most relevant parts comprise an INMP441 microphone connected to a Lolin32 lite board. I have a few more wired up with just the Lolin32 board and the microphone to allow testing a larger number.

I have also implemented a Python based server that is running on a Raspberry Pi zero W, which also functions as Wifi access point. The audio server buffers and mixes the incoming signal from the different microphones and plays it on a HifiBerry DAC+ zero audio card. The output is a line level voltage, strong enough to drive a headphone, and with some attenuation also suitable to feed into the microphone input of a low-cost USB headset adapter. The whole system works as expected, although the noise level of the microphones is higher than I had hoped. My guess is that it is in part due to the microphone being so close to the ESP8266 antenna. Also, the wires between the microcontroller and the microphone run over the Lolin32 board without any shielding, probably picking up EM interference.

The Arduino source code, the Python audio server code, and the Fusion360 CAD design files are available from the wifimic repository on Github.

The fact that it works with an USB headset adapter like this, i.e. a miniature external sound card, demonstrates that the device can also be connected to the standard Windows laptop “pink” microphone input.

My MacBook has a TRRS combined audio input/output and the TRS (stereo) cable that comes from the HifiBerry DAC audio card is not recognized as microphone when I plug it in, but over the USB headset adapter it works fine. There are Y-adapters to split the TRRS input into TRS for the headphone and a TS for the microphone that would allow connecting it. However, the Python audio server also works fine on macOS, which has the advantage that I can investigate the microphone audio signals in full quality. Rather than first converting the sound to a analog line-out on the Raspberry Pi, and then back into a digital representation by the USB headset adapter, I can use BlackHole or Soundflower to get the digital audio stream as it is generated by the microphone. A cool feature of BlackHole and Soundflower is that they support many channels. With some modifications to the Python server script, it will also be possible to stream the audio output of each microphone to each own channel, and record them with Audacity.