Setting Up Wi-Fi Simple Configuration with NFC on Raspberry Pi

This post shows steps to setup Wi-Fi Simple Configuration with NFC adapter on Raspberry Pi using nfcpy[1]. The goal is to enable “tap-to-connect” a NFC enabled phone with a Wi-Fi access point [2].


Prerequisites (parentheses indicate my environment)


1. Installation
1-1. Install nfcpy.

1-2. Verify installation by running the module.

The output should be like this:

1-3. As the output suggests, copy line 11 above and execute it.

1-4. Reboot the system.

1-5. After reboot, run the module again.

This time, the output should be like this:


2. Setting up Wi-Fi Simple Configuration
2-1. Download example code [3].

2-2. Create NDEF data [4] for Configuration token [5].

Note: Replace “NETWORK_NAME” and “PASSWORD” based on your environment.

2-3. Write NDEF data to NFC adapter [6].


3. Test
3-1. Enable NFC on the phone.

3-2. Move the phone close to the NFC adapter.

3-3. Allow to connect if the phone asks for permission.



[1] Python module for near field communication – nfcpy
[2] WPS adds NFC “tap-to-connect” for simple set up – Wi-Fi Alliance
[3] nfcpy – GitHub
[4] NFC Data Exchange Format – nfcpy
[5] make wificfg – nfcpy
[6] emulate – nfcpy



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.


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


1. Prep
1-1.Install prerequisite package.

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

1-3. Extract the archive file.

1-4. Make.


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

2-2. Change Bluetooth device address.

The result should be like this:

2-3. Reset hci device.

2-4. Also, restart bluetooth service.


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

3-2. Check the change with bluetoothctl.


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



Qt Creator Cross Compiling Environment for Raspbian Stretch using QtRpi

This post shows how to create Qt Creator cross development environment on Ubuntu PC for Raspbian Stretch by using QtRpi. Although QtRpi does not officially support Raspbian Stretch [1], additional few steps make it possible to create the cross development environment for Stretch. (For Raspbian Jessie, please see this post.)


– Assumptions
– Steps
1. Host Preparation (Ubuntu)
2. QtRpi Installation
3. Deploy to Raspberry Pi
4. Raspberry Pi Configuration
5. Qt Creator Configuration
6. Verify Cross Compiling Environment
– Reference


Here are some assumptions for the steps below.

  • Ubuntu Linux running on host PC
  • Raspbian Stretch running on target Raspberry Pi
  • Qt Creator running on host PC
  • SSH access from host PC to target Raspberry Pi

In this post, the versions I use are below:

  • Ubuntu 18.04 (host)
  • Qt Creator 4.6.1 (host)
  • Raspbian Stretch April 2018 version running on Raspberry Pi 3 (target)
  • Qt 5.7.0 (target)


1. Host Preparation (Ubuntu)
1-1. Install dependencies.

1-2. Configure environment variable for Qt version. As of writing this, QtRpi supports only 5.6.2 and 5.7.0. [2]

1-3. Configure environment variable for Raspberry Pi model. For different models, check the official site.

1-4. Configure environment variable for target IP address.

1-5. Generate SSH key. Just press enter when you asked about pass phrase.

1-6. Copy the key to the target so that you can log in without requiring a password afterwards.


2. QtRpi Installation
2-1. On host, download QtRpi from GitHub.

2-2. Then run “” script. This will take a while.


3. Deploy to Raspberry Pi
Before start the deployment script, one modification is required since a name of a package has been changed. [3]

3-1. Open the deployment script file.

3-2. Look for the line below and replace “libinput5” with “libinput10”.

After the change, the line should be this:

3-3. Then, run the deployment script.


4. Raspberry Pi Configuration
4-1. Login to Raspberry Pi.

4-2. Create symbolic links since some libraries has changed names in Stretch. [4] [5] [6]

4-3. Copy font files.

Note: This step is a workaround for font display. (see troubleshoot in the previous post for detail.)


5. Qt Creator Configuration
5-1. Device Configuration
5-1-1. Launch Qt Creator on host.
5-1-2. Navigate to “Tools” > “Options…”
5-1-3. In Options window, select “Devices” from left side bar.
5-1-4. Select “Add…”
5-1-5. Double click on “Generic Linux Device”

5-1-6. Enter information below into “New Generic Linux Device Configuration Setup” window.
Configuration name:

IP address:  (your RPi’s IP address)


Authentication type:

5-1-7. Click on “Next”, Then “Finish”. Then, it will automatically start “Device Test”.
5-1-8. Click “Close” to close “Device Test” window.

5-2. Debuggers
5-2-1. In Options window, select “Build & Run” from left side bar.
5-2-2. Click on “Debuggers” tab
5-2-3. Click on “Add” button
5-2-4. Put information below:



5-3. Compilers
5-3-1. Click on “Compilers” tab
5-3-2. Navigate to “Add” > “GCC” > “C”
5-3-3. Enter information below:

Compiler Path:

5-3-4. Navigate to “Add” > “GCC” > “C++”
5-3-5. Enter information below:

Compiler Path:


5-4. Qt Versions
5-4-1. Click on “Qt Versions” tab
5-4-2. Click on “Add…”
5-4-3. Navigate the qmake path:

5-4-4. Enter below as “Version name”.

5-4-5. Click on “Apply” button

5-5. Kits
5-5-1. Click on “Kits” tab and then “Add” button
5-5-2. Enter (or select) information below:
Name :

Device Type:

Sysroot :

Compiler: C:

Compiler: C++:

Debugger :

Qt Version :

5-5-3. Click on “Apply” button, then “OK”.


6. Verify Cross Compiling Environment
Let’s check if everything is OK by building a sample project on host and executing it on RPi.

6-1. “File” > “New File or Project”
6-2. “Application” > “Qt Qucick Application”, then click on “Choose…” button.
6-3. Enter project name and click on “Next”.
6-4. Click on “Next” on “Define Build System”.
6-5. Select “Qt 5.7” and click “Next” on “Define Project Details”.
6-6. Check on “Rpi 3” and click “Next” on “Kit Selection”.
6-7. Click on “Finish” button on “Project Management”.
6-8. Open .pro file from the project tree.
6-9. Replace “Default rules for deployment” portion with the two lines below.

6-10. Select “Projects” icon on left side bar.
6-11. Click on “Rpi 3” under “Build & Run”.
6-12. Click on “Run” icon on the left side bar.


[1] QtRpi Requirements – GitHub
[2] What versions of Qt is available? – QtRpi FAQ
[3] “unable to locate libinput5” #69 – qtrpi – GitHub
[4] Games that uses doen’t work in raspbian stretch –
[5] ArchLinux Qt eglfs –
[6] Linking the Application to the Static Version of Qt – Qt Documentation



Enabling Equalizer on Raspberry Pi using ALSA equal Plugin

This post shows how to setup a system wide equalizer on Raspberry Pi using ALSA equal plugin. Below are my setup.

  • Raspberry Pi3 B+ with Raspbian Stretch (2018 April version)
  • 3.5 mm plug Speaker


– Assumptions
– Steps
1. Equalizer Plugin Installation
2. ALSA Configuration
3. Play audio
4. Verify Equalizer
– Notes
– Reference


1. Equalizer Plugin Installation


2. ALSA Configuration
2-1. Create .asoundrc.

2-2. Add the lines below, save and close the file.

2-3. Reload .asoundrc.


3. Play audio
Play a sample sound file in a loop for testing.

Note: Press Ctrl+C to exit.


4. Verify Equalizer
Adjust the equalizer by using alsamixer command.

The sound from Raspberry Pi’s speaker should change as you change the equalizer values.


Since Raspbian Stretch, Bluetooth audio is handled by ALSA using bluez-alsa [2]. So if A2DP sink is enabled, this equalizer can be also applied on Bluetooth audio.


[1] Raspbian: the great Equalizer
[2] Raspbian Stretch has arrived – Raspberry Pi Official Blog



Streaming Bluetooth Audio from Phone to Raspberry Pi using ALSA

This post shows steps to setup Bluetooth audio sink on Raspberry Pi using bluez-alsa. Bluetooth audio sink (A2DP sink) enables Raspberry Pi to receive audio from other Bluetooth devices (e.g. smartphone) and play it through the connected speaker. Below are my setup.

  • Raspberry Pi3 B+ with Raspbian Stretch (2018 April version)
  • 3.5 mm plug Speaker
  • Smartphone


– Steps
1. Bluetooth Pairing and Connection
2. Audio Routing
3. Verify
– Summary
– Troubleshoot
– Reference


1. Bluetooth Pairing and Connection
1-1. Launch BlueZ command line interface.

1-2. Setup a pairing agent.

1-3. Make the Raspberry Pi discoverable.

1-4. On your phone, search and select your Raspberry Pi from Bluetooth menu.

1-5. Confirm the pairing on both your phone and Raspberry Pi.

1-6. Authorize A2DP service (first 32 bits: 0000110d). [1]

Note: You may be asked about other services (such as HFP: 0000111E) depending on what services your phone supports. Just answer ‘yes’ to all the services if you are not sure.

1-7. Trust the phone so that Raspberry Pi will automatically accept connections from the phone from the next time.

Note: Replace “XX:XX:XX:XX:XX:XX” with your phone’s Bluetooth device address.

1-8. Exit from BlueZ command line interface.


2. Audio Routing
2-1. Forward audio from the phone to Raspberry Pi’s output.


3. Verify
3-1. Launch a media player and play some music on your phone. You should be able to hear the music from Raspberry Pi’s speaker.


Troubleshoot : Sound Cutting Out
Raspberry Pi’s (3 / 3+ / Zero W) on-board Bluetooth+WiFi combo chip has an issue and the Bluetooth sound cuts out when WiFi is enabled [2]. If you don’t need WiFi, you can just disable the WiFi interface to avoid the sound cutting issue.

If you need WiFi, one of the workarounds is to disable the on-board Bluetooth and use a Bluetooth dongle (e.g. Plugable BLE Adapter, Panda Bluetooth 4.0 Adapter) instead. Below is the steps to do that.

1. Open “/etc/modprobe.d/raspi-blacklist.conf”.

2. Add lines below and save.

3. Connect Bluetooth dongle on Raspberry Pi’s USB port.

4. Restart the Raspberry Pi.


[1] Service Discovery – Bluetooth SIG
[2] Pi3 bluetooth audio stutters with Wifi enabled