LSM303DLH example in C for Raspberry Pi pico
GPIO PICO_DEFAULT_I2C_SDA_PIN (On Pico this is GP4 (e.g. pin 6)) -> SDA
GPIO PICO_DEFAULT_I2C_SCL_PIN (On Pico this is GP5 (e.g. pin 7)) -> SCL
3.3v (e.g. pin 36) -> VCC
GND (e.g. pin 38) -> GND
After you've wired your LSM303DLH breakout board run the example I2C bus scan to get the two I2C interface adressess (The IC has two interfaces - one for the accelerometr and second for the magnetometr) and update the inteface adresses in lsm303dlh.h
Or alternatively you can run my altered version of the scan to display the result via USB and use a terminal tool such as GTKTerm or PuTTY.
As stated in Getting started with Raspberry Pi pico chapter 8 -
$ mkdir build
$ cd build
$ export PICO_SDK_PATH=../../pico-sdk
$ cmake ..
$ make
some previous steps are necessary - please refer to chapter 2 of the material stated higher.
Code is published under the MIT License
Copyright (c) 2022 Tomas Dudacek