Figure12.2.2.The LSM303AGR breakout and its STEMMA QT cable. Either socket on the breakout takes the cable’s plug, and it only fits one way. Its four wires go to the Nucleo: black to GND, red to 3.3 V, yellow to SCL (D15, PB8), and blue to SDA (D14, PB9), the same SCL and SDA rows the display is already using. The pin the red wire feeds is VIN; the board accepts either 3.3 or 5 V logic, and in this course we use 3.3 V.
Black to GND, red to 3.3 V, yellow to SCL (D15, PB8), blue to SDA (D14, PB9).
Figure12.2.4.The accelerometer joins the bus: yellow to the SCL row, blue to the SDA row, black to GND, and red to 3.3 V. The display, not drawn here, stays wired to the same two rows.
One SDA row and one SCL row for the whole bus. The display (not drawn) can stay on the same two rows; each device has its own address, so neither answers transactions addressed to the other.
Activity12.2.2.Wire the accelerometer and verify the link.
The program we’ll run, whoami_test.c, reads a certain register, called WHO_AM_I, once a second and prints whether it got the value it expected.
Plug the STEMMA QT cable into the breakout and wire its four leads: black to GND, red to 3.3 V, yellow to SCL (D15, PB8), and blue to SDA (D14, PB9), as in Figure 12.2.2.
Make a copy of your TemplateProject and call the new project Accelerometer. Download whoami_test.c from the book’s starter files and put it in the project’s Src folder. Build and upload.