Introduction: Tweet-a-Pot: Twitter Enabled Coffee Pot

Like the idea of making coffee on the fly? from your bed? While you're on the bus coming home? Then the Tweet-a-pot is for you!

Tweet-a-pot is the next in fancy twitter enabled devices. This coffee pot enables its owner to make a pot of coffee from anywhere they have cell phone reception, using twitter and an arduino board.

The tweet-a-pot is the easy implementation for remote device control! with a bit of code and some hardware, you can have your very own twitter enabled coffee pot.

Take a look at this quick video, Special thanks to Sam:

Step 1: Supplies

To make your very own tweet-a-pot you will need the following

1 Power Switch Tail, this is basically a relay that is used to interface with the AC voltage
1 Arduino Board (any will do)
1 Computer running the arduino IDE and Python
1 Drip Coffee Pot

Step 2: Setting Up Your Computer

First you need to set up your receiving computer.

To interface between the arduino and twitter, we are going to use python. There is a library that is already put together that enables us to use the twitter API. It's called python-twitter.

After you have installed python, install the python-twitter library and all its dependencies. If you run into trouble just consult the documentation over on the python-twitter website.

Next, install the Arduino IDE so you can program your arduino and talk to it via serial port.

Once those are set up and working, time to go grab your credentials from twitter.com

Step 3: Setting Up Twitter

Interfacing with twitter used to be easy, all you had to do was put your name and password into your code and it would work. Now twitter has taken user info more seriously using oAuth, and as a result now you must register your app with twitter and get an API key.

First, make a twitter account for this project that is separate from your main twitter account. I chose, driptwit. 

Then, go to dev.twitter.com and register your app, this will enable you to grab 4 important pieces of information

-Access Token
-Access Token Secret
-Consumer Key
-Consumer Secret

These keys will be needed in the python code later to interface with the twitter API. After you have those 4 codes, you should be able to continue.

Step 4: The Code: Python Side

First lets go over our python code. The python code basically uses the python-twitter library to ask twitter for the statuses of user "x", it then takes the last status and searches for the term "#driptwit".
if found sends the ascii value of 1 to the serial port (and to the arduino), if #driptwitstop is found, it sends an ascii value of 0.
Lastly it loops and checks the twitter account every 15 seconds looking for changes.

As you can see, below is where you enter the keys you got from twitter in the last step.

Here is the actual code:

#******************************************#
# Tweet-a-Pot by Gregg Horton 2011 #
# Please email changes or #
# updates to greggahorton@gmail.com #
# *****************************************#

##Import Libraries

import twitter
import serial
import time

##authenticate yourself with twitter
api = twitter.Api(consumer_key='consumerkeyhere', consumer_secret='consumersecrethere', access_token_key='accesskey', access_token_secret='accesssecret')

##set to your serial port
ser = serial.Serial('/dev/ttyUSB0', 19200)

## check serial port
def checkokay():
ser.flushInput()
time.sleep(3)
line=ser.readline()
time.sleep(3)

if line == ' ':
line=ser.readline()
print 'here'
## Welcome message
print 'Welcome To Drip Twit!'
print 'Making Coffee..'
def driptwit():
status = [ ]
x = 0

status = api.GetUserTimeline('X') ##grab latest statuses

checkIt = [s.text for s in status] ##put status in an array

drip = checkIt[0].split() ##split first tweet into words

## check for match and write to serial if match
if drip[0] == '#driptwit':
print 'Tweet Recieved, Making Coffee'
ser.write('1')
elif drip[0] == '#driptwitstop': ##break if done
ser.write('0')
print 'stopped, awaiting instructions.'
else:
ser.write('0')
print 'Awaiting Tweet'

while 1:
driptwit() ## call driptwit function
time.sleep(15) ## sleep for 15 seconds to avoid rate limiting

Step 5: The Code: Arduino Side

The only connection between the python code and arduino is a single serial value. Python sends this as an ascii value, so arduino interprets this as a bit number, in our case 1= 49.

I didn't know how to make python spit out serial bytes, so after seeing what the python code was sending, i just modified the arduino code to react to the right value.

Here is the code:

/*
Tweet-a-pot Gregg Horton 2011
Please email changes to greggawatt@instructables.com so i
can improve this code!

Enables blinking/relay control over twitter, using python code
Based off of Blink and Serial demo code

*/

int relayPin = 13; // LED connected to digital pin 13
int incomingByte = 0; //declare incoming byte
// The setup() method runs once, when the sketch starts

void setup() {
// initialize the digital pin as an output:
pinMode(relayPin, OUTPUT);
Serial.begin(19200); // set up Serial library at 19200 bps

Serial.println("Arduino is ready!");
}

// the loop() method runs over and over again,
// as long as the Arduino has power

void loop()
{
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
Serial.println(incomingByte);
if (incomingByte == 49){
digitalWrite(relayPin, HIGH);
} else {
digitalWrite(relayPin, LOW);
}

// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
}

Step 6: Hardware Setup

The hardware set up is pretty simple, as the AC voltage control is being handled by the power switch tail

