element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Pi IoT
  • Challenges & Projects
  • Design Challenges
  • Pi IoT
  • More
  • Cancel
Pi IoT
Blog [Pi IoT] - Smarter Spaces #4 - Remote Horse Feeder System
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: jomoenginer
  • Date Created: 8 Aug 2016 4:43 AM Date Created
  • Views 653 views
  • Likes 2 likes
  • Comments 2 comments
  • pi iot
  • openhab
  • enocean-pi
  • bluez
  • ilumi br30
Related
Recommended

[Pi IoT] - Smarter Spaces #4 - Remote Horse Feeder System

jomoenginer
jomoenginer
8 Aug 2016

In this update, I cover the hacking of the iLumi Br30 BLE LED Light and controlling it from OpenHAB via BlueZ and the EnOcean Rocker switch.  My plan is to use the iLumi BR30 Outdoor LED Flood and wanted something that was remote controlled and not tied to a hub.

 

Hardware used:

  • Raspberry PI 3 and B+
  • Pi Cam Noir
  • EnOcean PTM Rocker Switch
  • EnOcean Pi 902 MHz TCM310 Receiver
  • Wi-Pi Wireless module

 

Scanning for BLE devices

 

I will not cover the install of BlueZ on the Raspberry Pi since it has been cover multiple times in other posts, however BlueZ 5.40 was used in this example.

 

  • Ensure the BLE device is up on the Raspberry Pi

$ hcitool dev

Devices:

  hci0 B8:27:EB:0A:18:49

 

 

  • Scan for available BLE devices in range

$ sudo hcitool lescan

LE Scan ...

C5:0B:A1:81:44:DB (unknown)

B0:B4:48:C9:A1:02 (unknown)

B0:B4:48:C9:A1:02 CC2650 SensorTag

C5:0B:A1:81:44:DB Nrdic8144DB

 

NOTE: Here both a TI SensorTag and a Nordic Semiconductor device have been detected.

           Since the CC2650 SensorTag is a known device, the Nrdic8144DB must be the device for the iLumi BR30

 

  • Create a connection to the iLumi Device

 

$ sudo ~/bluez-5.40/tools/hcitool -i hci0 lecc C5:0B:A1:81:44:DB

Connection handle 64

 

//  Once the device is added to the list of items, reconnect and get the list of characteristics

 

  • Using the gatttool from BlueZ, try grabbing the list of Handles and Characteristics from the Nordic device.

 

$ sudo /home/pi/bluez-5.40/attrib/gatttool -i hci0 -b C5:0B:A1:81:44:DB -I

[C5:0B:A1:81:44:DB][LE]> connect

Attempting to connect to C5:0B:A1:81:44:DB

Connection successful

             

              NOTE: The iLumi BLE device will quickly kick out the connection, so getting the list of characteristics must be done quickly.

 

[C5:0B:A1:81:44:DB][LE]> connect

Attempting to connect to C5:0B:A1:81:44:DB

Connection successful

 

[C5:0B:A1:81:44:DB][LE]> characteristics

Command Failed: Disconnected

[C5:0B:A1:81:44:DB][LE]> connect

Attempting to connect to C5:0B:A1:81:44:DB

Connection successful

[C5:0B:A1:81:44:DB][LE]> characteristics

handle: 0x0002, char properties: 0x0a, char value handle: 0x0003, uuid: 00002a00-0000-1000-8000-00805f9b34fb

handle: 0x0004, char properties: 0x02, char value handle: 0x0005, uuid: 00002a01-0000-1000-8000-00805f9b34fb

handle: 0x0006, char properties: 0x02, char value handle: 0x0007, uuid: 00002a04-0000-1000-8000-00805f9b34fb

handle: 0x0009, char properties: 0x20, char value handle: 0x000a, uuid: 00002a05-0000-1000-8000-00805f9b34fb

handle: 0x000d, char properties: 0x02, char value handle: 0x000e, uuid: 00002a29-0000-1000-8000-00805f9b34fb

handle: 0x000f, char properties: 0x02, char value handle: 0x0010, uuid: 00002a24-0000-1000-8000-00805f9b34fb

handle: 0x0011, char properties: 0x02, char value handle: 0x0012, uuid: 00002a27-0000-1000-8000-00805f9b34fb

handle: 0x0013, char properties: 0x02, char value handle: 0x0014, uuid: 00002a26-0000-1000-8000-00805f9b34fb

handle: 0x0015, char properties: 0x02, char value handle: 0x0016, uuid: 00002a28-0000-1000-8000-00805f9b34fb

handle: 0x0018, char properties: 0x1e, char value handle: 0x0019, uuid: f000f0c1-0451-4000-b000-000000000000

[C5:0B:A1:81:44:DB][LE]>

(gatttool:19161): GLib-WARNING **: Invalid file descriptor.

                The GLib warning will pop up when the list is complete which kills the connection.

 

