Controlling Bluetooth Lights With Puck.js

Photo of Espruino

Made by Espruino

About the project

Control most types of Bluetooth lightbulb using Puck.js.

Project info

Difficulty: Easy

Estimated time: 3 hours

Items used in this project

Hardware components

Awox Smartlight C9 Awox Smartlight C9 x 1
Espruino Puck.js v2 Espruino Puck.js v2 x 1


This video shows you how to control most types of Bluetooth lightbulb using Puck.js.

The actual code used is:

  1. function setLight(isOn) {
  2. var gatt;
  3. NRF.connect("98:7b:f3:61:1c:22").then(function(g) {
  4. // ^^^^^^^^^^^^^^^^^ your light's address here
  5. gatt = g;
  6. return gatt.getPrimaryService("33160fb9-5b27-4e70-b0f8-ff411e3ae078");
  7. }).then(function(service) {
  8. return service.getCharacteristic("217887f8-0af2-4002-9c05-24c9ecf71600");
  9. }).then(function(characteristic) {
  10. return characteristic.writeValue(isOn ? 1 : 0);
  11. }).then(function() {
  12. gatt.disconnect();
  13. console.log("Done!");
  14. });
  15. }
  17. var on = false;
  18. setWatch(function() {
  19. on = !on;
  20. setLight(on);
  21. }, BTN, { repeat:true, edge:"rising", debounce:50 });

But you'll have to change the address to that of your lightbulb!

This code will work with Awox Smartlight C9 and W13 bulbs. For other bulbs you may need to use the steps shown in the video to work out which characteristics were used.


For the Awox Smartlight W13 you can also change:

  • Brightness by writing a value from 0 to 127 to characteristic d8da934c-3d8f-4bdf-9230-f61295b69570 on service fff6fe25-469d-42bc-9179-b3a093f19032
  • Colour temperature by writing a value from 0 to 127 to characteristic 5b430c99-cb06-4c66-be2c-b538acfd1961 on service fff6fe25-469d-42bc-9179-b3a093f19032


You can buy the lights I used here from eBay:


Source code


Photo of Espruino


Espruino, Espruino Pico and Puck.js are low-power Microcontrollers that run JavaScript. Espruino is a JavaScript Interpreter for Microcontrollers that is designed to make development quick and easy. The Espruino interpreter is firmware that runs on a variety of different microcontrollers, but we also make Espruino Boards that come with the interpreter pre-installed and are the easiest devices to get started with. However Espruino itself isn't just the interpreter firmware or hardware - there's also the Web IDE, command-line tools, documentation, tutorials, and modules that form a complete solution for embedded software development.


Leave your feedback...