Unable to read magnetic data from 20948

Wearable electronics: boards, conductive materials, and projects from Adafruit!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Luttin
 
Posts: 5
Joined: Fri Aug 27, 2021 9:40 pm

Unable to read magnetic data from 20948

Post by Luttin »

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.
Screen Shot 2021-08-27 at 9.37.13 PM.png
Screen Shot 2021-08-27 at 9.37.13 PM.png (165.03 KiB) Viewed 540 times

User avatar
Franklin97355
 
Posts: 23910
Joined: Mon Apr 21, 2008 2:33 pm

Re: Unable to read magnetic data from 20948

Post by Franklin97355 »

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?

User avatar
Luttin
 
Posts: 5
Joined: Fri Aug 27, 2021 9:40 pm

Re: Unable to read magnetic data from 20948

Post by Luttin »

Sure.

The attached file is the code that I used.

[The extension ino has been deactivated and can no longer be displayed.]


User avatar
Luttin
 
Posts: 5
Joined: Fri Aug 27, 2021 9:40 pm

Re: Unable to read magnetic data from 20948

Post by Luttin »

/*
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

User avatar
Franklin97355
 
Posts: 23910
Joined: Mon Apr 21, 2008 2:33 pm

Re: Unable to read magnetic data from 20948

Post by Franklin97355 »

What board are you using?

User avatar
Luttin
 
Posts: 5
Joined: Fri Aug 27, 2021 9:40 pm

Re: Unable to read magnetic data from 20948

Post by Luttin »

ESP32 32S NodeMCU Arduino Development Board 2.4GHz WiFi+Bluetooth Dual Mode

User avatar
adafruit2
 
Posts: 22144
Joined: Fri Mar 11, 2005 7:36 pm

Re: Unable to read magnetic data from 20948

Post by adafruit2 »

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

User avatar
adafruit_support_carter
 
Posts: 29150
Joined: Tue Nov 29, 2016 2:45 pm

Re: Unable to read magnetic data from 20948

Post by adafruit_support_carter »

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.

User avatar
adafruit_support_carter
 
Posts: 29150
Joined: Tue Nov 29, 2016 2:45 pm

Re: Unable to read magnetic data from 20948

Post by adafruit_support_carter »

@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.

Locked
Please be positive and constructive with your questions and comments.

Return to “Wearables”