Adding Bluetooth to Vintage Headphones – Part 2


First part of the article.

I received the parts and the PCBs:


First thing I noticed is that the hole for the screw that will press the button is missing. The cutout in the soldermask is there but not the hole. Damn you cheap chinese PCB manufacturers!

All right, now I remember: I did the PCB cutout in the soldermask and decided to draw it on the mechanical layer later*.


Well, it’s nothing a Dremel and a needle file can’t fix. And I need to countersink the holes for the screw heads anyway.

Yet another detail: I measured the diameter of the hole of the option for a bigger axis screw (M3) to be 4mm. I might have decided to postpone the before-order-review of my PCB for later™ too…

Anyway, I’m curious to see if everything fits as nicely as in my 3D model. Let’s start with the potentiometer.

The PCB holding the potentiometer and the screw for the pushbutton (hole on the left):


The other side, which will be attached to the  headphone ear cup and holds the axis screw:


Not bad**. (The nut on the axis screw which sets the spacing of the two PCBs is missing on the photo.)

The whole fist surprisingly well on the side of the ear cup:


You can see the pushbutton and its actuator screw.

On the other side, the potentiometer sticks out enough to be pushed or turned:


Now the main PCB with the BM62 Bluetooth module and the PIC microcontroller, and the small PCB for the USB socket and the RGB LED:


They fit nicely too:


After this, I could build the bracket for the USB and LED PCB. I made it of 2mm thick acrylic sheets which I glued together. The light pipe for the RGB LED is the same material:


The glue is two components epoxy. Note the BM62 Bluetooth antenna sticking out from under the main PCB.

The result on the other side is quite ok:


I filed and sanded the piece of acrylic so it’s flush with the ear cup plastic and gives a diffused light.

One thing I didn’t think through enough is the mounting of all the mechanical parts together.  Because the PCB holding the potentiometer blocks the access to the screws attaching the first PCB to the side of the ear cup, it has to be assembled last. But then the axis screw touches the USB PCB making it impossible to put a nut on it. And you can’t pre-assemble it because you need access the screws holding the other half to the ear cup. Neither can the two PCBs have an angle, because the screw pushing the button has a hole limiting the PCBs angle against each other. Vicious circle. I ended up filing a corner of the PCB holding the USB connector to have space to put the locking nut for the axis screw and inserting the actuator screw last..

Apparently, having your ways with a professional 3D software doesn’t make you instantly a mechanical engineer.

At the end it was tight, but everything could fit without too much cursing. The LiPo battery sits flat against the main board.


Now let’s take care of the guts!

The BM62 Bluetooth module

Microchip advertizes it as “a fully-certified Bluetooth module for designers who want to add Bluetooth wireless audio and voice applications to their products.” and “Easy to configure with User Interface (UI) tool, a Windows® configuration utility or directly by MCU”

A serial interface can be used to command the module (enter pairing mode, wake up, volume etc). For the configuration, there is an onboard EEPROM, also accessible through the serial interface. Microchip provides tools to help with the development (for free and without login/registration -a nice touch):

  • A program to edit the configuration.
  • An utility to download the configurations to the module’s EEPROM.
  • A program to configure the BM62 DSP.
  • A tool to connect to the BM62 via the serial interface and to change and query all the settings and the module status (the Command Set Tool).
  • Some documentation (for the serial protocol).

The first step would be to use the Command Set Tool to play with the module and to get familiar with the different modes.

In reality, I spent some hours trying to connect the tool to the BM62 without success. After cursing the entire earth and the human lineage, I saw on a forum post that the serial interface of the BM62 has to be enabled in the EEPROM configuration first.

This is how looks the user configuration file to generate:

eeprom conf.png

It’s only a part of the EEPROM binary and has to be wrapped with the help of another Microchip tool, “MPET”.

I am not sure there is a comprehensive documentation for every bitfield. Luckily, Microchip’s program “UITool” can generate the text file. Unfortunately, it looks like it was coded by someone with no idea of software design, or anything about Windows 7 and above.

A polite welcome message greats you at launch:


Then, things get a bit messier. Luckily, there is a help function with a nice yellow notepady background:


Ok, never mind.

Note also that the help windows sizes are kind of random but fixed, so depending of your screen resolution and DPI setting, it can happen that the scroll bar isn’t long enough:


The best is, once you generated the text file with your configuration, you still have to go through the MPET thing (a dozen or so clicks, three files to open), put the BM62 in ROM boot mode by holding a pin low while powering it up (too bad if you already soldered a battery – you’ll have to disconnect it), upload the configuration with the third tool and, finally, test your new modifications. Don’t expect to try small changes, unless you have plenty of time.

Anyway, I managed to enable the serial interface of the module. From there, I could connect with the Command Set Tool:


It looks like it was done by the same unpaid intern, but it gets the job done. A nice touch is the log section: it shows and translates the received and sent data. You can even copy the messages into the Windows clipboard. Woohoo!

The tool gave me a good start with the BM62 and helped me to test and tweak the configuration. It was convenient to debug my hardware and my code, especially in case of doubt.

The PIC code

The PIC18LF4550 will  manage the BM62 module, the pushbutton and the potentiometer.

