Pi in the sky ideas Archive

Arduino on the Pi

pi_logoplus ArduinoLogo

What a combination. High level Raspberry Pi gui with processing power and Arduino hardware smarts.

Now. How do we make it all work together.

I started with a Raspberry Pi model B 512

I brought an 8MHz 3.3v Arduino ATmega328 with boot loader Complete kit (Check the drop down menu under options) This is a diy clone of the Arduino Uno.

I built the kit on some prototype board. Very simple build.

(Pictures on the way)

The hardware connection from the RPi to the Arduino clone is simple.  Supply the clone with 5v to the Vin pin, 0v to one of the ground pins. Hook a wire up from the Arduino RX pin (D0) to RPi GPIO08 and Arduino TX pin(D1) to RPi GPIO10

Also connect a 0v line from the Rpi (GPIO6) to the Arduino clone Gnd connector.

That’s the hardware. Now for some software setup.

The linux distribution I’m using is the 2012-10-28-wheezy-raspbian available here.

You will need to be root to do most of this. You can either use the sudo command. eg. ‘sudo nano /boot/command.txt’ to edit the command.txt file, or you can become root by entering ‘sudo su’.

This will make you root until you enter exit or reboot the pi.

First. You will need to edit the /boot/command.txt

This is the unedited line from the standard installation.

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

We need to remove any serial port information and make it look like this :-

dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

Edit the last line in /etc/init.tab. Add a # symbol in front of the last line

#TO:32:respawn:/sbin/getty -L ttyAMA0 115200 vt100

This will free up the serial port for our use.

Next , add the pi user to the dialout group.

usermod -a -G dialout

Last you need to add a link to the correct serial port because the Arduino environment does not recognise AMA0 as a serial port.

Create a new file

touch /etc/init.d/link_serial

Edit the file and enter the following text

#!/bin/bash

ln -s /dev/ttyAMA0 /dev/ttyS1

Save the file now.  Enter the following command to make the file executable.

CHMOD 755 /etc/init.d/link_serial

Now we need to make sure the file is executed every time the Pi boots.

update-rc.d link_serial defaults

You will get a warning

insserv: warning: script ‘link_serial’ missing LSB tags and overrides

This is not a problem.

To install the Arduino software environment enter the following command.

sudo apt-get install arduino

Reboot you Pi now.

You should now be able to program your Arduino clone via the serial GPIO pins on the Raspberry Pi.

You need to hold the reset button down until the program starts to download. Then release it as it starts. This takes a little practice…..

 

HDMI-vga cable hack

I brought an HDMI to vga cable from ebay.
This one in fact :- ebay hdmi-vga cable

To open the box I used a small scalpel to get between the two pieces of plastic in the middle of the join near the vga plug. I just eased the blade into the join and levered it apart. The cover is held on with a snap in connector along the edge of the pop out panel. Once the panel is off, just feed the HDMI cable into the strain relief rubber bung and the board should edge its way out of the box.

IMAG0275

IMAG0276IMAG0277

Its quite difficult to explain exactly how to get into this device but I hope the pictures give you and idea of what’s inside and how to approach it.

This cable is un-powered. It draws it’s power from the HDMI signal source, in this case the Raspberry Pi. This causes to much current draw though the diode on the board and will destroy  the diode over time.

To overcome this problem I opened the box and removed the power lead running from the HDMI plug to the board. I needed to carefully peel the hot melt glue off of the cable terminations and the board to access the solder pads.

DMIN_to_vga_hack

Then I added a fly lead to the 5 volt input for the board, and another to a ground point and bought these out thought a small hole in the case. I added a cable tie for a little strain relief.  Snip off the end of the old power lead to stop shorts inside the case.  Snap the front of the case back on and you are good to go.

IMAG0274

We now have a powered HDMI to vga cable adaptor. Fit the flying leads with a connector of your choice and connect to a 5 volt source. This could be a usb connector if you have a free socket on your hub or 0.1″ pin header if you are creating your own board or working with a bread board in your project.

Hope this is of use to somebody.

The Disclaimer – Upon opening the Product you have voided your warranty and the unit is now in your hands, no returns…

Secondly and even more important – you do the hacks/mods at your own risk, I am not responsible for damage to you, your equipment, or anything else within a 100 mile radius that may be directly or indirectly levelled, incinerated or otherwise obliterated to the ground (or neighbouring country) by your degree of skill (or lack of) with electronics, test equipment, soldering irons or hot coffee (not all necessarily used at the same time.)