For more in depth theory, please see the next step entitled Theory.
See the results of the toots of your on labor on Twitter.
Step 1: Theory
Therefore, it is of the utmost importance, to be able to update Twitter with life events without actually interfering with the event themselves. The documentation of life, henceforth, needs to be automated.
That said, I decided the first part of life that needed to be documented was my daily flatulence at work. I am not going to lie, I am a gassy individual. Since my flatulence is a part of life, it would be fraudulent of me to document life as it happens without documenting these occurrences.
In keeping with the process of non-interference in daily activity, I have created an office chair to both detect and Twitter my flatulence without having to bother me to update it myself.
Step 2: Go get stuff
- Office chair
- Squidbee TX/RX pair
- 1/8" piece of acrylic
- 50K trimpot
- Natural gas sensor
- Solid hookup wire
- Soldering setup
- Laser cutter (or saw and drill)
- Razor blade
- Screwdriver set
- Drill
- Nuts and bolts (or screws)
- Pliers
- A staple gun
- Python
- A Twitter account
Step 3: Make a sensor mount
Did I mention how awesome Epilog laser cutters are?
Anyhow... If, unlike us at Instructables, you do not have a laser cutter, you can download the file and print it to paper. Cut out the circular outline from the sheet of paper and tape this to your acrylic as a guide. Where necessary, drill holes through the acrylic using a power drill and cut around the outline with a jigsaw (or similar).
Step 4: Attach the sensor
When the components are inserted, solder them in place. You may want to first cut off any extra leads that may confuse you.
See the datasheet here.
Step 5: Plug it in
Step 6: Program the Squidbee
First things first, unplug the Xbee shield from the Arduino (the part of the Squidbee the sensor is plugged into). Also, change the power jumper from battery to USB power.
Next, plug the Arduino into your USB port.
Open the Arduino programmer.
Set the Serial port (usually looks like /dev/tty.usbserial-A70048pF). Write down the serial port address for future reference.
Download, open and hit the "play" button to compile the code (download below). Upload the code to your Arduino.
Unplug the Arduino from your computer. Switch the jumper back to battery power and put the Xbee shield back on.
TwitChairCode.zip635 bytesStep 7: Connect to the computer
You can see the incoming stream of data by watching the serial monitor in the Arduino interface on your computer.
Step 8: Python
If you are using a Mac with a recent version of OS X, you should have Python already.
Open the Terminal, type into the command prompt "python" and hit "enter."
This should open up Python.
To see Python do its thing type:
print 'hello world' (and hit Enter)
This will return "Hello World" in the prompt.
To quit Python hit "control-D".
If you don't have Python, you can go download it here and install it by following the instructions listed.
Step 9: Dependencies
The first thing you need is the setuptools shell script. Open terminal and change your working directory to the directory setuptools is in. You can change directories by typing "cd nameofdirectory" and hitting "enter". and you can look at what directories are in your current location by typing in "ls" and hitting "enter".
Once you are in the correct directory, install the shell script by typing chmod setuptools.egg (or whatever the exact name of the file is. Do not rename the file). This may require entering your administrator password. Do so when prompted and hit "enter".
You should now be able to use Easy Install, which, happens to be one of the greatest pieces of code ever written. Once you have Easy Install you just need to type into the command prompt "easy_install" followed by the name of the package you are trying to download and hit "enter." For example, "easy_install greatcode" (not a real example). Next thing you know, you have downloaded and installed the whole "greatcode" package for use in your own code.
Open your prompt and type each line below and hit enter. This will install the Simple Json, Twitter, Time and advanced Math (numpy) packages.
easy_install simplejson
easy_install pyserial
easy_instally numpy
easy_instally time
Download and install Python Twitter by following the directions on the page (you might even just try "easy_install twitter").
Step 10: Code
That said, some helpful things I learned about Python include:
One of Python's greatest features (or possibly the worst?) is its lack of syntax. You rarely need to remember a closing or opening tag. You can just keep typing out lines of code and Python will try its best to process it.
Python processes blocks of code based on their indentation. Improper indentation can result in catastrophe. For instance, the only way the code knows that something is part of a for loop is because it is indented the same as everything else that is also part of that loop. This can start to get tricky with nested loops (loops inside of loops) and lead to confusion and bad code.
Python's function system is confusing on a number of levels (for instance some variables are mutable and some not). I don't fully understand the complexities of functions, but if you are interested, you should definitely look it up.
The code we are going to use includes a number of packages, a collection of functions that can be invoked at will (see last step for more information about installing packages).
We are importing the following packages:
- Python Twitter
- PySerial
- Numpy
- Time
- Random
The code is as follows:
#!/usr/bin/python #Filename: TwitterChair.pyimport twitterimport serialimport numpyimport timeimport random## Your username and password here#api = twitter.Api(username='yourusername', password='yourpassword')## Change this to match your serial port#ser = serial.Serial('/dev/tty.usbserial-A70063pF', 19200)serialArray = []global gassygassy = 0def checkokay(): ser.flushInput() time.sleep(3) line=ser.readline() time.sleep(3) if line == ' ': line=ser.readline() print 'here'def startvalues(i): while i <= 50: #time.sleep(.25) line=ser.readline() serialArray.append(int(line)) ser.flushInput() i=i+1 print serialArraycheckokay()startvalues(0)def main(i, i1): ArrayTransfer = numpy.array(i) ComparatorValue = int(numpy.mean(ArrayTransfer)) print ComparatorValue lastReading = ComparatorValue print lastReading loopy = i1 print loopy y = 0 x = 0 while y < 10: while x < 5: line=ser.readline() currentReading = int(line) if currentReading > lastReading: lastReading = currentReading print lastReading print currentReading time.sleep(6) ser.flushInput() x=x+1 print 'half minute' x=0 y=y+1 if lastReading > (ComparatorValue + 50): i1 = 1 if i1 == 1: sayings = ["He farted again with success and vigor. Woest me.", "Pfffffffffft", "Ugh. That was a gross one", "Someone please disassemble me", "If I could puke my foam stuffing, I would", "I wish I were some other chair", "He farted right on me again", "Didn't hear that coming", "allow me to repeat... ppppfffffffffftttttttttttt", "It wasn't always like this."] pickSaying = random.randint(0,9) print pickSaying status = api.PostUpdate(sayings[pickSaying]) loopy = 0 print 'done' if __name__ == "__main__": main(serialArray, loopy)main(serialArray, gassy)
TwitterChair.py1 KBStep 11: Disassemble the chair
Remove the seat from the chair assembly and undo the upholstery until you can access the foam in the area in which you marked.
Step 12: Undo the upholstery
Remove the staples from the back side of the seat such that you can pull up a little of the fabric.
Step 13: Modify the cushion
Step 14: Insert the sensor
Step 15: Reassemble
Step 16: Bottoms up
I chose to attach mine using hot glue. You can also use things like nuts and bolts.
This may require first emptying the case.
Step 17: Turn it on
Plug the receiver into the computer.
Step 18: Run the code
If you didn't download the python file yet from the "code" step, download it from this step!
TwitterChair.py1 KB









































































Visit Our Store »
Go Pro Today »




sammy jr - never heard of that company but can recommend http://www.margolisfurniture.co.uk/office_storage
Of course if I was to sit on that chair you'd never hear a tweet out of me all day
;-)
where can we follow that chair??
actually I am looking for a Chair (that's how I laned on this page), does anyone know this company?
www.chworkspace.co.uk/
Can you help me find some kind of way to make it detect when i sit, stand, and how much weight is put upon it?
http://www.instructables.com/member/plusea
Thanks again
Would be BA if it could tell what you ate..
When you spin it could say "I'm getting reeeeaaaally dizzy" and when you sit on it it could say "God he's so fat" (no offense and I'm not saying you are fat)
While it's not so critical here, it is good electronics hygiene.
Maybe a mesh office chair like one here: http://www.intercounty.com could make linking the whole thing up to a human easier?