Switching the Mugic to Wifi Client Mode (no app)

publié le 15 August 2023

I've been experimenting for some time with the Mugic, a very nice 9-axis IMU (accelerometer, magnetometer and gyroscope, 3 axes each) based on the BNO055 "smart" sensor. For instance, the following video shows a motion-controlled harmonizer allowing to play 4-part jazz harmonies with a single flute, using the player's position to select the quality of the chords (and the dice allows to select which notes are played, allowing to harmonize in 3rds, 5ths, 7ths or combinations thereof).

This sensor really opens up interesting perspectives and that's why we've decided to include it in Les Chemins de Traverse's teaching at the Summer Academy of the La Côte Flûte Festival.

So we ordered 7 more sensors so that each student in the Augmented Instruments workshop could use one simultaneously.

The default setting of the mugic is to provide its own wifi access point (AP). This is convenient for quick testing, but is a little bit fragile - and doesn't scale to several devices. So I had to switch the devices to "Wifi client mode", where it can connect to an existing wifi. The mugic team provides an application for this, but it's not available for Linux. It's also supposed to be possible via a web browser (I wouldn't have bought it otherwise), but I soon noticed it did not work as advertised.

Luckily, the mugic team has been very helpful (we spent more than two hours on the phone trying to fix things) and we finally found a way that works. I put it here, more as a reminder for myself when I need to do it again, but if it can be useful to others...

  • boot the mugic

  • connect your computer to the mugic's AP

  • run the following script (must be adapted to your use case!). Of course you could visit the URLs manually, but that would be tedious and error-prone...

import sys
from urllib.request import urlopen
from urllib.parse import quote

mugic_index = int(sys.argv[1])
device_url = ''

setup = {
    'prefix': f'mugic/{mugic_index}',
    'wifi_ssid' : '<SSID>',
    'wifi_pwd' : '<PASSWORD>',
    'wifi_ip' : '', # The IP you want to send to
    'wifi_port' : '4000',
    'wifi' : 'c',
    'button' : '1',

for k, v in setup.items():
    v = quote(v)
    url = f'http://{device_url}/set?{k}={v}'

url = f'http://{device_url}/commit'
  • Now with a paper clip or similar device, press the button in the tiny hole on the long side of the mugic. This should switch the mugic to wifi client mode - all going well it should connect to your wifi and start sending data to the IP you provided (liblo's oscdump is your friend).

  • If it works, you'll have to "commit" again so that it goes to client mode again after reboot. But you don't know the device's IP on the new network. You could check in your router admin interface, but as I'm lazy I wrote this code, that will scan your network for the first mugic it finds and call a "commit" on it (this is not very robust, don't use it blindly):

from urllib.request import urlopen
from bs4 import BeautifulSoup

for i in range(100,200): # adapt to your router's dhcpcd address range
        ip = f'http://192.168.10.{i}'
        response = urlopen(ip, timeout=.1)
        soup = BeautifulSoup(response, 'html.parser')
        if soup.title.string == '{v}':
            url = f'{ip}/commit'

And voilà! Hopefully your mugic is now in client mode... to be sure, power cycle and see if it starts in client mode again. If anything goes wrong, there's a reset button on the small side - just press it and start again.

When it works, switch it off... and do the same with the next mugic!

Note One of the problems I had was that my wifi SSID was rejected by the mugic. I'm not sure what the problem was, but it seems having an SSID that is at least 8 characters long and without special characters (whatever that means) helps.