Spider-Man twitter monitor

Spiderman twitter monitor

I was recently chatting to a friend who was telling me how he was going to use a unicorn hat to make a nightlight that changed colour for his kids. I have had a long love of all things blinky and especially those which come from Pimorini so it got me thinking about my own similar project using the blinkt.

I looked on thingiverse.com for a suitable size case and came across a lovely little spiderman lamp housing which I thought would be perfect for this project.

I decided that rather than making a simple lamp which came on and off I wanted to do something that would use the WIFI capability of the PiZero W and then used the colour of the Blinkt to display real world information back to me.

Some of my ideas were:

  • Weather monitor which changed colour from blue to red depending on the outside temperature
  • Weather monitor which changed colour when its was sunny and wet
  • A news scraper that changed colour when a braking news items came onto the BBC News site
  • A twitter feed that changed colour if I got a mention / RT

In the end I went for the last option. I liked the idea of using the Spider-Man logo to represent the spidey senses of spiderman which would tingle when I got a RT/mention.

The coding of the Blinkt was really easy as the libraries and documentation from Pimoroni are very clear and easy to follow.

I tried the twitter example code and after generating key codes etc for a new Twitter app I could not get it to work. All I would get was 401 errors everytime the code was run. I did a little bit of digging and discovered that this was quite a common occurrence so had to look for a different approach to how I was going to search twitter.

I settled on
twython and installed the libraries.

It was fairly simple to generate the relevant key codes and I was able to read the last tweet that I was mentioned in (or a RT)

I then wanted a simple way of changing the colour in response to this.

I decided that I would use the time stamp of the last tweet mentioning me as the trigger for any notifications.

When the script starts up the time stamp of the last tweet is saved to a file. After a certain amount of time the new time stamp is obtained and compared to the time stamp on file. If it is the same - no new tweets have been discovered and the script checks again in another 30 seconds. If the date stamp is different it triggers an event, updates the date stamp in the file and changes the light to green.

I was initially quite pleased with the effect but eventually decided to change the way the colour is displayed. By varying the brightness of the Blinkt I made the light gradually fade over 30 seconds for a red light and 5 minutes for the green light. This would give me an indication of how long ago the tweet had been received and removed any need for human interaction. I didn’t want to add any physical buttons to the device.

Overall I am really pleased with this project. I did find it quite hard to fit the PiZero W and the Blinkt into the case. In the end I had to directly solder the wires onto the GPIO holes on the Pi and poke the other ends into the female connector on the Blinkt.


Case attribution: SPIDERMAN LED Light / Nightlight by jjpowelly

I have removed my sensitive code from the example below, you will need to generate your own Twitter key codes etc.