Control a Neopixel using I2S via BLE

Abdelali Boussetta
3 min readSep 7, 2020

--

In this tutorial we’ll be looking into how to control a Neopixel (WS2812b) using the I2S peripheral via BLE.

The project is based on the nordic’s nRF52 series of SOCs.

The Neocontroller app controlling the ws2812b RGB led on the Adafruit board.

1. Hardware :

For the Hardware will be using the Adafruit Feather nRF52840 Express, as it is already having a Neopixel (WS2812b) on board.

The Adafruit Feather nRF52840 Express featuring a ws2812b.

You can still use any off the nRF52 SOCs boards, you’ll just need to grab a ws2812b module. like this one from sparkfun.

Sparkfun ws2812b RGB led module.

And make sure to hook the module to your board using the Data In pin (DI).

Note: Unless you’re using a different board then the Adafruit nRF52840, you can update the Neopixel pin number in the main.c file.

2. Softwares :

The nRF52 firmware :

The firmware is :

  • Based off the Nordic nRF5_SDK.
  • Compatible with the nRF5_SDK versions starting from v15.3.
  • Uses the SEGGER toolchain.

And support many development boards :

The nRF5_SDK already supports the nRF52-DK and the nRF52840-DK development kits.

To add the Adafruit board support, you’ll need to update the boards folder located under the components folder in the nRF5_SDK.

In $nRF5_SDK_location/components/boards, add the two adafruit board files and update the boards.c file, using the files provided in the github repo above.

If you don’t have an external j-link debugger to flash the firmware to the Adafruit board, you can use an nRF5 development kit instead.

(1): The nRF52840-DK. It can be any development board that has an on-board segger j-link and a debug out port.

(2): The Adafruit Feather nRF52840 Express board. If you will be using the nRF52832 version, you’ll need to solder the SWD connector or connect the SWD pins (back of the board as test points) to the P20 connector on the nRF52840-DK.

(3): The j-link cable: Socket to socket, 2x5 pin, 1.27mm pitch. Example.

Note: Make sure you perform a full erase to the SOC, before flashing the new firmware.

The mobile app :

The app is a hybrid application built using the ionic framework (v5).

ionic + angular logos
Neocontroller ionic app.

The app features two pages.

  • The home page : used to scan for the PIXEL devices. It scans the nearby ble devices and filters them based on the supplied PIXEL ble uuid.
  • The details page : used to connect/disconnect/control the PIXEL device’s Neopixel, by sending RGB data [r,g,b].

The app uses the cordova-plugin-ble-central for the BLE functionalities.

Please find the app source code, also a build and ready to test android app in the following link to the project github repo.

--

--

Abdelali Boussetta

Embedded firmware developer, specialized in Bluetooth Low Energy applications.