Cubesicle Code: GitRepo
This is the code for my recent studio project Cubesicle, an internet-connected cube that functions both as furniture and as part of a creative partitioning system. Visit www.cubesicle.com to learn about the process and concept.
There are two elements to the existing code… it may still need to be cleaned up a bit but the basics are here.
This was basically a mashed up version of some code meant to push data to Cosm (formally Pachube) but it has been repurposed a bit. I'm working on an OAuth version that will allow a user to create a session so that you don't have to store your gmail info in the actual Arduino code. Right now you have to pass that information through to the php script.
There's also some funkiness in the code… an infinite while loop keeps the wifly module from disconnecting once the buffer fills up. This needs to happen in order for it to stay connected long enough to read a character being returned by the php script. There may be other ways around this but for now this is what works. Thanks to Leif for figuring out this hack. The current switch triggers different LED behaviors but you could do anything with this.
Make sure the correct Wifi information is added to the credentials.h file. You can ignore the Pachube API key information, it's not being used.
This IMAP code is practically given to you by Google… i've added a few things and most importantly created a stupid-simple "memory" for it to check it's history. The php script checks your gmail for the unread count. It then compares it to a number in the text file. If the unread number exceeds the number in the text file, it updates the text file and returns a parseable character that's easily read by the arduino. If the count is the same as the text file, nothing happens and a different character is returned.
This was originally being used by an unmoderated gmail account and so these are pretty much the only possible outcomes. If for some reason the gmail count is lower than in the text file (due to moderation), it resets the count at the actual total. Hope this makes sense. It caps out at a count of 72 or 73 and then stops working. It wasn't an issue for me so I didn't rewrite that piece of the script. I'm new to php so it's probably still a bit crude.