The WunderYoPinball project is my contribution for The Great Wunderbar Holiday Challenge 2014.
At my company, we have a pinball machine which I play regularly. It's a 2 minute walk from my workplace to the pinball machine, and it happens quite often that I walk to the machine to find out someone else is already playing pinball.
What a waste of time... Couldn't the WunderBar help me out here?
Of course it can: WunderYoPinball helps me and my colleagues with managing an online waiting list for the pinball machine. Powered by the WunderBar and Yo!
TL;DR
The project is easy to explain: WunderYoPinball uses the WunderBar's proximity sensor to detect if someone is currently playing the company's pinball machine.
When the pinball machine becomes available/free again, it sends out a "Yo" message to the first person on the waiting list. To enlist yourself for the pinball waiting list, just install the Yo app and send a "Yo" to your pinball machine's Yo API account.
Don't know Yo? Yo Developers can make use of the Yo API to send a "Yo" to followers and run callbacks when receiving a "Yo".
So, from the user's point of view, the flow is as follows:
- user sends a "Yo" to the pinball machine's Yo account to get on the waiting list;
- when the pinball machine becomes available, the user receives a "Yo" from the pinball machine's Yo account
Ingredients and initial setup
For this project, I've used:
For those who don't know the Raspberry Pi: it's a $30 micro computer, which can run a Linux-based OS and has a very low power-usage of around 2 watt. You can install node.js on it and then use the relayr npm-package to read data from your WunderBar-sensors using JavaScript.
Doesn't that sound great? Get a Pi!
In addition, I used the following web services:
- an Azure Mobile Service which exposes a WaitingList REST service to enqueue and dequeue usernames in the waiting list;
- a Yo API account with a callback, which pushes the user to the WaitingList when someone sends it a "Yo";
When the data indicates the pinball machine is available/free for at least a minute, it pops the first person from the WaitingList, sends out a "Yo" message to that person and sleeps for three minutes before repeating it's loop.
We need the sleeping period to allow the selected person to receive the "Yo" and walk to the pinball machine, before the next user on the waiting list is selected.
Of course you can use any other object instead of a pinball machine (e.g. an Xbox or a PlayStation); as long as you can detect if someone is nearby by using one of the WunderBar sensors.
Photos
Solution
- WunderBar's proximity sensor picks up that some is playing the pinball machine, because the sensor is placed next to the arcade button on the side of the machine. The proximity sensor sends data (using BLE) to the WunderBar's main module, which has a WiFi connection to the Internet and sends the data to relayr's Open Sensor Cloud platform.
- A node.js script on a Raspberry Pi - also connected to the Internet - is reading the data from the proximity sensor. When sensor indicates no nearby objects for a couple of minutes, the scripts decides that the pinball machine is available again. It now dequeues a user from the waiting list and sends this user a "Yo" message by using the Yo api (I've used the yohoho npm package for this).
After sending a "Yo", the script sleeps for a couple of minutes, allowing the selected person to pick up the "Yo" alert and walk to the pinball machine, before the next user on the waiting list is selected.
Current status
This project is currently being fine-tuned. The WunderBar's proximity sensor is already placed on the pinball machine and is sending out data to relayr's Open Sensor Cloud. The code for the node.js script (running on a RasberryPi) and the api's for the WaitingList (running as Azure Mobile Service) are available as open source.
Source code
The code is available on my github account: https://github.com/dionoid/wunder-yo-pinball. Note that the node.js script depends on the npm packages "request", "relayr" and "yohoho" and needs the "npm install
" command before running.
Thoughts and Todo's
- WunderBar's light/prox sensor currently flashes a bright white led when your hand comes close, which is needed for better color detection. However for this project we don't need color detection, so the bright flashing led only annoys the pinball player and drowns battery more quickly. Luckily, the relayr team has made a firmware-update for the light/prox sensor that disables the flashing white led. Works like a charm!
- I'd like to make a special version of this project for the Xbox/PlayStation so that people are encouraged to play a game together (e.g. soccer).
- Thanks to the IoT special-interest-group at Macaw (my employer) for brainstorming about cool ideas. Special thanks to Michael!
Happy Christmas to you all!
P.S.
The pinball machine seems to have a "quiet mode", which means it doesn't make any sound when no one is playing the machine. This makes WunderBar's sound sensor also a valid option to detect if someone is currently playing a game of pinball.
I just did some tests with the sound sensor - sticked to the bottom speaker of the pinball machine - which gave me excellent results. >
Comments