Introduction: Automatic Coffee Notification System

About: I like to build cool stuff

In this project I make an office coffee maker smart, by building a coffee alert system that sends Slack notifications when someone brews a fresh pot of coffee. The code could be changed to send an email, or text message. This project is built on a Raspberry Pi Zero-W

To do this I’m going to need to continuously monitor the temperature of the coffee machine. I went with the DS18B20 waterproof temperature sensor and a Raspberry Pi Zero-W.

If you like this project please follow me on Instagram and YouTube.

Links

Code & Wiring Diagram: https://github.com/calebbrewer/pi-coffee-ready

Adafruit's Raspberry Pi & DS18B20 Temperature Sensor Guide: https://cdn-learn.adafruit.com/downloads/pdf/adafr...

Parts (Some Affiliate Links)

Mini Solderless Prototype Breadboard: https://amzn.to/2Toevid

Male to female jumper wires: https://amzn.to/2Ft0RaE

DS18B20 Digital Temp Sensor from Adafruit: https://amzn.to/2RZv81W

Digital Temp Sensor on eBay (The one I used): https://rover.ebay.com/rover/1/711-53200-19255-0/1...

Raspberry Pi Zero W Kit: https://amzn.to/2DxGuWV

Raspberry Pi Zero W from Adafruit ($10 shipping): http://amzn.to/2fHrQzo

I had the LED laying around.

The single gang box and piping came from Lowes

Step 1: The Circuit

This circuit is supper simple. I built mine on a mini breadboard so I didn't have to solder (I was just learning at the time). I did however solder some jumper wires onto the wires coming off the DS18B20, so it could be plugged into the breadboard. You don't have to do it this way, and everything could be easily soldered together (See my Duel Internet of Things Thermometer video).

Take a look at the diagram.

Basically, you just run a jumper wire from pin 5 to the yellow wire on the DS18B20, ground to the ground wire (black), and 3.3V to the red wire. Then, add a 4.7K resistor between 3.3V and the yellow wire (signal) on the sensor

For more info you should checkout Adafruit's Raspberry Pi & DS18B20 Temperature Sensor Guide

Step 2: Setting Up the Pi & Getting a Temperature Reading

After installing Raspbian (I have a Gist & a video for that) on the Pi Zero W, you will need to SSH Into the Pi and run dtoverlay=w1-gpio to enable the temperature probes interface. Then reboot by running sudo reboot. After SSHing back into the Pi you can run the following to get a temperature reading.

  • sudo modprobe w1-gpio
  • sudo modprobe w1-therm
  • cd /sys/bus/w1/devices ls cd 28-xxxx (change this to match what serial numberpops up)
  • cat w1_slave

Note: to SSH in Windows you may need to use Putty.

Step 3: Connecting to the Coffee Maker & Calibrating

To hook the temperature probe to the coffee maker I used metal heating duct tape, and attached it right behind the boiler. The coffee maker we have at the office is an old Bun with a nice metal back that conducts the heat well. You will have to find a good place to put the probe on your coffee maker. The DS18B20 temperature sensor is water proof, so you have options.

Once the probe is attached, you will need to monitor the temperature while brewing, and see what temp it hits when brewing, as well as when it's brewed. You may have to play with the positioning of the sensor to find a place that give you a large enough temp difference between the normal temp, and the brewed temp.

To get your temp numbers, you can log the temperature to the console by running the commands from the "Setting Up the Pi & Getting a Temperature Reading" step.

Note: you only need to run all of the commands once, then just run the "cat w1_slave" command to view the newest temp reading.

Step 4: The Code

Here is a link to the code: https://github.com/calebbrewer/pi-coffee-ready/blo... It is written in JavaScript (nodejs)

At the top there are a few constants you can change to get it working for your setup.

  • const brewingTemp = 88; (This is the lowest temp while brewing. The LED light on the front will blink when this temp is hit)
  • const brewedTemp = 93; (When this temp is reached we know that the coffee is ready)
  • const brewOffset = 45 * 60000; (This is the time to wait before checking again. Change the 45 to the number of minutes you want to wait for the coffee maker to cool down)
  • const filePath = '/sys/bus/w1/devices/28-031702a501ff/w1_slave'; (This is the path to the file with temp reading. Yours will be different from mine. Use the file you found by running the commands in the "Setting Up the Pi & Getting a Temperature Reading" step.)
  • const slackMessage = { "username": "Coffee Bot", "text": "There's fresh coffee! Get it while it's good."}
  • const slackHook = ""; (Your Slack hook)

This code is based around sending a Slack notification, but line 75 is where I actually send the message. You could modify this to send a notification with whatever service you like.

If you want to know how to set up a Slack hook for sending messages, see this doc: https://api.slack.com/incoming-webhooks

To add your code to the Pi, just use the scp command to copy the index.js and package.json files to the Pi. For example: scp index.js pi@pi-ip-address:/var/pi-coffee-ready

Step 5: Node & Starting the Code at Boot With PM2

To run the code you will need to install nodejs by doing the following:

To run the code when the Pi boots up I used pm2. While sshed into the Pi run:

  • npm install pm2 -g
  • pm2 start app.js

After this the script will start when the Pi boots.

Step 6: Making It Look Cool

I grabbed an outlet box to hold the components, and some metal 1/2 inch pipe from a home improvement store. I put it together so that the pip would be a stand for the box. I then the painted it red and white.

I created a graphic for the front of the box and used a vinyl cutter to cut it out. I drilled a hole for the indicator LED, then attached the vinyl to the box cover.

I covered the back of the Pi in electrical tape so the contacts on the back wouldn't short out in the metal box. I then attached the Pi to one side of the box with carpet tape. I attached the mini breadboard to the other side using the included adhesive backing.

The wires run nicely through the pipe and out of the T fitting. Please excuse the paint run. I got into a bit of a hurry.

Step 7: All Done

And just like that, you have a coffee alert system that looks awesome!

If you like this project please follow me on Instagram and YouTube.