Tweet-a-Pot: Twitter Enabled Coffee Pot

Like the idea of making coffee pot 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.

Coffee Pot

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

[mom_video id=’_Y-F9Zdk_qM’]

Step 1: Supplies

Supplies

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

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

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

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

 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

 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

 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

Make Some Coffee         

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

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.

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

0/5 (0 Reviews)

About The Author

Hassan Zaka

I am an expert in accounting and possess diverse experience in technical writing. I have written for various industries on topics such as finance, business, and technology. My writing style is clear and simple, and I utilize infographics and diagrams to make my writing more engaging. I can be a valuable asset to any organization in need of technical writing services.

Follow Us:
LinkedinTwitter
Home Automation >> Custom Home Automation Projects >> Arduino >> Tweet-a-Pot: Twitter Enabled Coffee Pot

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top