IoT Hackathon - Coffeebot with Raspberry Pi
For our latest Hackathon, with the theme being the Internet of things (IoT), my team and I wanted to create a device that would encourage people in the office to keep the coffee pots full of life-giving nectar. Often the pots don't get refilled when someone takes the last cup of coffee, so we decided to gamify the process. The basic idea was to award points to people when they made fresh pots of coffee, and whoever made the most coffee each week would get a shoutout at the company all-hands meeting. We realised that we could also add extra features such as alerting people when fresh coffee was available, or being able to remotely check how full the coffee canisters were.
Since everyone in the company uses Slack, we decided that this would be a good interface for the device, so that we could minimize the amount of hardware needed and make using Coffeebot as easy as possible. This would allow us to identify users by their Slack handle, check the leaderboard, and announce fresh pots easily. We set up a Coffeebot user in Slack and started working on the code. On the hardware side, we decided to use a Raspberry Pi, as this allowed for easy integration with Slack and gave us plenty of inputs to attach the components we needed.
The initial version of Coffeebot had three hardware components integrated into the Pi: a button to be pressed when a user makes a pot of coffee, a screen to give the user instructions and feedback, and an RFID reader to identify users.
The button is nothing fancy, just a nice big button that invites users to press it. It is simply wired up to one of the Pi's GPIO pins, and starts the process of awarding a user a point when they make a pot of coffee.
The screen is a standard 1602 display, with a Metal Toad orange backlight. We connected it in 4-bit mode (8-bit mode would have required more wires, and would not have offered us much in the way of benefits) and used the RPLCD library to control it. This made it very easy to give the user instructions, and also told us Coffeebot's IP address on startup, which made it simple to log in remotely and run it headlessly.
Initially, Coffeebot worked by generating a random number and asking users to send it back through Slack for verification, so that it would know who should get credit for making coffee. This worked, but was a bit of a hassle for users. We decided to use our office RFID fobs to let users identify themselves. Unfortunately, we didn't know much about the specifics of our fobs, and the two types of readers we tried (125 kHz and 13.56 MHz) did not work with them. Undeterred, we ordered some RFID tag stickers that were compatible with one of our readers. These can be stuck to our office tags, or whatever else is convenient for users (eg their phone).
To prevent people from claiming coffee brewing credit when they didn't actually brew coffee, we thought about how we could detect a real brewing event. We thought about using flow meters connected to the brewer, but this also supplies hot water for tea, so the fraud detection could be bypassed easily. The other main component, the grinder, seemed like it could be measured in some way too. We tried using a piezo vibration sensor. This provides an analogue signal when it moves, so we hooked it up to an ADC to connect it to the Pi. Unfortunately, we found that the signal level when the coffee was being ground was very low, so we couldn't rely on this. Our next attempt will be to use a current sensor around the grinder's power cable that should tell us when the grinder has been activated.
We bought some load cells and the necessary signal amplifiers and cut some wooden boards to act as scales for the coffee canisters. This would tell us how much coffee was in each pot, and allow users to ask Coffeebot through Slack how much coffee there was. We'd also like to have little graphical displays in the Coffeebot housing showing this info. We didn't find a great source of info on how to wire the weight sensors up, so we didn't get reliable results from them, but will keep at it and work out how to get a good reading from them.
For aesthetic purposes, we'd like to make a nicer looking enclosure for Coffeebot — perhaps a custom 3D printed box. Also, the RPLCD library makes it easy to show custom characters on the display, so we would like it to show the Metal Toad logo.