The accelerometer and gyroscope on the BerryIMUv3 can output data at a rate of 6,664 times a second! I2C is too slow to read the output at this rate, this is where SPI comes in.
Buy default, BerryIMUv3 is setup to use I2C. You can complete the SPI interface by placing a solder blob on jumper 7 (JP7).
SPI uses 4 pins, and depending on what device you are using these pins could be named differently, which causes confusion.
The most common pin names are;
- MOSI (Master out Slave In)
- MISO (Master In Slave Out
- SCLK (Serial Clock)
- CS (chip select) This is CE0 or CE1 on the Raspberry PI.
These pins have been highlighted below
On the BerryIMUv3, they are called;
- SDI (Slave Data In)
- SDO (Slave Data Out)
- SPC (Serial Port Clock)
- CS (Chip Select)
When we connect a BerryIMUv3 to a Raspberry Pi using SPI, the Raspberry Pi will be acting as a master and the BerryIMUv3 will be acting as a slave. This is how they are connected logically.
Here is the physical wiring
You can enable SPI on the Raspberry Pi using raspi-config
Go into “Interfacing Options”
When asked if you want to enable SPI, select “yes”
The code for SPI can be found here https://github.com/ozzmaker/BerryIMU/tree/master/python-BerryIMUv3-SPI