LSM9DS1 with ESP32 trough I2C

Hello,

I am trying to get the LSM9DS1 to talk to my ESP32 using I2C... but cant get it to work. Used various libraries that can be installed rough the Arduino IDE but no cigar.

I2C scanner detects the device on the default address 0x6B but initialization fails.

Is there someone who can help me in the right direction?

#include <Wire.h>
#include <SPI.h>
#include <SparkFunLSM9DS1.h>

LSM9DS1 imu;

#define LSM9DS1_AG  0x6B

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);

  Wire.begin();

  if (imu.begin() == false) // with no arguments, this uses default addresses (AG:0x6B, M:0x1E) and i2c port (Wire).
  {
    Serial.println("Failed to communicate with LSM9DS1.");
    Serial.println("Double-check wiring.");
    Serial.println("Default settings in this sketch will " \
                   "work for an out of the box LSM9DS1 " \
                   "Breakout, but may need to be modified " \
                   "if the board jumpers are.");
    while (1);
  }
}

void loop() {
  // put your main code here, to run repeatedly:

}

Hi @marcwitteveen
What GPIOS are you using to connect to LSM9DS1?
See if this link helps.
https://learn.sparkfun.com/tutorials/esp32-thing-motion-shield-hookup-guide/using-the-imu

I have it connected at followed:

ESP 32 <-> LSM9DS1
3V3 <-> VDD
GND <-> GND
21 <-> SDA
22 <-> SCL

Hi
Are you using a module?
If yes, please post the link with the image of this module.

What does not work mean?

Have you tried using the SPI connections for the LSM9DS1? I did not ever get my LSM9DS1's working with an ESP32 on I2C.

Sounds like a problem with the library. Try a different one.

https://www.amazon.de/-/en/MINGMIN-DZ-Permanent-Inertia-LSM9DS1-Assemble/dp/B08W546FL1/ref=sr_1_5?keywords=lsm9ds1+modul&qid=1639935908&sr=8-5

Ignore the price, it is crazy high...paid much less for it (10 euro or so).

@jremington most of them are SPI... I wanted to use I2C because it is easy to attach other sensors later. But perhaps I will need to use ISP if I2C is not working.

@Idahowalker initialisation is not working... if you look at the first message... I get "Failed to communicate with LSM9DS1", immediately.

post a few images of your project, all wired / powered up.

Complete installation

ESP32

LSM9DS1

tried using pull up resistors?

The LSM9DS1 usually requires a soft reset at start-up, and a delay of I think 250 ms before it's available for general use... Might want to check up on that in your library source

No, I did not... Stupid question, what would you pull up? Address selection?

Hi
I think these resistors inside the red circle are the PULLUPs for the I2C.

But this VDDIO pin needs to be wired to some potential VCC.
I think it's at 3.3V.

2 Likes

See post 14

I2C Pull Up Resistors — Rheingold Heavy

1 Like

That was it... after I connected the VDDIO pin it worked...using Adafruit as well as SparkFun library. Also I2C tester returns two default addresses as it should (0x1E and 0x6B). The VDDIO pin is the power supply for I/O pins as mentioned in the datasheet of the sensor https://www.st.com/resource/en/datasheet/lsm9ds1.pdf

Thank you all for helping me crack this nut.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.