Introduction: *Preliminary* SPI on the Pi: Communicating With a SPI 3-axis Accelerometer Using a Raspberry Pi

Step by step guide on how to setup Raspbian, and communicate with a SPI device using bcm2835 SPI library (NOT bit banged!)

This is still very preliminary... I need to add better pictures of physical hookup, and work through some of the awkward code.

Step 1: Starting With a Blank SD Card, Download Raspbian Image, and Install Onto SD Card

Visit for instructions on how to install Raspbian

I downloaded:
Raspbian image, and used
Win32DiskImager to install on SD card

There's also more information at

Step 2: Connect Raspberry Pi to TV/Monitor, and Run Through Initial Setup

(Internet connection not required yet)

Set timezone
enable SSH

Then, Finish.

Terminal code:

Step 3: Optional: Operate Pi Headless

Excellent tutorial at

I use Putty (Windows) or Terminal (Mac) to connect with SSH

Step 4: Recommended: Update OS

Terminal Code:
sudo apt-get update
sudo apt-get upgrade

Step 5: Optional: Setup IP Address E-mailer

I've set up my Pi to e-mail me it's IP address each time it boots.  This makes my life easier when I need to remote login using SSH.

Excellent tutorial at

Step 6: Optional - Setup VNC

Excellent tutorial at

I didn't go through the entire tutorial... just the following steps:
$ sudo apt-get install tightvncserver
$ tightvncserver
$ vncserver :1 -geometry 1200x800 -depth 24

And, I created a script to keep my typing to a minimum.

Step 7: Install BCM2835 SPI Library

Excellent documentation (and examples) at

Terminal code:
// wget; // My Pi can't figure out this URL - unable to resolve host name?
tar xvfz bcm2835-1.5.tar.gz;
cd bcm2835-1.5;
sudo make install

Step 8: Get ADXL362 SPI Example

Note: Code is still very basic... need to improve

get ADXL362_RaspPi from
(How to do this on Pi, using wget?  I'm having trouble with this... "unable to resolve host address ''")

Step 9: Phyiscally Connect ADXL362 Breakout to Raspberry Pi GPIO

More details to come...

More info about ADXL362 (ultra low power 3-axis accelerometer) at

Connect 3v3, GND, SPI0 MOSI, SPI0 MISO, SPI0 SCLK, SPI0 CE0 N on Raspberry Pi to
VDDand VIO, GND (2), MOSI, MISO, SCLK, and CSB on ADXL362 Breakout board.

Step 10: Compile and Run ADXL362_RaspPi

terminal code:
gcc -o ADXL362_RaspPi -I ../bcm2835-1.5/src ../bcm2835.c ADXL_RaspPi.c
sudo ./ADXL362_RaspPi

Which I combines into a script called compileADXL362.