IoT Christmas Star [ balena ❤️ adafruitIO ] -- build logs

It’s that time of the year, yet another holiday project. This time I decided to build a star jewel for my Christmas tree which can sit on top and light it up beautifully.

4 Likes

Share more @iayanpahwa how do you connect the Pi with the neopixel? :wink:

1 Like

:eyes:

1 Like

Initially I planned to design 3D printable holders in the shape of a star onto which I can stick my LED strip but it was too much time consuming , so decided to went analog, dusted my glue gun and soldering iron, ordered these parts and wore my safety glassed.

1 Like

Bill-of-material :

  • A pack of popsicle sticks :wink:
  • WS82xx Neopixel LED strip
  • Raspberry Pi board
  • SD card
  • Power Supplies (for pi and LED strip)
  • Glue gun and sticks
  • Soldering Iron
  • Wires and general prototyping tools

The base design

Sticking neopixel strip to popsicle sticks were as easy as peeling of the tape or if your strip doesn’t have that glue gun can always help:

Now comes the most scary part, soldering it all together. they way WS82xx LED strips work is by daisy chaining, i.e output of one LED (DOUT) goes to input of next LED (DIN) so need to be very careful with the direction, follow the arrow marking on silk screen of the LED strip. Also my LEDs are 5v, they also comes in 12v flavour so make sure to double check before buying, LED D+ and GND also needs to be soldered together. I attached a small pc of general purpose PCB and used it as terminals for +5v and GND as shown below:


Uploading: IMG_6624.jpeg…

1 Like

Not to lie, it was hard to route all those wires, a multimeter came in handy checking for continuity, If I have to do it again and calmly I’ll rather use Neopixel Sticks and 3D printed brackets to make the Star v2.0

connecting strip to the Pi

The next step is to connect this star to my Raspberry Pi board and now there are a few ways to do that, some are more safer than others, but I decided to live on the edge and try the most easier way connecting Vin of strip to 5V output of Raspberry Pi and GND to GND, though this is not the recommended method as if LEDs are shining too bright for elongated times it can damage the raspberry pi board which are not meant to supply out high current as can be demanded by the LED strip. But I am always going to be using them at 10-20% brightness, I choose to do this way and save some more circuit complexity though I recommend everyone making this project to take short term pain for long term gain and connect the strip using methods recommended in this guide:

The other thing to keep in mind is that these neopixel LEDs works on 1-wire protocol which is highly time sensitive and since raspberry pi running linux is not a real time operating system to make the strip work we rely on something called DMA or direct memory access controller, this offloads the processor and we can get almost real time like timings to make these LEDs work, hence we need to connect to pin board.D18 of the Pi which supports DMA operation. Secondly Pi GPIOs are 3v3 compatible while neopixel’s is 5v, so in some cases you might also need to add a logic level shifter :

  • Ideal way of connecting [ using a leval shifter ]
    image

  • hacky way of connecting [ using a diode ]
    image

  • with external power supply [ for strip current needs ]
    image

  • Legends [ don’t try this at home w/o supervision :stuck_out_tongue: ]
    image

Refer this guide for more …

Using adafruit library examples and an arduino board, I gave a quick sanity test to the strip and it worked, some connections needs to be re-done but it all worked out in the end . then did the same with pi

  • Libraries used :
    sudo pip3 install rpi_ws281x adafruit-circuitpython-neopixel
    sudo python3 -m pip install --force-reinstall adafruit-blinka and it worked xD

IoTizing it

Well, now comes the tricky part, I am okayish with soldering and using glue guns but not at all with JS and CSS, but I needed a frontend to control my new shiny star.

Enter adafruitIO : which allows you to create b’full dashboards and control your edge device. You can send data to/from edge device from/to adafruitIO. So if you wanna plot a sensor reading or if you wanna add few buttons on a web browser which can blink LEDs on your boards adafruitIO is a good platform and it’s free to use.

The communication happens over REST api or my fav MQTT. it’s secured using your personal account key and username. The details on how to do that will follow in an upcoming blog but here’s some steps to summarize:

1- create account on adafruitIO
2- create a new dashboard
3- add widgets and link them with feeds
4- copy API key, username and feedname and add it to balena device variables
5- you’re good to go

Here’s a great getting started with adafruit IO guide .

I used Python library on raspberry pi to communicate with adafruitIO using MQTT.


t

Here’s the sample application I created → https://github.com/iayanpahwa/holiday-star.

You can clone it and deploy using balena push or use deploy with balena

deploy button

Don’t forget to add following device variables after adding devices to the fleet:

Name Value
NUM_PIXELS total number of LEDs in the strip (default 60)
BRIGHTNESS between 0 and 1 (default 0.3)
ADAFRUIT_IO_KEY Obtain from adafruitIO account
ADAFRUIT_IO_USERNAME username of your adafruitIO account
FEED_ID name of the feed you created on adafruitIO

That’s all for this project, do share in ShowNTell category if you build a holiday themed project or use adafruitIO with balena. If you have any questions, feedbacks or ideas, I’d love to hear that.

also feel free to modify and contribute to this project. @mpous already has a great idea of using new Connector V2 block alongside and make star blinks whenever someone mentions him on twitter :wink:

More Photos:

Video : combined my ble-beacon project with this one

https://youtu.be/j4VxgesdVes