@@ -27,10 +27,52 @@ Please ensure all dependencies are available on the CircuitPython filesystem.
27
27
This is easily achieved by downloading
28
28
`the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle >`_.
29
29
30
+ Installing from PyPI
31
+ =====================
32
+ On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
33
+ PyPI <https://pypi.org/project/adafruit-circuitpython-lsm9ds0/> `_. To install for current user:
34
+
35
+ .. code-block :: shell
36
+
37
+ pip3 install adafruit-circuitpython-lsm9ds0
38
+
39
+ To install system-wide (this may be required in some cases):
40
+
41
+ .. code-block :: shell
42
+
43
+ sudo pip3 install adafruit-circuitpython-lsm9ds0
44
+
45
+ To install in a virtual environment in your current project:
46
+
47
+ .. code-block :: shell
48
+
49
+ mkdir project-name && cd project-name
50
+ python3 -m venv .env
51
+ source .env/bin/activate
52
+ pip3 install adafruit-circuitpython-lsm9ds0
53
+
30
54
Usage Example
31
55
=============
32
56
33
- See examples/lsm9ds0_simpletest.py for a demo of the usage.
57
+ .. code-block :: python
58
+
59
+ import time
60
+ import board
61
+ import busioimport adafruit_lsm9ds0
62
+
63
+ i2c = busio.I2C(board.SCL , board.SDA )
64
+ sensor = adafruit_lsm9ds0.LSM9DS0_I2C(i2c)
65
+
66
+ while True :
67
+ accel_x, accel_y, accel_z = sensor.acceleration
68
+ mag_x, mag_y, mag_z = sensor.magnetic
69
+ gyro_x, gyro_y, gyro_z = sensor.gyro
70
+ temp = sensor.temperature
71
+ print (' Acceleration (m/s^2): ({0:0.3f } ,{1:0.3f } ,{2:0.3f } )' .format(accel_x, accel_y, accel_z))
72
+ print (' Magnetometer (gauss): ({0:0.3f } ,{1:0.3f } ,{2:0.3f } )' .format(mag_x, mag_y, mag_z))
73
+ print (' Gyroscope (degrees/sec): ({0:0.3f } ,{1:0.3f } ,{2:0.3f } )' .format(gyro_x, gyro_y, gyro_z))
74
+ print (' Temperature: {0:0.3f } C' .format(temp))
75
+ time.sleep(1.0 )
34
76
35
77
Contributing
36
78
============
@@ -84,4 +126,4 @@ Now, once you have the virtual environment activated:
84
126
85
127
This will output the documentation to ``docs/_build/html ``. Open the index.html in your browser to
86
128
view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to
87
- locally verify it will pass.
129
+ locally verify it will pass.
0 commit comments