The Google Trends Powered Christmas Tree

by 8BitsAndAByte in Circuits > Raspberry Pi

1676 Views, 4 Favorites, 0 Comments

The Google Trends Powered Christmas Tree

15.png

Want to know how trendy Christmas is? Find out with this Google trends powered Christmas tree! Party mode included.

Supplies

- Raspberry Pi 3b+

- 8x Adafruit NeoPixel

- Button

- USB Speaker

- Wiring

- Soldering Equipment

- Pipe Cleaner

- 3D Printer

- Glue

Project Video

The Trending Tree - A Google Trends powered Christmas tree

Lights - 3D Print

00.png
01.png
02.png

The first step is to create a container for each light.


We've 3D designed some gift boxes (see above) and printed them with transparent filament. This filament is perfect because it diffuses the light perfectly and gives off the perfect holiday vibe.

We printed eight of them, but you can create as many as you need.

The STL file is attached to this step.

Lights - Hardware

03.png
04.png

With the containers printed, we can move on to the electronics.

We're using Adafruit Neopixels as lights. These are very bright, support a lot of colors and have great documentation.

They are not quite ready to use out of the box, we still need to solder the necessary wires.
Depending on the amount of lights this can take some time, a perfect moment for some coffee.

It's important to not connect them to each other just yet, we first need to put them in their gift boxes.

Hardware - Assembly

05.png
06.png
07.png
08.png
09.png
14.png

Now both our containers and lights are ready for assembly.

We've left some holes in the lid of each box, these we can use the loop through a led (see above).
Once all the boxes and light are completed we can solder them to each other to create a light string

Connect your light string to the Raspberry Pi and you can test out the lights.

Once we checked that everything works, we can glue the boxes and the lids together.

Wrapping some colorful pipe cleaner around the wire between each gift box adds some extra jolliness.

Google Trends Connection

11.png

To give this tree some extra oempf, we're going to connect it to Google Trends.

The full code is included in the last step "Part Mode", but to give you an overview, we've used Python with some extra packages:

  • PyTrends to fetch the data from Google Trends
  • Neopixel to control the NeoPixels

And the logic is as followed:

  • Every hour, fetch the popularity of the search term 'Christmas'
  • We get back a number between 0 (not popular) and 100 (popular)
  • The speed of the lights is calculated based on this number

This results in our tree changing color quickly if the search term is popular, and slowly when it's not popular.

A small note, we used different threads (ledControlThread and trendDataThread) to make sure that each action doesn't hinder the other.

For example, the lights keep going while we fetch the Google Trends data, without threading he would wait for the API call to finished and only then continue.

Party Mode!

12.png
13.png
pic.png

Because a Christmas tree is a bit of a year long thing, a party mode is a necessity.

This extra feature will need some extra hardware, to be precise, a button and USB speaker.

Once attached to the Pi you can start looking for a fitting song, we chose for "Complicate ya" by Otis McDonald.
We also need to add some logic to our existing script:

  • Check if button is pushed
  • If so, play the audio filed specified and make the lights change color super fast.
  • Once audio is done, return to normal

This logic has its own thread, just like the others and the full script is also attached to this step.

All that's left to do is hang everything in a tree, and enjoy the jolly data visualization, and most importantly the party mode!

Downloads