We have said several times that the ESP32 is feature rich. We will use two of the built-in components to build Hornbill Lights. In this tutorial we will make use of the built-in remote peripheral to drive the WS2812 LEDs with Hornbill ESP32 and then build a cross platform app using cordova-ionic to control the LEDs. The app speaks with the Hornbill ESP32 with Bluetooth Low Energy (BLE).

0 lights collage.jpg

Components

The Hornbill Lights Kit Comes with all the parts required to build the project.

  • WS2812 LED Strip. 5 meters in length uses 150 LEDs.
  • Power Supply, 10A.
  • Hornbill Lights Kit
    • Hornbill ESP32 Dev Board
    • Hornbill Proto Board
    • Other Passive components as per schematic.

Lights parts.jpg

Schematic

Lights sch.jpg

Code

The firmware is written in bare metal 'C' using the ESP-IDF. The code as is works, however it will need some clean up. Also we are working on porting Bluetooth and WS2812 library to arduino. I will update the tutorial with the Arduino Code once it is done.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/event_groups.h"
#include "esp_system.h"
#include "esp_log.h" //data logging
#include "nvs_flash.h" //permnant
//hornbill lights files
#include "ble.h"
#include "WS2812.h"
 
void app_main()
{
    esp_err_t ret;
    esp_bt_controller_init();
 
    ret = esp_bluedroid_init();
    if (ret) {
        ESP_LOGE(GATTS_TAG, "%s init bluetooth failed\n", __func__);
        return;
    }
 
    ret = esp_bluedroid_enable();
    if (ret) {
        ESP_LOGE(GATTS_TAG, "%s enable bluetooth failed\n", __func__);
        return;
    }
 
    esp_ble_gatts_register_callback(gatts_event_handler);
    esp_ble_gap_register_callback(gap_event_handler);
    esp_ble_gatts_app_register(PROFILE_A_APP_ID);
    esp_ble_gatts_app_register(PROFILE_B_APP_ID);
 
    hornbillLights_begin((rmt_channel_t) 0, (gpio_num_t)16, (uint16_t)150);
}

App

The Hornbill Lights App can be used to set any color depending on your mood or run light effects like rainbow. The app is still not published on the app store. However if you're using an Android Phone you may download the .apk file from repository (links in the download section).

Hornbill lights app.jpg

Installation

I would recommend using aluminum brackets to to install the strips with plastic caps. This serves dual purpose of heat dissipation and light refraction. Like the one shown in the Image below. Aluminium holders.jpg