This repository contains a short example script that tests out the LIS3MDL digital output magnetic sensor using my own Raspberry Pi I2C library. This test includes setting up the device and reading magnetic field data.
This example requires the following dependencies (projects authored by me):
- pi_lw_gpio.c
- "Lightweight GPIO Interface Library for the Raspberry Pi"
- pi_microsleep_hard.c
- "Hard Microsleep Library Via System Timer for the Raspberry Pi"
- pi_i2c.c
- "Inter-Integrated Circuit (I2C) Library for the Raspberry Pi"
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
First, clone this repository.
$ git clone /~https://github.com/besp9510/pi_lis3mdl_example.git
Alternatively, download the repository from Git.
Compile test_lis3mdl.c into an executable.
$ make
test_lis3mdl.c is a test script to check and see the I2C library working on your Pi with a LIS3MDL device. The outline of the test is:
- Configure I2C library
- Scan for the device
- Verify device I.D.
- Configure device
- Set performance mode and sensitivity
- Select operating mode
- Get measurement status
- Read magnetic field data in a loop
Follow the "fork-and-pull" Git workflow.
- Fork the repo on GitHub
- Clone the project to your own machine
- Commit changes to your own branch
- Push your work back up to your fork
- Submit a Pull request so that your changes can be reviewed
Be sure to merge the latest from "upstream" before making a pull request!
Feel free to email at the email address under my account name if you have any questions.
Benjamin Spencer
This project is licensed under the MIT License - see the LICENSE.md file for details