Notice, one of the listings looks a bit different so it is a good chance that this is the one to control the LED with.

handle: 0x0018, char properties: 0x1e, char value handle: 0x0019, uuid: f000f0c1-0451-4000-b000-000000000000

 

 

  • I created a python script that collects some basic data from the BLE device, creates a connection and sends an Initialization command to the iLumi BR30 via handle 0x0019.

 

$ sudo python  ble_scan4.py

Here be the file

['LE Scan ...', 'C5:0B:A1:81:44:DB (unknown)', 'C5:0B:A1:81:44:DB Nrdic8144DB']

Length of len(new_list): 2

NewList = ['C5:0B:A1:81:44:DB', 'Nrdic8144DB']:

Mac Address: C5:0B:A1:81:44:DB

Model: Nrdic8144DB

Nrdic8144DB found

Connection handle 64

Command to send = sudo gatttool -i hci0 -b C5:0B:A1:81:44:DB --char-write-req --handle=0x0019 —value=3235352c302c302c3130302c2c2c2c2c2c2c

 

  • The gatttool can be used to read from the iLumi to grab some info from the device:
    • Thus far, I have found I can only get the BLE Model and Vendor info from the iLumi.

 

$ sudo sudo /home/pi/bluez-5.40/attrib/gatttool -i hci0 -b C5:0B:A1:81:44:DB --char-read --handle=0x000e

Characteristic value/descriptor: 69 4c 75 6d 69 20 53 6f 6c 75 74 69 6f 6e 73

 

NOTE: The value that come back is in hex so it would have to be converted into a readable format.

 

 

  • I created another python script that does the conversion on values that are readable from a BLE device.  With the iLumi this was handles 0x000e and 0x0003

 

$ sudo python  ./get_bleASCII.py iLumiBR30  0x000e

The name = iLumiBR30

getName: sudo gatttool -i hci0 -b C5:0B:A1:81:44:DB --char-read --handle=0x000e

ASCII DATA: Characteristic value/descriptor: 69 4c 75 6d 69 20 53 6f 6c 75 74 69 6f 6e 73

 

ASCII String to convert: 694c756d6920536f6c7574696f6e73

iLumi Solutions

 

 

$ sudo python  ./get_bleASCII.py iLumiBR30  0x0003

The name = iLumiBR30

getName: sudo gatttool -i hci0 -b C5:0B:A1:81:44:DB --char-read --handle=0x0003

ASCII DATA: Characteristic value/descriptor: 4e 72 64 69 63 38 31 34 34 44 42

 

ASCII String to convert: 4e72646963383134344442

Nrdic8144DB

 

  • Now the device has been identified and can be communicated with, its time to attempt to send commands to it.
  • From what I have gathered in my search on the web and looking at other BLE LED examples, I ended up using the following code to initialize the iLumi BR30:
    • 3235352c302c302c3130302c2c2c2c2c2c2c

 

        And the following to change the intensity of the colors on the device.

    • 0xff010301ff00000000

 

  • This is what I ended up with to change the colors on the iLumi:

 

    • Initialize BLE Device

$ sudo /home/pi/bluez-5.40/attrib/gatttool -i hci0 -b C5:0B:A1:81:44:DB --char-write-req --handle=0x0019 --value=3235352c302c302c3130302c2c2c2c2c2c2c

Characteristic value was written successfully

 

    • Set to Darker color

$ sudo gatttool -i hci0 -b C5:0B:A1:81:44:DB --char-write-req --handle=0x0019 --value=0xff010301ff00000000

Characteristic value was written successfully

 

 

    • Set LED to Blue

     $ sudo /home/pi/bluez-5.40/attrib/gatttool -i hci0 -b C5:0B:A1:81:44:DB --char-write-req --handle=0x0019  —-value=58010301ff000000ff

     Characteristic value was written successfully

 

 

    • Set LED to Green

     $ sudo /home/pi/bluez-5.40/attrib/gatttool -i hci0 -b C5:0B:A1:81:44:DB --char-write-req --handle=0x0019 --value=58010301ff0000ff00

     Characteristic value was written successfully

 

    • Set LED to RED

      $ sudo /home/pi/bluez-5.40/attrib/gatttool -i hci0 -b C5:0B:A1:81:44:DB --char-write-req --handle=0x0019 —value=58010301ff00ff0000

     Characteristic value was written successfully

 

    • Set LED to OFF

      $ sudo /home/pi/bluez-5.40/attrib/gatttool -i hci0 -b C5:0B:A1:81:44:DB --char-write-req --handle=0x0019 --value=58010301ff00000000

     Characteristic value was written successfully

 

  • Now that the device can be written to, its time to add it to OpenHAB.  This uses a Python script I created that handles the reading and writing to a BLE device.

 

    • OpenHAB iLumi sitemap config:

        Frame label="iLumi" {

                Switch item=iLumi1_Stall label="iLumi LED1" icon="slider-80"

                Colorpicker item=iLumi1_Color label="iLumiBR30" icon="slider"

        }

 

    • OpenHAB iLumi item config:

