Introduction: Light Bamboo (Connected Lamp)

Hello and welcome!

Light bamboo is a connected lamp that lights up when a notification is received on the Android smartphone to which it is connected. The goal of this instructable is to show you the design stage of the project : from the hardware architecture, to the Bluetooth Low Energy (BLE) connection and the Android application building.

For our lamp, we chose a plastic plant for a cool decorating design. For this project, the notifications which are displayed are from the following applications: calls, sms/mms, facebook, messenger, instagram, whatsapp ang gmail. One light color is attributed for each type of notification.

For this project, you will need:

  • A uC with an integrated BLE module : nFR51822 RedBearLab
  • 3 NeoPixel Ring (12 RGB LEDs)
  • An Android smartphone
  • Android Studio

Each notification has a specific priority, depending on its importance. For example, an incoming call notification is more important than a Facebook notification. In that case, the LEDs color will be associated to the incoming call notification.

The smartphone on which we developed the application is a Samsung Galaxy A5.

Step 1: Hardware Part

Our architecture is quite simple.

Connect the NeoPixel Ring pins to the nRF51822 board as follow :

  • Inout Data pin of the NeoPixel Ring to the port 3 of the uC.
  • Vcc of the NeoPixel Ring to the 3.3V of the uC.
  • GND of the NeoPixel Ring to the GND of the uC.

You can notice that we do not use the Output Data pin of the NeoPixel Ring. That is because the Input Data pins of the three NeoPixel Rings we use in this project are all connected to the same port of the nRF51822 board (pin 3).

Step 2: Software Part

1. The Bluetooth Low Energy communication:

In a BLE communication, the server (which is in our case the uC) and the client (the smartphone) exchange data using GATT transactions. In those transactions, the data is organized hierarchically in sections called services, which group conceptually related pieces of user data called characteristics. In our case, the data encapsulation is simple since we only have one information to pass from the client to the server (see the image above).

  • on the server side : To be able to use the nrf51822 board as a BLE server, first install the "BLEPeripheral.h" library on the Arduino IDE. This library provides with ready-to-use functions for creating the services and characteristics and advertising.
  • on the client side : To start a BLE communication in Android Studio, first configure the BLE permissions in the Manifest file. Then, in the activity_main.xml file, add 4 buttons: scan, stop scan, connect and disconnect that will allow the application to scan for nearby BLE devices, stop the scan, connect and disconnect to a device. In the file, implement the functions that are associated with the previous buttons: startScanning(), stopscanning(), connectToDeviceSelected(), disconnectDeviceSelected().Finally, implement the callback functions that get called when the state of the client changes.

2. Notification management

  • on the client side (on Android Studio): To listen for the notifications coming from the smartphone, implement a notification listener which is activated when a notification occurs in the status bar. This notification listener will send a "message", called an intent, to the main activity when a notification is posted or removed. This "message" contains a notification code that helps identify the application which posted the notification. To process the notification in the main activity, create a broadcast receiver that will receive the message from the notification listener. Then, depending on the notification code, a different character is sent to the server.
  • on the server side (on Arduino IDE): the notification which has the highest priority is displayed.

Step 3: Step 3 : Annexes

Here, you will find all the code source.