The power switch tail allows you to hook up 2 wires, one to ground and one to the control pin, to turn on and off the relay. As seen in the code, all you need is a simple high/low statement.

Connect the arduino to your computer and make sure your serial port is set, then plug the power switch tail leads into pin 13 and ground

Next connect the coffee pot to the relay and plug the relay into a regular outlet. Its that easy!

The coffee maker has to have coffee and water in it as well before you begin.

Step 7: Make Some Coffee

I did a lot of testing before hooking this up to an actual coffee pot (and even then found some bugs), but once you get it working, its time to make coffee!

Fill the pot with water and coffee grounds, and tweet to the account the code is following.

If the message contains the word #driptwit the coffee will start, if it receives #driptwitstop, or you tweet something else it will stop.

Once the pot of coffee is done, tweet again to turn it off. Its that easy!

Then enjoy your hot piping cup of tweet coffee.

Step 8: Final Thoughts

This project can be extended to any AC device that you want to control remotely. You could turn on lights or open garage doors with the same concepts

The code is not perfect, any improvements that people give me i will gladly include and test out. A large improvement on this project would be to integrate an ethernet shield so you wouldn't have to have a dedicated computer.

I want to give special thanks to the team the developed the python-twitter library, without them this project would be much harder.



Comments

author
mbenguelamine90 made it!(author)2017-06-02

Its a very nice Idea... lovely

author
balkan+ku%C5%9Fcu made it!(author)2017-04-24

ı want to ask somethink, the output of the power switch going to the coffee machine, but you cannot tell from the photo attached where the input ends

author
IshaanJ3 made it!(author)2016-12-06

how can we make it without using power tail as I live in India and here it is not available

author
T0BY made it!(author)2016-12-03

Lovely idea!

author
MattY18 made it!(author)2016-01-30

New to the Arduino world. Having trouble uploading the code to the Arduino board. Also where do I input the Access Tokens and Consumer Key?

author
Jonathanrjpereira made it!(author)2016-01-29

I featured this Instructable in one of my collections:https://www.instructables.com/id/8-Twittering-Thingamajigs/ along with many other Twitter Powered Instructables. I can't wait to make my own Twitter Enabled Coffee Pot.

author

is it still working , please answer if u know :)

author
jperdomohn made it!(author)2015-06-09

I will try this out , cause was the first thing that came to my mind when knowing about arduino for the first time...it is great somebody else did it already!!

author
RobertGoldring made it!(author)2014-08-20

great design, could a raspberry pi work as the receiving computer?

author
AmitS17 made it!(author)2015-04-04

Thats what I am currently making.

I am using Raspberry Pi 2 instead of laptop and according to me it definetely would.

author
iamm99 made it!(author)2015-04-26

cant u just just rapsberry Pi 2? do u need arduino here?

author
eddierome made it!(author)2014-11-27

Hummm? Can the Arduino IDE run in Linux(Raspberry Pi). That is a good question.

author
AmitS17 made it!(author)2015-04-04

There is Arduino IDE available for raspberry pi.(Raspian)

To get it use command sudo apt-get install arduino

author
BertugBerkay made it!(author)2015-04-12

Is it still working ? I ve heard that twitter changed some policy or something.

author
ThomasL3 made it!(author)2015-03-21

How do I program the part that adds water and coffee?

author
sakibmuhammad.anwar made it!(author)2015-03-20

Made it :D

author
escaleraalcielo made it!(author)2014-12-06

It's working!!!

Greetings from Mexico

Captura de pantalla (12).pngCaptura de pantalla (13).pngCaptura de pantalla (14).pngCaptura de pantalla (15).pngCaptura de pantalla (16).png
author
jamesbrosuk made it!(author)2015-02-09

well done, very impressive

author
escaleraalcielo made it!(author)2014-12-06

To connect to the serial port i use this code instead of the suggested one because allows to search in more than one serial port :D

##set to your serial port

#to use with linux locations = ['/dev/ttyACM0', '/dev/ttyACM1', '/dev/ttyACM2']

locations = ['COM3','COM4','COM5','COM6'] #to use with windows

for device in locations:

try:

ser = serial.Serial(device, baudrate=9600, bytesize=8,

parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE)

print ("\nArduino found on: " + ser.portstr + " please wait...\n")

time.sleep(2)

break

except:

print "Failed to connect on", device

author
escaleraalcielo made it!(author)2014-12-06

To register a new app you must go to the next link https://apps.twitter.com/

Because dev.twitter send you to download fabric, the new Builder from twitter

author
davidbarcomb made it!(author)2014-11-20

Great idea. Thanks for sharing us

author
tanish.kotyankar made it!(author)2014-11-12

This is an amazing idea, but I was wondering that the requirement of a Laptop to be present doesn't make it as portable so what if we use a wifi shield to connect to the Arduino. I saw this in a different project that scanned twitter for particular phrases. Would we have to change the programming or will it remain the same. I am a curious Engineering Student and wanted to learn about this. Would appreciate your help.

author
luketyrel made it!(author)2014-11-10

This is a really cool idea. Just wondering do you sell this device with out the coffee machine. I'm looking to buy a working version or pay a developer to create one with a simple laptop and AC switch.

