Connecting an IMU GY N601N1, reading angles

Hi, thanks for very good help in the past.

I am a beginner trying to connect a 6 axis gyroscope / accelerometer GY N601 N1 to an ESP32 S3 development board. The green LED is on and I can find the sensor on I2C scan. But that is all. I see nothing on UART and can not retreive anything over I2C.
image

I have also made one earlier try of reading over UART to an Arduino R3 via a Logical Level Shifter. No data arrived. That was via SoftwareSerial which I had used before. I am all new on this ESP32 and "RXD2, TXD2".

The sensor can deliver better processed data over UART (Euler angles) that I would prefer, but to start with I also try to read acceleration data over I2C.

I have not learnt to draw wiring diagrams yet, so I believe a photo is better and possible mistakes more easily detected.

Why cant I get data via I2C and why doesnt it give data over UART


color of wires leaving the ESP32, from right to left:
green/blue: Gnd/3.3V feed to IMU
white: 3.3V feed to pull up resistors for I2C
ESP32 grey(pin 11)/violet(pin 10):
11->IMU-Rx;
IMU-Tx->10

#define RXD2 10
#define TXD2 11
 Serial2.begin(BAUD_RATE, SERIAL_8N1, RXD2, TXD2);

ESP blue(pin 9)/grey(pin 8):
9 <-> IMU SCL
8 <-> IMU SDA
Pin 9 and 8 connected to 3.3 V via pull up resistors (9.1 K Ohm).

The solitary white on pin 5 is for testing the LED that blinks as expected

Some say the IMU will start feeding data over UART as soon as it receives power.
In the sketch it receives a wake up call. (I have naturally tried different variants and also without wake up call.)
Some say a fixed green LED can mean it is waiting for satellite connection. But this IMU has no GPS as far as I know.
I have naturally moved the IMU while reading.
The I2C scan also detects one more connection which seems to be some kind of "ghost device".


/*
16:12:20.019 -> Scanning...
16:12:20.060 -> I2C device found at address 0x68  !
16:12:20.060 -> I2C device found at address 0x7E  !
16:12:20.060 -> done
*/

// for I2C
#include <Wire.h>
// #define WIRE Wire

#define I2C_SDA 8
#define I2C_SCL 9

const int MPU_ADDR = 0x68;

// for UART:
#define RXD2 10
#define TXD2 11
#define BAUD_RATE 115200

void setup() {

  // USB
  Serial.begin(9600);
  Serial.println("start program");

  // I2C:
  Wire.begin(I2C_SDA, I2C_SCL);  // Initialize I2C with specific pins
  Wire.beginTransmission(MPU_ADDR);
  Wire.write(0x6B);  // Power Management Register
  Wire.write(0);     // Set to zero to wake up
  Wire.endTransmission(true);
  Serial.println("I2C initialized");

  // UART:
  Serial2.begin(BAUD_RATE, SERIAL_8N1, RXD2, TXD2);
}

void loop() {

  // I2C:
  Wire.beginTransmission(MPU_ADDR);
  Wire.write(0x3B);  // Starting register for data (ACCEL_XOUT_H)
  Wire.endTransmission(false);
  Wire.requestFrom(MPU_ADDR, 6, true);  // Request 6 registers

  // Read data
  int16_t ax = Wire.read() << 8 | Wire.read();
  int16_t ay = Wire.read() << 8 | Wire.read();
  int16_t az = Wire.read() << 8 | Wire.read();

  Serial.print("AccX: ");
  Serial.print(ax);
  Serial.print(" | AccY: ");
  Serial.print(ay);
  Serial.print(" | AccZ: ");
  Serial.println(az);

  // UART:
  if (Serial2.available()) {
    Serial.print("UART:");
    Serial.print(Serial2.read());
    Serial.println();
  }

  delay(500);
}

IMU



Controller

Where the IMU was bought

It's probably an ICM45686 IC. There is an Arduino library for it.

