Skip to content

NUSTEM-UK/IoTrees

Repository files navigation

Internet of Trees

Whatever the 'Next Big Thing' is, there's apparently going to be an Internet Of them. We think at least some of the Things should be trees -- Christmas trees. With sparkly lights.

This code drives coloured lights from a Twitter stream. It's a ghastly hack, but in initial testing it mostly works. It's also our first Python code, so, you know, be gentle.

Project Story

You can read up on the project in detail at the Think Physics website. The following is more of a developers/hackers guide for anyone wishing to replicate the tree, or something like it.

Hardware

To replicate Think Physics' IoTree, you'll need:

  1. A tree. We built this design from Makedo on Instructables. Makedo is a terrific cardboard construction system with which you can quickly lash together big structures. We love it.
  2. A Raspberry Pi. We used a Pi2 backed onto a Pi touchscreen, in a Pimoroni stand, which all fitted neatly into the side of the Makedo Tree base. The Pi needs to be on a network; we used a WiFi dongle, since plugging things into our university network is frowned upon.
  3. A Pimoroni Unicorn HAT, which is a nifty 8x8 array of individually-addressable RGB LEDs.

Software

Requires:

  • Unicorn HAT Python bindings: \curl -sS get.pimoroni.com/unicornhat | bash, if you're trusting; see here if you'd like more information before piping a URL straight to shell.
  • Python Twitter Tools. Once installed, follow these instructions to acquire the necessary Twitter OAuth keys for the username use wish to follow.

This code was copy-pasted together from examples and a bunch of StackExchange answers, with most of the "development" time spent with me trying to wrap my head around how to cast lists to string or integer. I've never written any Python before; pull requests which present better ways of doing things seen here are welcome!

Configuration

Set username (line 34) to the Twitter handle your keys authenticate against. Tweets to this user will be processed.

Usage

  1. Tweet the target user with a hex colour code (as used in CSS): @username #8a9a2a will set the Unicorn HAT to the bright variant of Think Physics' theme green. The full 24-bit range #000000 to #FFFFFF is available, though we can't speak to the colour accuracy of the LEDs. They're probably fairly terrible.
  2. Tweet the target user with a Kelvin colour temperature: @username 3400K will set the Unicorn HAT to a warm orange-white. The available range is 1000-15000K.

At present, the code outputs diagnostics to STDOUT only. Stub code (from the Twitter Tools example) remains in place to tweet an acknowledgement in reply.

Kelvin temperature

We're a physical sciences outreach project, so there had to be some physics in here somewhere. If only to justify the time investment. We'll write this up properly in a blog post, so for the moment:

Future development

We plan two things:

  1. Integration with a Pi Camera module to take tree selfies and post them in response to input tweets.

  2. Modification to replace the tree with a diffusing orb, and instrumentation so users can select a star temperature and have the orb glow the appropriate colour. Though colour conversion and perception are thorny subjects: see "What colour is the Sun?" for an example.

We're quite likely to hack something together for Maker Faire UK in April 2016. Look for us there!

About

Drive a Raspberry PI Unicorn HAT from a Twitter stream

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages