Whenever I get a like on a tweet of mine that is < 7 days old, I get treated to a notification from wavy tube guy. It's a delight. ✨
Watch in real-time on twitch to see your like
on twitter trigger wavy guy!
Untitled.mp4
- Blowup wavy guy toy
- 9V 2A 2.1mm barrel jack DC adapter
- MQTT Broker:
- Raspberry Pi 4
- Twitter Developer Account (for the necessary API tokens)
- MQTT Client:
Note: I chose the Feather Huzzah & Raspberry Pi 4 for this product since I already had them and reused them from previous art projects. There are many ways to approach a project like this, but this made sense for me with the materials I already had available.
I have a raspberry pi 4 running a small node.js app. I use pm2
to run this on the pi: node index.js
. This file (index.js
) creates a small local express server to create a MQTT Broker (using Aedes) and sends a request to the twitter API using my Bearer token as authentication (so I can poll up to 450 times every 15 minutes) every 3 seconds to grab my most recent 100 tweets from the past 7 days.
This specific criteria is due to limitations of the twitter API and what data I can retrieve using the API... I can't retrieve my total like count as a user directly) and calculate the total number of likes on them.
The MQTT broker allows clients to subscribe to topics. In this case, the arduino is subscribed to receive messages about tweet likes. When the app retrieves and calculates the tweet count and determines it has increased, the app then publishes a message to subscribed clients.
When the arduino receives this message, it sends a digital write of HIGH
for 2 seconds to the non-latching relay.
This triggers the latch to move to the closed position, therefore connecting the power supply and turning on the wavy guy for 2 seconds.
Note: I choose to use MQTT because I know how it works pretty well (I've used it in previous projects) and it works really well and was just a great solution since I was re-using the feather huzzah here and keep the board footprint on the wavy guy really small.