Thanks. My own efforts have not been enough. I will check out that library and be back in due course.

I don’t know that module but The GY-601N1 likely cannot be used on I2C and UART simultaneously, as the pins are physically shared and probably the the PS pin selects one interface at a time.​​​​​​​​​​​​​​​​

I forgot to write that I have tried each mode separately before, but thanks for the reminder. Which pins are "physically shared"?
I have assumed the PS means Pin Select and putting voltage to it would activate SPI? I have never used that.

Now I assume "each side of connectors" represents I2C and UART.

The library uses I2C stick with that for now.

Actually, the "AN" marking on the IC would indicate that it is a Bosch BMI323 IC, try that library.

Thanks. You have the experience to analyze this. I have just seen general pages that often said this kind of board is based on ICM-42688-P. The name MPU6050 also often came up.

Is this of any value?

See my last post.
It seems to be a BMI323 IC. Search for a library for it.

OK. It's getting late here, but I will definitely follow your advice and come back.

Good night

My curiosity kept me awake. How does the library manager work. When I enter BM1323 and similar I find nothing?

For the Bosch BMI323 6-axis IMU, the best Arduino library is DFRobot_BMI323

A person has to make their library available through the library manager, if they don't it won't show up. So for the dfrobot library, go here:

Click on the code button on the right and download the zip file.

Then in the IDE click on Sketch->Include Library->add ZIP lib

Ha ha. We have data. You're the man @jim-p

So to find example sketches I must go to Github?

No. The library zip contained the examples, so they should appear in the IDE Files->Examples.

Yes, you are right, of course. The examples from the libraries come up at the bottom.

Do you know how to make the final step, to compute the orientation of the chip, using these raw accelerometer/gyroscope data? I definitely want that to happen on the chip, it would be complex for me to do on the ESP32 and I would need to spend much time learning that. And the ESP32 would probably spend much effort doing it. I may want to use the ESP32 for other purposes.

And it is not just adding the accelerometer data to get the position. I think the dedicated chips use Kalman filter etc to integrate gravity with acceleration to find the "horisontal level" to get absolute values of pitch and roll. For absolute values of yaw they integrate magnetometer/compass data.

I think the result should come in Euler angles (or Quaternions that can be converted into Euler angles, as I understand.)

Great you identified the chip and found a way to read data from it.

Maybe I save myself a lot of work by getting a MPU-6050 instead?

If you or anyone knows of a suitable board, please advice! (Another Bosch chip is mentioned in the screenshots below.)

For motion-specific applications, this board differs from modules like the MPU-6050, which has a specialized DMP specifically designed for offloading sensor fusion (gyroscope and accelerometer) calculations. On this board, the GD32 MCU handles the general logic and data management for its environmental sensors


GY 521 costs just over a buck. Is this a good buy?


Google:

The MPU6050 is an old and discontinued IC, no longer made by TDK. I personally would only buy one from a reputable distributor like, Adafruit, Sparkfun, Digi-Key, etc., same goes for the MPU9250

There are many other IMU boards, like the BNO055 and BNO086 that you should look at.

I found a BNO08X that I ordered and also a MPU6050 since it was only a dollar :grinning_face:

To test the controller's BT, I picked the example
ESP32S3 Dev module > BLE > UART service
that immediately worked.

ESP32S3 Dev module only uses BLE and the app I am used to - "Bluetooth Graphics" by Cetin, will only connect to BT Classic.
The app "Serial Bluetooth Terminal" by Morich will also connect to BLE and read/write data well but has no plotting which I really need. Internet claims the app can plot but I can't make it.
The apps nRF Connect and Light Blue will connect to ESP32S3 BLE but these apps are not for communicating as I understand, they are more for analyzing BT connections.

I will maybe try to send the Gyroscope data from the BMI323 to Bluetooth Graphics app to plot it. But it seems I will have to unholster the trusted HC-06 card in order to communicate with Bluetooth Graphics app that only accepts BT Classic?