Group iLumi

Switch iLumi1_Stall "Stall Light1" (iLumi) icon="settings"

Color  iLumi1_Color "Color" {exec=">[OFF:sudo /usr/bin/python /usr/share/openhab/configuration/test2.py "iLumi1" 0 0 0] >[ON:sudo  /usr/bin/python /usr/share/configuration/test2.py "iLumi1" 255 255 255]”}

 

 

 

    • OpenHAB ilumi rules config:

import org.openhab.core.library.types.*

import org.openhab.model.script.actions.*

 

var String iLumiTest = "python@@/opt/openhab/configurations/scripts/test.py@@"

 

rule "Set iLumi"

when

        Item iLumi1_Stall received command

then

    logInfo("Set iLumi", "Trying to run python script")

    if (receivedCommand == ON) {

        executeCommandLine (String::format(iLumiTest))

    }

end

 

rule "Set iLumi Color"

when

        Item iLumi1_Color changed

then

        val hsbValue    = iLumi1_Color.state as HSBType

        val brightness  = hsbValue.brightness.intValue

        val redValue    = ((((hsbValue.red.intValue * 255) / 100) * brightness) / 100).toString

        val greenValue  = ((((hsbValue.green.intValue * 255) / 100) * brightness) / 100).toString

        val blueValue   = ((((hsbValue.blue.intValue * 255) / 100) * brightness) / 100).toString

        logWarn("Red", redValue)

        logWarn("Green", greenValue)

        logWarn("Blue", blueValue)

 

        var String cmd = 'sudo /usr/bin/python /opt/openhab/configurations/scripts/test2.py ' + 'iLumi1' + ' ' + redValue + ' ' + greenValue + ' ' + blueValue

 

        executeCommandLine(cmd)

end

 

  • For the EnOcean Pi and Rocker switch, I added the following to the OpenHAB config:

 

    • OpenHAB EnOcean Rocker Switch sitemap config:

        Frame label="EnOcean" {

                Text label="EnOcean Switches" icon="smiley" {

                  Frame label="EnOcean Switches" {

                    Switch item=EnOcean_sensor_002BA820_A  label="Switch1"

                    Switch item=EnOcean_sensor_002BA820_B  label="Switch2"

 

                  }

                }

        }

 

 

    • OpenHAB EnOcean Rocker Switch items config:

Group EnOcean

Switch EnOcean_sensor_002BA820_A "Master A" <switch>  (EnOcean) {enocean="{id=00:2B:A8:20, eep=F6:02:01, channel=A}"}

Switch EnOcean_sensor_002BA820_B "Master B" <switch>  (EnOcean) {enocean="{id=00:2B:A8:20, eep=F6:02:01, channel=B}"}

 

    • OpenHAB EnOcean Rocker Switch rules config (channel A):

import org.openhab.core.library.types.*

import org.openhab.model.script.actions.*

 

var String iLumiTest = "python@@/opt/openhab/configurations/scripts/test2.py@@"

 

rule "EnOcean On"

when

        Item EnOcean_sensor_002BA820_A received command

then

    logInfo("EnOcean On", "Trying to run python script")

    if (receivedCommand == ON) {

        var String cmd = 'sudo /usr/bin/python /opt/openhab/configurations/scripts/test2.py ' + 'iLumi1' + ' ' + 255 + ' ' + 255 + ' ' + 255

        //executeCommandLine (String::format(iLumiTest))

        executeCommandLine (cmd)

        logInfo("EnOcean On", "Send on")

    }

    else if (receivedCommand == OFF) {

        var String cmd = 'sudo /usr/bin/python /opt/openhab/configurations/scripts/test2.py ' + 'iLumi1' + ' ' + 0 + ' ' + 0 + ' ' + 0

        executeCommandLine (cmd)

        logInfo("EnOcean On", "Send off")

    }

end

 

  • With all of this set, I was able to control the iLumi BR30 via OpenHAB and turn it on or off using the EnOcean Rocker Switch.
    • NOTE: The image of the BR30 is from a Raspberry Pi B+ which has a Pi CAM Noir connected to it and viewed remotely from OpenHAB thus the refresh rate is a bit slow

 

  • The attached video is the end result of this.
  • You don't have permission to edit metadata of this video.
    Edit media
    x
    image
    Upload Preview
    image
  • Sign in to reply
Parents
  • clem57
    clem57 over 9 years ago

    Good demo of the OpenHAB. I like the way this works.

    Thanks

    Clem

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • clem57
    clem57 over 9 years ago

    Good demo of the OpenHAB. I like the way this works.

    Thanks

    Clem

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube