Want to build this project?
View Parts

 

I finally got a got a chance a couple weeks ago to experiment with my Alamode from Wyolum.  It's an Arduino-compatible board with an ATMega328 that sits on top of the Raspberry Pi.  It has has headers for Arduino shields and also features a real-time clock and microSD card reader:

20121129_003716.jpg

The setup for the Alamode on the Pi is pretty simple when following Wyolum's Getting started guide.  Essentially, you'll need to install the Arduino package via apt and then download and run the Alamode setup script.  The setup script disables the system console on the Pi's serial port in /etc/inittab.  The Pi's serial port is instead used to upload sketches onto the Alamode's ATMega328 and also used for communication (such as with the Arduino IDE's serial monitor).

 

I don't typically have my Pi hooked up to a display, but instead log into it remotely from my laptop via ssh to work on my projects in the shell.  It turned out to be simple to be able to display the Arduino IDE (running on the Pi) on my laptop.  My laptop is running Linux (Ubuntu 12.04), so I just had to edit /etc/ssh/ssh_config to uncomment ForwardX11Trusted and ensure it was set to yes:

 

Host *
#  ForwardAgent no
#  ForwardX11 no
ForwardX11Trusted yes
#  RhostsRSAAuthentication no
#  RSAAuthentication yes
<snip>


 

This allows the GUI applications running on the Pi to be displayed on my laptop and controlled by the laptop's keyboard and mouse.  I then just have to log into the Pi via ssh with the "-X" to enable X11 (e.g. XWindows) forwarding:

 

afustini@lappy486:~$ ssh -X pi@192.168.1.245

 

After logging in, I simply type "arduino" at the shell prompt, hit enter, and the Arduino IDE appears on my laptop:

arduino.png

The Arduino IDE works as usual and there is an entry in Tools->Board for the AlaMode (which uploads the sketch via the Pi's serial port):

arduino_alamode.png

Last year I bought an Adafruit 2.8" TFT LCD touchscreen shield but never really found a project for it.  I've been working a lot with the Pi lately and have wanted a small LCD that could display crisp text and graphics (unlike "fuzzier" composite-input LCDs).  The Alamode presented me with the opportunity to use the TFT Arduino shield, but this time with the power of a Linux behind it thanks to the Pi.

 

My previous project displayed tweets on a character LCD connected to a Pi, so I figured I would try to adapt it for the Pi, Alamode & TFT shield sandwich:

20121202_031332.jpg

To start off, I went through Adafruit's 2.8" TFT shield tutorial to download all the necessary Arduino libraries onto the Pi and run the example sketches to get a handle on what the TFT shield can do.  I then started changing their graphicstest.pde example to see what text size I liked as I wanted to be sure I could fit the Twittter max of 140 characters.  The TFT library will automatically wrap the cursor around to the next line so you only have to be concerned about when the screen is full.  Here's the bulk of the main loop:

 

 

It waits for characters over the serial port from the Pi and then just writes them to the display.  If there is a newline (\n), then the screen will be cleared and the cursor moved to the top left.  The Python script running on the Pi writes the tweets to the serial port with a newline at the end of each tweet.  Here's the full tftweet sketch:

 

https://github.com/pdp7/tweetypi/blob/master/tftweet/tftweet.ino

 

The Python script that I mentioned is based on the HashTagDisplay class from my earlier character LCD project but without more complicated character LCD display logic.  This is the gist of how tweets are written to the serial port:

 

 

The full alatweet.py script is located here:

 

https://github.com/pdp7/tweetypi/blob/master/alatweet.py

 

And here's a video of it all in action displaying tweets for hashtag #raspberrypi:

 

 

 

Cheers,

Drew

http://twitter.com/pdp7

 

(note: this is a not an entry for the Double Your Memory Challenge)


 

 

element14
Product Name*DescriptionBuy All PartsBuy All Parts
Raspberry Pi Model B with SD CardRaspberry Pi Model B with SD CardRaspberry Pi model B and 8GB SD Card with NOOBS preinstalled
Optical MouseOptical MouseBasic USB optical mouse
Raspberry Pi Power SupplyRaspberry Pi Power Supply120-240v to 5V power supply with micro USB connector
KeyboardKeyboardBasic USB keyboard
Adafruit Touchscreen shieldAdafruit Touchscreen shield2.8” TFT LCD touchscreen shield for Arduino
Additional Parts
Product Name*Description
AlaMode expansion boardArduino compatible expansion board for Raspberry Pi

 

*Products and resources listed are listed to help members build their own Pi Projects. They are suggestions and listed for educational purposes. For substitutions of any parts, please post a question asking the original author.