Problem using MPU-6050 Accel/Gyro with WifiKit ESP32 Board

I am having problems getting the MPU-6050 Accelerometer & Gyro to work with my Heltec WiFiKit V2 ESP32 Development board.

I can run the I2C scanner and it detects the MPU-6050 at 0x68

If I run any of the example sketches that came with the MPU6050.h library it does not get data from the MPU-6050

I tried the MPU6050_DMP6.ino and have tried various examples from the web. But it is an issue with the ESP32
The MPU-6050 works fine using the sketch on my Arduino Nano but not the ESP32

I have the MPU-6050 connected as follows:
MPU-6050 o left ESP32 on right
VCC to 3.3V
GND to GND
SDA to Pin 21
SCL to Pin 22

Any help is greatly appreciated

Do you have other IIC devices? You can use other IIC devices to confirm whether pins 21 and 22 of Kit32 are available.

Unfortunately I do not have any other I2C devices. I have tested this KPU-6050 on the Arduino Uno and it works. So I know the board itself is functional.

I just have to figure out how to get it to work on the Wifi32 Kit.

Anyone? Anyone? Where is heltec support on this?

I tried another MPU6050, also working properly with the Arduino Nano, and connected it to the WiFi Kit board.

Exactly the same issue

I will update this post in case anyone else experiences the same issue Since heltec support does not reply.

Progress. I was able to get the MPU6050 to initialize. I don’t know if it will work on any pin but I will have to test that after I get the interrupt to work.

I do not know how to setup and use a pin as an Interrupt on the ESP32. The accel/gyro generates an interrupt when data is available. Then I can view the readings when I figure this out.

I moved the MPU6050 to the first I2C bus, the one that the display is connected to.
This is SDA-Pin4 and SCL-Pin 15

The steps are as follows:

  1. Load the heltec library
    #include “heltec.h”

  2. Now you can enable the built-in OLED display with this line
    Heltec.begin(true /DisplayEnable Enable/, false /LoRa Enable/, true /Serial Enable/);

  3. The key to getting I2C to work seems to be that now you have to initialize the display then other devices can be used
    Heltec.display -> display();

  4. It is time to start the wire. It defaults to SDA-Pin4 and SCL-Pin 15
    Wire.begin();

  5. Now you can initialize the MPU6050
    mpu.initialize();

The next step would be to enable the interrupt. On the Arduino Uno all you have to do is plug the MPU6050 INT pin into Uno pin 2 and it worked right away.

But I am not sure how to setup and use a GPIO pin as an Interrupt on the Heltec board

I’m from HelTec. Since the previous two days were weekends, we did not go to work, so we did not answer your question in time. I am very sorry. You can use the “attachInterrupt” function to set the pin interrupt. For function usage, please refer to attachInterrupt()

Thank you. I will take a look at this and reply

I looked at that page and it is still not working.

Here is the code I added:
#define INTERRUPT_PIN 35

  pinMode(INTERRUPT_PIN, INPUT_PULLUP);
  attachInterrupt(INTERRUPT_PIN, dmpDataReady, RISING);

After a lot of testing I figured it out. The issue was not with the code the problem was the pin used.
In addition the code to configure a pin as an interrupt is working.

Seems like some features of this board operate differently from the other ESP32 boards.

For example some docs I found say that any pin can on an ESP32 board can be configured as an interrupt. But on the Heltec board not all pins actually work. Maybe there is extra coding or whatever.

I tested most of the pins on the Heltec board to see if they will operate as an interrupt pin and results are as follows
36, 37, 38, 39 - SEE NOTE
34 - NG
35 - NG
32 - OK
33 - OK
19 - OK
18 - OK
5 - OK
2 - OK

36, 37, 38, 39 exhibited strange behavior. They did work when configured as an interrupt but they activated in pairs.
For example if I configured Pin 37 as an interrupt Pin 36 also triggered an interrupt. Same condition for Pair 38 & 39.

The code snipets for the MPU6050 interrupt are as follows (dmpDataReady is interrupt routine)
#define INTERRUPT_PIN 39

void setup() {
pinMode(INTERRUPT_PIN, INPUT);
attachInterrupt(digitalPinToInterrupt(INTERRUPT_PIN), dmpDataReady, RISING);
}

Feedback and suggestions are greatly appreciated

Now I need to work this code into my GPS Data Logger.
Question: The uBlox GPS Module uses two pins for data TX and RX. If the MPU6050 Accel/Gyro generates an interrupt will it cause issues with the sketch dropping GPS Data?

using Wire.begin(SDApin, SCLpin);

define pins
int SDA= ;
int SCL = ;