Thursday, March 12, 2015

Displaying tweets using Processing + Arduino + LCD

Now that I have my Arduino LCD cooked up, I needed a quick and easy project to expand my LCD horizons. I thought to myself, "Self! let display some tweets on the LCD. Should be easy." Boy was I wrong. Follow me on  my quest for knowledge as I try to display some tweets on an LCD.

I had heard about Processing before, however I had not tinkered with it yet. The IDE looks a lot like the Arduino IDE. I am not much of a details guy so I just started searching how to integrate processing with Arduino. SparkFun has a great article on how to use Processing to write to the serial port and use Arduino to read from the serial port.

After some looking around I found this Twitter Client written in processing. Now I just had to put it all together. The getSearchTweets and getTimeline functions in the Twitter client were written to print out data to the console. I tweaked the functions to return strings so I could pass that along to the serial port. Here is my final Twitter Client Processing Script.

I took the SparkFun Arduino code and had to tweak it a bit to read the buffer from the Serail Port and then display the buffer on the LCD. Threw in some delays and had a working LCD twitter display.

Couple issues I noticed. The serial buffer has some weird characters and the word wrapping is a little wonky. I need to figure out how to print the serial buffer without the crazy characters and such. I setup a delay to clear the LCD on arduino. This could be done differently for sure. Right now I grab a tweet every 60 seconds and then display it on the LCD for 20 seconds. This is just test mode stuff and should be a little smarter to see if we have a new tweet, etc.