Tag Archives: GPIO

IMU Sensor Installation

Since a week ago, I ‘ve been looking into my new IMU: Inertial Measurement Unit.

I bought  from e-bay a MPU6050, a sensor including:

  • a gyroscope that can return the angular speed around the 3  axis x,y,z.
  • an accelerometer  that can return the linear acceleration along the 3  axis x,y,z.

This sensor can communicate trou I2C interface.

Below the electrical drawing:

wiring_IMUIMU_conn

 

 

 

 

 

 

 

For the sw installation I fuond a clear tutorial on the Adafruit website ,so I just report here a memo for the necessary steps:

in sudo nano /etc/modules add:

  • i2c-bcm2708
  • i2c-dev

sudo apt-get install python-smbus

sudo apt-get install i2c-tools

in sudo nano /etc/modprobe.d/raspi-blacklist.conf comment:

  • #blacklist spi-bcm2708
  • #blacklist i2c-bcm2708

Now ,running the command sudo i2cdetect -y 1  yuo have to see the address 0x68, corresponding to the default sensor address.

SW Installation

Hello, today I inaugurate the english version of my blog.

As soon as I can I’ll translate also the static pages.

By the way, consider that this project is based on raspberry pi (rev B) for the motion control of the quadcopter.

Here there is a description of the necessary sw installation.

I’m using a laptop with ubuntu, and there I installed  ninja IDE, direcly from  ubuntu software center.

On this laptop I create a folder home /home/pyton/qpi.

Considering the rpi installation:

I copied a 2013-02-09-wheezy-raspbian.img on a  2GB SD.(right now you can find an updated verison of raspbian, on the rpi website  here: link

Start rpi connected on a monitor,my case was tv  via hdmi wire , mouse and keyboard and a ethernet cable.

Leave the default setting in the config.

Now you can disconnect all from rpi except the ethernet wire.

On the router  I defined a static address :192.168.0.50 , related with rpi mac address. (i have a netgear router and it waas really intuitive to set it ).

From the laptop , on the terminal use [See note below if you encounter problem with ssh]:

ssh pi@192.168.0.50
password : raspberry

Now yuo are using rpi from the laptop

Execute:

$ sudo apt-get undate
$ sudo apt-get upgrade

The update/upgrade can take up to one hour.

Since I ‘ll use rpi to pilot the motors I ‘nned to install the library that can manage the GPIO in rpi.

This library  RPIO allows to set any output as PWM:

$ sudo apt-get install python-setuptools
$ sudo easy_install -U RPIO

Now let’s see how to set up the Wifi Connection via usb dongle.

Do not connect the usb dongle.

Install the  wpa_supplicant  utility:

$ apt-get install wpasupplicant

Run the utility to create the password_phrase:

$  wpa_passphrase My_WiFi_SSID mypassword

Yuo will get this output.

network={
    ssid="My_WiFi_SSID"
    #psk="mypassword"
    psk=b2abb0fcd2f4527e11817de0823a57bb19ba4622f4595062c94ec4dd1370b5fe
}

Copy the  psk value.

Run the editor to modify the  /etc/network/interfaces

$ sudo nano /etc/network/interfaces

Modify the file (pasting the psk value):

...

auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
  wpa-ssid "My_WiFi_SSID"
  wpa-psk b2abb0fcd2f4527e11817de0823a57bb19ba4622f4595062c94ec4dd1370b5fe

Switch off  RPi.

Connect teh dongle and disconnet the ethernet wire.

Restart rpi and you are on line.

Set the router in case you want a fixed ip address for the wifi connection.

Link:

ninja IDE

RPIO

NOTE: recently I clean up my laptop and installed ubuntu 13.10 on it.

From that moment it has been not possible to use ssh using wired connection.

So I solve it modifying the rpi eth0 configuration manually.

pi@raspberrypi ~ $ sudo nano /etc/network/interfaces
iface lo inet loopback
#iface eth0 inet dhcp
allow-hotplug eth0
iface eth0 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.1

In the same way, in the laptop I defined a static ip address 192.168.1.1