Saturday, 20 June 2015

Putting things together

After parking the Robot Arm on top of a bookcase for several months, I've decided to see if I can make something a bit more complex (and useable).

In addition to the Arduino, I also have a Raspberry Pi and the Windows 7 Laptop I use to create this blog so I thought it might be a good idea to put all these together. Now, I don't really need to use the Raspberry Pi for this particular project, but it's small, hardly draws any power and there's an increasing amount of community support for robotics.

So, Step 1, connect the Pi to the PC

Note I've installed Raspbian onto my particular Pi. To begin with, I want to connect via VNC. There are plenty of instructions on the web for setting up a VNC server. Instructions like these should be sufficient

I installed UltraVNC Viewer on the laptop which is a useful free viewer with very unobtrusive advertising.

PuTTY is also a useful tool to have installed as you can use this to connect to the Raspberry Pi from the command line. Especially handy to check what went wrong with configuring VNC.

It's important you don't use the default login credentials of User: pi, Password: raspberry, so change it using the command passwd from the command line

Step 2, Setup Wifi for the Pi

I didn't want to have to connect my Raspberry Pi to the PC everytime I use it, so I bought a cheap and low power USB Wifi dongle.
There's a lot of information about how to setup Wifi on the web. This is what I did.

Edit the /etc/network/interfaces file (I use nano for this)
auto lo
iface lo inet loopback

# Ethernet
iface eth0 inet dhcp

allow-hotplug wlan0
auto wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface default inet dhcp


Create a new /etc/wpa_supplicant/wpa_supplicant.conf file
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
ssid=”YourWifi”
scan_ssid=1
proto=WPA
kep_mgmt=WPA-PSK
pairwise=TKIP
group=TKIP
pas=”password”
}

Restart the Pi to setup the connection.

Obviously setup the connection information as per your own circumstances. One thing I did do was setup a static IP address for the Pi on my router. This did save quite a bit of pain getting DHCP working.

Step 3, Connect the Pi to the Arduino
The Arduino client software is installed using sudo apt-get install arduino

The default setting wasn't compatible with my Arduino board. When I tried to upload a sketch to the board I got this wonderfully informative message:

error: avrdude stk500_getsync() not in sync resp=0x00

The fix was to set the Board from the Tools -> Board menu to Arduino Diecimila or Duemilanove w/ ATmega168 on Serial Port /dev/ttyUSB0

I then uploaded the Blink sketch to the Arduino to prove it worked.

Finally, I connected using a powered USB hub to confirm that worked as well. The images below show both the direct Raspberry Pi to Arduino and USB hub connection.

The latter will be useful in future as this will help minimise power consumption issues.



No comments:

Post a Comment