The program has to:

  • Wake up and power off the BM62 module
  • Put the module into Bluetooth pairing mode
  • Read the potentiometer value and send it to the BM62
  • Put the PIC in sleep mode as often as possible to save the power

For this we have:

  • The pushbutton
  • The potentiometer
  • The red LED of the RGB LED
  • The serial interface

The pushbutton will trigger an interrupt (INT0 -pin RB0). The ADC acquisition will be triggered by the Timer1 and Capture Compare module 2. I tried to use the High/Low-Voltage Detect module to see if the USB cable was plugged and the battery charging (to for example, configure the PIC to act as a USB-serial converter, for debug purposes) but because the PIC gets its power from the BM62 “SYS_PWR” pin, the voltage was too dependent of the current the PIC was pulling from it, making the detection unreliable.

Speaking of the SYS_PWR pin, it’s the output of the BM62 internal power source switch (battery or USB) but it’s a pity the datasheet doesn’t give the current capabilities of this pin.BM62_power_tree.png

(There are three other pins with voltages from the BM62, VDDA, BK_OUT and VDD_IO, but here, the datasheet says you’re not supposed to use them).

Low power design

The BM62 power consumption is around 15mA when streaming music, so the current taken by the PIC at that time isn’t really a problem and because it runs on the internal oscillator, it will be around 2mA max. anyway. The concern is when the headset is in sleep mode, with the BM62 powered off (10uA power off quiescent current). The PIC18LF4550 has a sleep mode current between 1uA and 2uA, quite good.

But the problem is everything else. Here, I messed things up by connecting the potentiometer between the power rail and the ground. With a value of 270 Ohms, the current would have been 11mA all the time, enough to drain the 800mAh LiPo battery I chose in two days. Bad design. Luckily I had spare pads for the PIC I/Os and I connected the Vcc of the potentiometer to the PIC (through a 1KOhm resistor) and I am only switching it on when I need to convert the value. I am also putting all the other IOs in high impedance (inputs) to minimize the sleep current.

I measured the total battery current in sleep mode (both the PIC and the BM62) around 100uA. It gives more than 200 days in standby.

Driving the BM62

Because I hate to spend more time on the embedded code than on the electronics for one-off projects like that, I tried to keep the things as simple as possible. First, I was using the BM62 module’s configurable control pins, but it ended up to be half unreliable, half annoying because of the time needed to change and upload the BM62 EEPROM configuration. I went for the serial communication instead.

Here, Microchip provides an Excel file which lists all the commands and parameters. Someone had the good idea to make a sheet (tab) per command, so you end up with a file with more than 100 tabs. And the links to go back to the command list don’t seem to work with LibreOffice. Luckily, there is a doc file with the same content and linearly organized. It also gives the timings for the data and the error handling. Each serial command is composed of:

  • Start byte (0xAA)
  • Length (2 bytes)
  • Operation code
  • Parameters
  • Checksum

With an optional 0x00 byte at the beginning of each transmission, in case the USART controller of your system can interrupt on this break character (like the PIC18F4550).

The checksum is described as:

Check sum rule: Summation of every byte after START WORD(LENGTH, COM.ID, COM PARAM, CHK SUM) is 0xXX00

Well, it’s not. Here again I found the answer on a forum. Yes, you have to sum the bytes from the length to the last byte before the checksum, but then invert the value and add 1 to it. Here is a working code:

uint8_t calculateChecksum(uint8_t* startByte, uint8_t* endByte)
 uint8_t checksum = 0;
 while(startByte <= endByte)
  checksum += *startByte;
 checksum = ~checksum + 1;
 return checksum;

And here, for reference, the function I wrote to pause or play the music when you push the potentiometer button while the BM62 is streaming:

void TogglePause(LEM_state_t *s)
 char buf[7];
 buf[0] = 0xAA; 
 buf[1] = 0x00;
 buf[2] = 0x03;
 buf[3] = 0x04;//music control
 buf[4] = 0x04;//reserved ??
 buf[5] = 0x07;//play pause toggle
 buf[6] = calculateChecksum(&buf[1], &buf[5]);
 bm62Puts(buf, 7);

An other little detail missing from the documentation is about the two LEDs controlled by the BM62. Of course, you want a blue LED to flash when streaming, because you know, Bluetooth. The other LED can be green. Unfortunately, I could find nowhere in the datasheet or the tools which one of the two pins called LED1 and LED2 is for which color. Of course Murphy got me and I had to bodge the PCB to invert the two. For reference: the LED2 output is forthe blue one.

The source code can be found on my Github. Because I only included the files directly related to the BM62, you won’t be able to compile them directly (I omitted all the USB-serial converter files from Microchip). The code is quickly written and doesn’t reflect my magnificent embedded C skills… 😉


I made a short clip to show the headset working:

I’m very pleased with the results. I can use the headset a whole week, using it a few hours everyday on a single charge thanks to the 800 mAh LiPo battery combined with the low power consumption of the PIC and the BM62 module. The headset doesn’t seem heavier than before and the sound quality is the same. FTW!

Have a gif before you go :

BM62 LEM Headset.gif


**good enough