/ README.rst
README.rst
  1  This library is archived and no longer supported
  2  =============================================
  3  This library has been split into separate libararies for the magnetometer and accelerometer. The accelerometer code will  be shared with another version of the LSM303 that uses the same accelerometer but not the magnetometer and this repo will be archived.
  4  
  5  This library will no longer be supported. Please us the new libraries
  6  
  7  The new, split libraries
  8  
  9  https://github.com/adafruit/Adafruit_CircuitPython_LSM303_Accel
 10  
 11  https://github.com/adafruit/Adafruit_CircuitPython_LSM303DLH_Mag
 12  
 13  The library for the new magnetometer
 14  
 15  https://github.com/adafruit/Adafruit_CircuitPython_LSM303AGR_Mag
 16  
 17  You can find usage information for the new libraries in the sensor's guide:
 18  
 19  https://learn.adafruit.com/lsm303-accelerometer-slash-compass-breakout/python-circuitpython
 20  
 21  Introduction
 22  ============
 23  
 24  .. image:: https://readthedocs.org/projects/adafruit-circuitpython-lsm303/badge/?version=latest
 25      :target: https://circuitpython.readthedocs.io/projects/lsm303/en/latest/
 26      :alt: Documentation Status
 27  
 28  .. image :: https://img.shields.io/discord/327254708534116352.svg
 29      :target: https://discord.gg/nBQh6qu
 30      :alt: Discord
 31  
 32  .. image:: https://travis-ci.com/adafruit/Adafruit_CircuitPython_LSM303.svg?branch=master
 33      :target: https://travis-ci.com/adafruit/Adafruit_CircuitPython_LSM303
 34      :alt: Build Status
 35  
 36  Adafruit CircuitPython module for the LSM303 6-DoF with 3-axis accelerometer and magnetometer
 37  
 38  Dependencies
 39  =============
 40  This driver depends on:
 41  
 42  * `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
 43  * `Bus Device <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_
 44  
 45  Please ensure all dependencies are available on the CircuitPython filesystem.
 46  This is easily achieved by downloading
 47  `the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
 48  
 49  Installing from PyPI
 50  ====================
 51  
 52  On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
 53  PyPI <https://pypi.org/project/adafruit-circuitpython-lsm303/>`_. To install for current user:
 54  
 55  .. code-block:: shell
 56  
 57      pip3 install adafruit-circuitpython-lsm303
 58  
 59  To install system-wide (this may be required in some cases):
 60  
 61  .. code-block:: shell
 62  
 63      sudo pip3 install adafruit-circuitpython-lsm303
 64  
 65  To install in a virtual environment in your current project:
 66  
 67  .. code-block:: shell
 68  
 69      mkdir project-name && cd project-name
 70      python3 -m venv .env
 71      source .env/bin/activate
 72      pip3 install adafruit-circuitpython-lsm303
 73      
 74  Usage Example
 75  =============
 76  
 77  .. code-block:: python
 78  
 79  	import time
 80  	import board
 81  	import busio
 82  
 83  	import adafruit_lsm303
 84  
 85  	i2c = busio.I2C(board.SCL, board.SDA)
 86  	sensor = adafruit_lsm303.LSM303(i2c)
 87  
 88  	while True:
 89  		raw_accel_x, raw_accel_y, raw_accel_z = sensor.raw_acceleration
 90  		accel_x, accel_y, accel_z = sensor.acceleration
 91  		raw_mag_x, raw_mag_y, raw_mag_z = sensor.raw_magnetic
 92  		mag_x, mag_y, mag_z = sensor.magnetic
 93  
 94  		print('Acceleration raw: ({0:6d}, {1:6d}, {2:6d}), (m/s^2): ({3:10.3f}, {4:10.3f}, {5:10.3f})'.format(raw_accel_x, raw_accel_y, raw_accel_z, accel_x, accel_y, accel_z))
 95  		print('Magnetometer raw: ({0:6d}, {1:6d}, {2:6d}), (gauss): ({3:10.3f}, {4:10.3f}, {5:10.3f})'.format(raw_mag_x, raw_mag_y, raw_mag_z, mag_x, mag_y, mag_z))
 96  		print('')
 97  		time.sleep(1.0)
 98  
 99  
100  Contributing
101  ============
102  
103  Contributions are welcome! Please read our `Code of Conduct
104  <https://github.com/adafruit/Adafruit_CircuitPython_LSM303/blob/master/CODE_OF_CONDUCT.md>`_
105  before contributing to help this project stay welcoming.
106  
107  Documentation
108  =============
109  
110  For information on building library documentation, please check out `this guide <https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/sharing-our-docs-on-readthedocs#sphinx-5-1>`_.