Changing a Bluetooth Device Address on Raspberry Pi

This post shows how to change Bluetooth device address on Raspberry Pi.

Bluetooth device address (aka BD_ADDR, Bluetooth MAC address) is a 48-bit identifier assigned to each Bluetooth chip. Whether it can be changed is depends on each chip. Fortunately, Raspberry Pi’s on-board Bluetooth chip (Cypress/Broadcom) allows device address change.

 

Assumptions
Raspberry Pi board with on-board Bluetooth chip (e.g. Raspberry Pi3 B+Raspberry Pi Zero W)

 

Steps
1. Prep
1-1.Install prerequisite package.

sudo apt-get install libbluetooth-dev

1-2. Download the archived file of bdaddr tool. [1][2]

wget -U firefox http://www.petrilopia.net/wordpress/wp-content/uploads/bdaddrtar.bz2

1-3. Extract the archive file.

bzip2 -d bdaddrtar.bz2 && tar xf bdaddrtar

1-4. Make.

cd bdaddr && make

 

2. Bluetooth Address Change
2-1. Check the original Bluetooth address..

$ ./bdaddr -i hci0
Manufacturer:   Broadcom Corporation (15)
Device address: B8:27:EB:89:DA:DA

2-2. Change Bluetooth device address.

sudo ./bdaddr -i hci0 -r 00:11:22:33:44:55

The result should be like this:

$ sudo ./bdaddr -i hci0 -r 00:11:22:33:44:55
Manufacturer:   Broadcom Corporation (15)
Device address: B8:27:EB:89:DA:DA
New BD address: 00:11:22:33:44:55

Address changed - Device reset successully

2-3. Reset hci device.

sudo hciconfig hci0 reset

2-4. Also, restart bluetooth service.

sudo systemctl restart bluetooth.service

 

3. Verify
3-1. Check the change with bdaddr tool.

$ ./bdaddr -i hci0
Manufacturer:   Broadcom Corporation (15)
Device address: 00:11:22:33:44:55

3-2. Check the change with bluetoothctl.

$ bluetoothctl
[bluetooth]# list
Controller 00:11:22:33:44:55 raspberrypi [default]

 

References
[1] Change your bluetooth device mac-address
[2] Wget: Error 403- Can I get around this?

 

 

Sponsor Link

3 Comments

  1. Thanks, you made my day. I wrote a BLE program that worked
    on an RPi 3B+ + SD card. When I used this SD card in another RPi
    the program did not function anymore. Changing the MAC address
    of the second RPi into that of the first made it function again.

  2. Slight note: I had no luck with the downloaded bdaddr, but the one built into raspi-os (sudo apt install bdaddr) did the trick.
    Big thanks, 4h of research and messing with weird selfcompiled code and poking undocumented commands and GPIOs were solved by this.

    For the record: Raspi4B

Comments are closed.