Thanks

Luke

author
FranciscoC made it!(author)2014-09-10

Great tutorial, how can anyone activate the Coffee by sending a tweet? Is this possible to do in this example or similar?

author
danmellow made it!(author)2014-08-28

wow this can be used for something bigger may be

author
LadySith made it!(author)2013-10-14

I always come back to this page. Loved the idea since I saw it. We were planning on doing it for our space but we can't find a relay switch anywhere. Is there any way we can effectively mutilate a regular power supply to work as a relay switch?

author
ChrisW3 made it!(author)2014-08-23

I know it is a bit late but did you try Radio Shack? Also Jameco (online or catalog) has a really good selection of loads of different things. Good luck to you!

author
KarateLover21 made it!(author)2011-01-09

where did you get the serial module

author
jarrodramsey made it!(author)2014-06-25

Be sure to run the install command with sudo.

author
Mitch11011 made it!(author)2011-06-27

Ya I am having the same problem. I tried downloading a serial module from here http://pypi.python.org/pypi/pyserial but when I run the program I get an error.


author
KarateLover21 made it!(author)2011-06-28

yeah that module didn't work for me either.

author
HomuraRun made it!(author)2012-10-22

I keep getting "Index Error: list index out of range". What does that mean?

author
jarrodramsey made it!(author)2014-06-25

This is due to you not having any tweets. Post a dummy tweet and problem solved.

author
firater made it!(author)2013-10-06

I also get that error. Could you find any solutions?

author
jdawgaz made it!(author)2014-04-13

I am not sure why there is an arduino at all here. This could be done more simply by just using one of the gpio pins on the rpi.

even the original powerswitch tail only draws 40ma and 3.3v dc is good enough to switch the relay: well within the rpi tolerance.

this would eliminate the need for the serial library. and all of it could be done with just the python program.

author
jarrodramsey made it!(author)2014-06-25

The tutorial is for Arduino, not rpi. It's very useful exercise for going Arduino training.

author
mist42nz made it!(author)2013-12-09

What functionality is the Arduino providing in this circuit? It looks redundant, the output signal could be used to drive relay on the tail in a similar manner to how computer tills used to be activated by the serial port. The laptop is providing all the controller "decisions"

author
manoellemos made it!(author)2013-11-22

Hi, I'm writing a blog post about cool home automation Arduino based projects and your's is going to be there. Do you allow me to use one or two of your pictures in the post? I'm linking the reference to tweet-a-pot back to this page.

author
animedubbedonline made it!(author)2013-09-09

nice one

author
Kelly02 made it!(author)2013-06-26

nice idea.

author
pnoytech made it!(author)2013-04-24

Activating my arduino projects thru twitter is awesome! Thank you so much!

author
contactscolored made it!(author)2013-04-04

Nice Instructable!

There are some really good things for people to learn here. (from your instructions, especially)

author
ProbioticSoundsystem made it!(author)2013-03-08

very cool

author
ShadowJesus made it!(author)2013-02-13

This is a fairly simple arduino project.

author
JensonBut made it!(author)2013-01-25

I am fairly new to Instructables so I will have to take a look at putting it together. I definitely want to get a video up. I'll let you know when I get either up. (I tried replying but the captcha thing seems messed up)

author
tcerier made it!(author)2012-11-20

Hi, I'm following this, and i'm having some issues. it would be great if someone could help me.

-first: when running, does the arduino need to be connected via a serial cable? or can one use the usb cable?

-Also, (my main problem) i recieve a serial error... what could this be?
thanks!
tcerier

author
beverageexpert made it!(author)2011-02-05

for my twitter app these are the only keys I received
# Consumer key
*****************************
# Consumer secret
***************************************
# Request token URL
http://twitter.com/oauth/request_token
# Access token URL
http://twitter.com/oauth/access_token
# Authorize URL
http://twitter.com/oauth/authorize

so what would I use for
access_token_key='accesskey', access_token_secret='accesssecret')

thanks

author
anderspeterson made it!(author)2012-11-12

there should be a button that says "Show me my access token...(etc).

author
pdxnat made it!(author)2011-06-14

I've got an instructable here detailing the process of getting your tokens. Like everything, it's simple once you know how....

https://www.instructables.com/id/Simple-Tweet-Arduino-Processing-Twitter/step4/Twitter/

author
MattDurr made it!(author)2011-02-09

The access_key and access_secret keys need to be generated separately and are unique to each user and twitter application.

After searching the python twitter library, I was having trouble finding how this library generates these keys. So sorry I don't think I can help you there.

But another similar python library I found for twitter called Tweepy does have lots of documentation!

And a nice example of how to get started!

check it out - http://jeffmiller.github.com/2010/05/31/twitter-from-the-command-line-in-python-using-oauth

About This Instructable

240,716views

305favorites

License:

Bio: I'm a full stack web developer focusing on security and privacy.
More by frenzy:Cómo hacer una placa iluminada con teclas de un tecladoUna funda para tu dispositivo, hecha de un traje de buceoDead Drop inalámbrico
Add instructable to: