Introduction: Treelegram - Hack a Christmas Tree Lights From Anywhere in the World!

About: New Technologies Enthusiast & Passionate MAKER - Trying to learn everyday something new

Hello all,

after some years registered on Instructables, and never published any tutorial, the time has come!

So, here I am, ready to share my last project, called Treelegram.

Treelegram is a Social Christmas Tree that lets you Hack its Lights from anywhere in the world on real time. You can take Photos or Videos on real time to check it out! It is meant to be a social experiment of sorts, demonstrating the use of Telegram Bots for physically interactive projects.

Treelegram is simple to use: You just need to install the Telegram application and search for it, as any contact.

It´s simple and very intuitive. You should be prompted with a custom keyboard to let you start "Hacking Christmas". So simple as you´ll have a remote control on your own hands :-)

Step 1: How Is It Made? Materials List

The project idea came when I discovered a few months ago the announcement of Telegram bots.

At that time I was looking for some research based on Internet Of Things projects and so on.

I´ve already done some projects based on Twitter API, but once I looked over the possibilities of Telegram Bots, I was totally impressed! It was just amazing! Custom keyboards are awesome!

So, after some research and testing on the Telegram Bot API for Python, the project idea was born!

Treelegram is based on RaspberryPi and Arduino.

Above there is a quick "design sketch" showing how idea was conformed.

There´s nothing better than writing it down before starting coding. - Don´t you think so? :P -

Below listed the materials you may need if you want to setup your own:

1x RaspberryPi

1x Arduino UNO

1x RaspberryPi NoIR Camera

1x RGB LED Strip + IR Key Controller

1x 12V DC +2 Amp Power Source

1x NPN Transistor

1x 470 Ohm Resistor

1x IR LED

1x IR Receiver (TSOP38238)

1x USB Cable

1x Protoboard

1x Wires

The project consists of 3 distinguishable parts. So let´s go to explain them!

Step 2: Reverse Engineering: Decoding IR Codes From IR Key Remote

The first idea to control the RGB LED Strip lights was based on Arduino.

Attaching directly the strip to the analog outputs and start coding a way to make differents patterns. I was performing it...when I realized that already got a device that came with the RGB LED Strip that sent the different colour patterns.

It has an IR Receiver attached that receives the different IR codes sent by the IR Key Remote controller.

So, How about using it? YES! Reverse Engineering!

I mounted an small circuit on a protoboard to decode the different codes from the IR Key Remote controller.

Once I got them, it was easy to setup an Arduino Sketch and circuit to make my own IR Controller.

The Raspberry Pi will send via serial a number that will be read by Arduino and send the IR Code accordingly. Every number represents one of the keys of the IR Key Remote.

You can follow the Adafruit Tutorial about Receiving and Sending IR to setup yours too. It´s too easy!

Attached the sketch to upload into your Arduino.

Step 3: Treelegram Bot: Just a Python Script Running on Raspberry Pi

Ok, so as I described at first page. Once I discovered Telegram Bots, I fell in love with them. The possibilities they let you to play with are huge.

So first of all you should read and understand how Telegram Bots works:

  1. Bots: An introduction for developers
  2. What can I do with bots?
  3. How do bots work?

And last but not least, the most important steps for this project:

  1. How do I create a bot?
  2. BotFather

If you have been a good boy,and you have read the links above, you should know now what is the TOKEN, able to understand what is used for and why it´s so important.

Please create your own Telegram Bot Authorization TOKEN with the help of BotFather! You NEED IT for this project too or to make your own!

I Love Python

Yes, I love to code Python. It´s simple and easy to use. That´s why I looked on Internet for a Python library that uses Telegram Bot API. And guess what? YES, I found one on Github!

Its name is python-telegram-bot and is up to date. You can use all the Telegram Bot API Methods.

If you want to run my Treelegram Bot Script, you need to follow the below steps:

Install library into your Raspberry OS(I use Raspbian)

Insert YOUR Telegram Bot Authorization TOKEN into the following line:

bot = telegram.Bot('INSERT HERE YOUR TELEGRAM BOT AUTHORIZATION TOKEN')

And you´ll be ready to run the whole project!

You just need to:

  1. Connect our DIY Arduino IR Remote to RaspberryPi via USB cable.
  2. Place RGB LED Strip around your Christmas Tree and connect their end to the IR Control Box.
  3. Connect IR Control Box to Power Source.
  4. Turn on Raspberry Pi with an Ethernet or Wi-Fi Internet connection.
  5. Place DIY Arduino IR Remote pointing at the IR Receiver on the IR Control Box (Distance can be up to 6 meters!)

Now, you should be able to run the Treelegram python Script. (I recomment to use linux Screen command)

Once you have created a new Window with Screen and placed at the path that contains the script, you can execute it with the command:

python treelegram_rx_v4.py

Then your own version of Treelegram starts to Run! You should now search for your Telegram Bot name and start playing!

Step 4: Treelegram: a Christmas Tree Telegram Bot That Lets You Hack Its Lights at Your Own

Once python script is executed, you should be able to search into your Telegram application for the name of your bot.

Search for it as you´ll be looking for any contact. It should appear and tap over its name to start the chat and fun with it!

In this case, I´ll show a quick demo of my own version:

Treelegram(You can search for it too and try it!)

Check the screenshots for details!

Hope you like it and be ready to start creating your own Bots! May the force be with your Clones! :-P

Please don´t forget to share your comments or any improvements you could make into code!

Please, rate my Treelegram bot with 5 Stars if you liked it! -> https://storebot.me/bot/treelegrambot

You can check and follow its own Facebook page to be updated and receive any news! -> https://www.facebook.com/TreelegramBot


HAPPY HACKING XMAS TREE LIGHTS!