Category Archives: alamode

Preparing for à la mode: Raspberry Pi and Arduino

Well, I got my Raspberry Pi, and preparations are well underway to make an Arduino compatible clone that fits right on top.

Anool Mahidaria has completed an initial circuit design, and I’ve gotten some of the software set up. Lots of information out there that helped me figure out what to do, so I thought I’d compile it here in one place.

à la mode will connect via the uart on the GPIO, so we need to figure out how to enable serial communications, and get the Arduino environment installed.

Serial port: An embarrassment of riches?

The Pi’s Broadcom brain has a very rich set of peripherals, unfortunately it was hard for the Pi’s designers to route them all out to a connector. There’s a limited functionality min-uart that is very well supported, and at least in the debian image I’ve tried has drivers.

It doesn’t have hardware handshaking or DTR (needed for auto reset on the Arduino) but is supported at this stage so I think that’s what we’ll go with. There’s also a fully featured UART, and most of it’s compatible pins are brought out to the GPIO connector, but as far as I can tell, it’s not fully supported in the distributions generally available for the Pi.

The GPIO connector is well documented on the Pi’s wiki:

But I found this blog post most helpful: http://lavalink.com/2012/03/raspberry-pi-serial-interfacing/ from which I get this useful illustration.

That’s great, but it turns out that the Serial port is a little too well supported. (Caveat, I’m talking about the recommended Debian Squeeze image) You can log into it as a console! This, of course, prevents you from opening the port in a program (such as Arduino), so we need to disable logins on this port, as well as logging messages that go out. This post explains how to disable both.

I’ll repeat the instructions here, in case the link goes away:

First, disable logging messages:

Edit /boot/cmdline.txt

From:

[code]dwc_otg.lpm_enable=0 rpitestmode=1 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait[/code]

to:

[code]dwc_otg.lpm_enable=0 rpitestmode=1 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait[/code]

deleting the two parameters involving the serial port /dev/ttyAM0

You also have to edit /etc/innitab to remove the login (getty)

comment out:

[code]2:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100[/code]

then reboot.

Arduino IDE:

The Homelabs raspberry pi blog has good concise instructions for installing the Arduino IDE. The IDE is written in Java (based on Processing) and while Oracle doesn’t have an official Java for the ARM core in the Pi, the Open JDK has been ported. It doesn’t have a JIT (Just In Time Compiler) so it’s a little slower, but it works.

First grab the Arduino IDE code. (you can change the url if you want the latest)

[code]wget http://arduino.googlecode.com/files/arduino-1.0-linux64.tgz
tar zxvf arduino-1.0-linux64.tgz[/code]

The Arduino IDE is written in Java, but there are native parts to do compilation for the atmega328p  microcontroller. Fortunately those have also been ported:

[code]
sudo apt-get install avr-libc
sudo apt-get install libftdi1
sudo apt-get install avrdude

[/code]
Java:

[code]sudo apt-get install openjdk-6-jre[/code]

Serial support:
[code]sudo apt-get install librxtx-java[/code]

And then copy the native stuff into the Arduino directory:

[code]
cd arduino-1.0
for i in $(find . -name “librxtxSerial.so”) ; do cp /usr/lib/jni/librxtxSerial.so $i ; done
for i in $(find . -name “RXTXcomm.jar”) ; do cp /usr/share/java/RXTXcomm.jar $i ; done
cp /usr/bin/avrdude /home/pi/arduino-1.0/hardware/tools/avrdude
cp /etc/avrdude.conf /home/pi/arduino-1.0/hardware/tools/avrdude.conf

[/code]

After this, you can attach an Arduino to one of the USB ports, or (carefully) a 3.3 v clone to the GPIO pins.

More to come!

 

 

Raspbery Pi à la mode ?

Lot’s of people are excited about the Raspberry Pi®, a complete computer for $25 (or $35 with ethernet).
The initial shipment is entirely sold out, and there are 200,000 more on order. Lots of people have been saying that this is the end of the Arduino, as it’s about the same cost, a full linux system with keyboard, mouse, and hdmi video output.

I think this is an oversimplification. Arduino is fantastic at interfacing to the physical world in a way that no linux (or Windows) PC could hope to approach at any cost.

The Pi does have a GPIO connector, but it pales in comparison to the humble Arduino. No built in PWM (servos anyone?) and no Analog to digital conversion.

Why throw the baby out with the bathwater? How about some delicious ice cream with your Raspberry Pi?
As a member of the amazing Open Source Hardare collective Wyolum.com,  I’m working with Justin Shaw and  Anool Mahidharia on “à la mode”: an Arduino clone specifically for the Raspberry Pi (That rendering above is courtesy of our  fabulous  EE  Anool) . You can of course connect an Arduino to a Pi USB port, but when you want a turnkey solution, how about an Arduino compatible “plate” (what the Pi folks call shields) that fits right on top of the Raspberry Pi.

You can plug your existing shields right in,  and you can even run the Arduino IDE on the Pi. Since the Pi’s core mission is to provide equal access to computing to all children, this will also give the kids the opportunity to mix it up “Arduino-style” with real world hardware.

We couldn’t have a vanilla add-on, so we added:

  • A battery backed real time clock: RTC: DS3231 (same as ChronoDot)
  • uSD card for logging
  • Socketed Atmel Atmega 328p in case you make a wiring mistake and need to replace it.

We’re sending off for prototype boards soon, so if you have feedback, let us know! Join the conversation at the Wyolum.com forums.

Raspberry Pi® is a trademark of the Raspberry Pi Foundation.