Skip to content

OlivierdenOuden/LSM9DS1_IMU

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

LSM9DS1_IMU

How to read-out LSM9SD1 digital IMU sensor by use of the I2C port on a Raspberry PI model 3B+. More info on the LSM9DS1 and the I2C port.

Raspberry PI - I2C port

First the hardware needs to be enabled before the software, attached python scripts, can be used. This is done by following the steps of the link above. The I2C port is not enabled by default, this needs to be done;

  1. Run, in terminal, sudo raspi-config.
  2. Select point 9, Advanced options.
  3. Select A7, I2C, and select yes.
  4. Exit this window and reboot the PI.

After reboot, check if the I2C port is enabled by using;

ls /dev/*i2c*

if I2C port is open the PI will respond with;

/dev/i2c-1

where 1 indicates which I2C bus is used.

Now the I2C port is enabled but to have interaction between the PI and the sensor some utilities are needed. Use the following command line in a terminal;

sudo apt-get install -y i2c-tools

The i2cdetect command probes all the addresses on a I2C port bus, and report whether any devices are present. Outcome of this command will look like;

pi@raspberrypi:~/$ i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: 60 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Here the I2C adress of the sensor is 0x60. More information, or source, can be found here.

I2C - Python

To read out the sensors with python, some python modules are needed. Run the command lines below;

sudo apt-get update
sudo apt-get install python-smbus
sudo apt-get install python-obspy

Python scripts

The main file to read raw sensor data of the LSM9DS1 is the read_lsm9ds1.py script. Calling the main script needs some arguments;

OSR           - Oversampling rate
Record time   - Recording time
Measurement type - 0 = only accelerometer data, 1 = only gyroscope dat, 2 = only magnetometer data and 3 = all types of data

Converting raw data, counts, to accelerometer unit g, gyroscope unit dps and magnetometer unit gauss is done by con_lsm9ds1.py.

Author

Olivier den Ouden - KNMI - HFSP SeabirdSound

Releases

No releases published

Packages

No packages published

Languages