I used 2 I2C interface and 1 SPI to collect data from 5 sensors 20948. I2C address of 20948 could be changed after I soldered ADR pin. The I2C address of 20948 will be changed from 0x69 to 0x68. So, 2 9DoF sensor 20948 could share one I2C interface. ESP32 support 2 I2C interface. So I could use I2C to collect data from 4 sensor 20948. Meanwhile, sensor 20948 supports SPI too. I use one SPI collect data of one sensor 20948. As shown above, sensor # 1, to sensor # 4 communicate with ESP32 by I2C while sensor # 5 communicates with ESP32 by SPI.
The sequence of the data follow this
{acceleration_x,acceleration_y,acceleration_z,gyro_x,gyro_y,gyro_z,magnetic_x,magnetic_y,magnetic_z}
Data collected by I2C is reasonable. However, data collected by SPI is no reasonable because magnetic_x, magnetic_y, magnetic_z are always 0 though other data collected by SPI is normal. I found it is the problem of adarfuit libray not because of developing board.
Unable to read magnetic data from 20948
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- Franklin97355
- Posts: 23912
- Joined: Mon Apr 21, 2008 2:33 pm
Re: Unable to read magnetic data from 20948
I'll let the author know. Can you post the code you used to get the data and a picture of the boards spi pins and connections?
- Luttin
- Posts: 5
- Joined: Fri Aug 27, 2021 9:40 pm
Re: Unable to read magnetic data from 20948
Sure.
The attached file is the code that I used.
The attached file is the code that I used.
- Luttin
- Posts: 5
- Joined: Fri Aug 27, 2021 9:40 pm
Re: Unable to read magnetic data from 20948
/*
For software-SPI mode we need SCK (SCL)/MOSI (SDA)/MISO (SDO)/CS (SS) pins
*/
Here is how i define pin of spi
#define ICM_CS 5
#define ICM_SCK 18
#define ICM_MISO 19
#define ICM_MOSI 23
For software-SPI mode we need SCK (SCL)/MOSI (SDA)/MISO (SDO)/CS (SS) pins
*/
Here is how i define pin of spi
#define ICM_CS 5
#define ICM_SCK 18
#define ICM_MISO 19
#define ICM_MOSI 23
- Franklin97355
- Posts: 23912
- Joined: Mon Apr 21, 2008 2:33 pm
Re: Unable to read magnetic data from 20948
What board are you using?
- Luttin
- Posts: 5
- Joined: Fri Aug 27, 2021 9:40 pm
Re: Unable to read magnetic data from 20948
ESP32 32S NodeMCU Arduino Development Board 2.4GHz WiFi+Bluetooth Dual Mode
- adafruit2
- Posts: 22149
- Joined: Fri Mar 11, 2005 7:36 pm
Re: Unable to read magnetic data from 20948
the way the magnetic sensor is wired inside the sensor...we're not actually sure you *can* get to it over SPI :( its a very odd sensor where you set up an I2C passthrough to connect to the magnetic part of the chip.
you may be better off using a multiplexor https://www.adafruit.com/product/2717
you may be better off using a multiplexor https://www.adafruit.com/product/2717
- adafruit_support_carter
- Posts: 29189
- Joined: Tue Nov 29, 2016 2:45 pm
Re: Unable to read magnetic data from 20948
Opened an issue here to take a look:
https://github.com/adafruit/Adafruit_ICM20X/issues/13
Even if not fixable, can at least serve to document behavior.
https://github.com/adafruit/Adafruit_ICM20X/issues/13
Even if not fixable, can at least serve to document behavior.
- adafruit_support_carter
- Posts: 29189
- Joined: Tue Nov 29, 2016 2:45 pm
Re: Unable to read magnetic data from 20948
@Luttin I think we know why this happening:
https://github.com/adafruit/Adafruit_IC ... -910742548
But no idea when or even if this can get fixed. It's an odd setup.
https://github.com/adafruit/Adafruit_IC ... -910742548
But no idea when or even if this can get fixed. It's an odd setup.
Please be positive and constructive with your questions and comments.