Tweeting Images

Screen Shot 2014-03-25 at 09.11.58

 

Originally I was going to use a LinkSprite JPEG Camera to add in pictures. Using the Arduino 1.0.4 IDE I was able to capture images to the SD card using Adafruit’s wonderful library (it didn’t work with 1.0.5, unsure why). The plan was to take the snapshot to the SD card reader on the Arduino’s ethernet board and then delete it when it had been used.

Sadly now we are using Processing to do Twitter posting and connecting to the Arduino with Firmata using an external library is out. If I was really desperate to use the Arduino for this I could set up a serial link to Processing rather than using Firmata but trying to send the file from the SD card over serial whilst viable is certainly overcomplicating matters.

So, as a result, my code still isn’t touch the Arduino’s sensors yet, sorry! Rather I am using a webcam and the saveFrame() function to save an image. This is attached to the tweet using Twitter4j and then deleted after uploading is complete.

Here is the extra code used to take the photo and add it into the tweet (camera instantiation not included):

saveFrame(“/your/datapath/image.jpg”);
delay(2000); //time to save
File file = new File(“/your/datapath/image.jpg”);
status.setMedia(file);
twitter.updateStatus(status); //update the status with the above string
println(“Successfully updated the status to [” + status + “].”);
file.delete();