Raspberry Pi 3 Model B with MPU9250 connected to it's I2C interface and a USB-Serial widget to access console over serial |
Connections
Preparations
Prepare and boot Arch Linux ARM from SD Card: instructions are here.
Connect the Raspberry Pi to your home network using an ethernet cable.
Look up the DHCP assigned IP address from your router’s configuration web interface, it will show as a new device named "alarmpi".
Gain access to the console over SSH using PuTTY or MobaXterm or physically using keyboard/mouse/monitor. Login: alarm and Password: alarm
While following the instructions below, switch to root user whenever required using:
su root
Password: root
Enable Console over USB-Serial [Optional]
Follow instructions over at https://gist.github.com/yeokm1/d6c3ca927919c61257cdInstall required packages on Arch Linux ARM running on RPi3B
- pacman-key --init
- pacman-key --populate archlinuxarm
- pacman -Syu
- pacman -S curl bash ca-certificates nano i2c-tools jq iio-utils
- pacman -S base-devel
- pacman -S dtc git
- pacman -S linux-raspberrypi-headers
- pacman -S python python-pip
Enable I2C on Raspberry Pi 3 Model B running Arch Linux ARM
su root
nano /etc/modules-load.d/raspberrypi.conf
Append:
i2c-dev
Save and Reboot
nano /boot/config.txt
Append:
dtparam=i2c=on
Save and Reboot
Test (0x68 is MPU9250):
Python Library for reading from MPU9250 over I2C
Install python packages (Latest version from its git repository, replace the version numbers with latest one)
python -m pip install git+https://github.com/FaBoPlatform/FaBo9AXIS-MPU9250-Python.git@78e4da28e176a07cc1c22c2f61a5be7ffe6c2c28
Clone the git repository to fetch the example code
git clone https://github.com/FaBoPlatform/FaBo9AXIS-MPU9250-Python.git
First test in text mode using example from FaBo9AXIS-MPU9250-Python repo (This uses raw I2C bus without the need for MPU9250 Industrial I/O Driver):
Enabling MPU9250 Industrial I/O interface on ArchLinux running on Raspberry Pi 3
Fetch (from mainline kernel repository) the latest sources of inv-mpu6050 which has support for MPU9250 through shallow clone/sparse checkout, execute the following commands while in /root:
su root
mkdir linux_main_src
cd linux_main_src
git init
git remote add origin https://github.com/torvalds/linux.git
git config core.sparsecheckout true
echo "drivers/iio/*" >> .git/info/sparse-checkout
git pull --depth=3 origin master
Create the Makefile for compiling the driver:
Get into /root/linux_main_src/drivers/iio/imu/inv_mpu6050
And modify the Makefile present there for the inv_mpu6080 driver to compile on and for Raspberry Pi 3 platform (lines in blue will be present already, lines in red are the ones that need to be appended, make sure to use a single tab and not spaces at the beginning of the lines below “all:’ and “clean:”) :
Makefile
Change to /root
cd /rootCreate an device tree overlay source file for MPU9250:
nano /root/mpu9250.dtsAdd the contents and save:
Compile the device tree source and place it in overlays folder:
dtc -I dts -O dtb -o /boot/overlays/mpu9250.dtbo -b 0 -@ /root/mpu9250.dtsUpdate /boot/config.txt and add the following lines to it, save it and reboot:
dtoverlay=mpu9250Read the Accelerometer and Magnetometer values like so:
Python Bar Graph with Industrial I/O Driver
Install python packages (Latest versions from its git repository, replace the version number with latest one)
pacman -S libjpeg
python -m pip install git+https://github.com/peterbrittain/asciimatics.git@476159c95c5b6e34a782ea97503785ad95683805
Clone the git repository to fetch the example code
git clone https://github.com/peterbrittain/asciimatics.git
Then run following code using python for live bar graph:
Try rotating the MPU9250 widget and watch the bars change. |
Enable WiFi on your Raspberry Pi 3 Running Arch Linux ARM [Optional]
su root
sudo pacman -S netctl
nano /etc/netctl/wireless-home
Copy and paste the following contents and modify the SSID and passphrase to match your WiFi network
netctl enable /etc/netctl/wireless-home
reboot
Comments
Post a Comment