Arduino program to esp32

Hey guys can somebody help me convert this program to esp32?

I saw this guy made this program, i just want to test it out with my esp32 and my self builded robot:

ty for the helps!

That is not how the forum works. You need to do your best first, then show us the code and any wiring diagrams, and we can then comment on that.

That would be a starting point and the code would be in the correct format. The biggest problem will be the pins and level interface to the hardware. Using a UNO or Nano would be the easiest way.

Sorry then, its my first time using this site.

Im using ESP32, because after solving the self balancing problem, i want to control it via Bluetooth with my smart phone.

Im using the MPU6050, after the calibraionts, i got those ofsets:
Sensor readings with offsets: 0 3 16386 2 0 0
Your offsets: 2278 -580 630 138 64 -52
Data is printed as: acelX acelY acelZ giroX giroY giroZ
Check that your sensor readings are close to 0 0 16384 0 0 0

and this is how i connected the mpu6050:
VCC 3.3V
GND gnd
SCL G22
SDA G21
INT G23

with the motor driver, im using this:
L289 H BRIDGE
ENA – G32 //right side
ENB – G33 //left side
IN1 – G16 //right forward
IN2 – G17 //right backward
IN3 – G18 //left forward
IN4 – G19 //left backward

and this is the code what ive done with my values: #include "I2Cdev.h"
#include <PID_v1.h>
#include "MPU6050_6Axis_MotionApps20.h"

MPU6050 mpu;

#define DMP_INT_PIN 23

bool dmpReady = false;
uint8_t mpuIntStatus;
uint8_t devStatus;
uint16_t packetSize;
uint16_t fifoCount;
uint8_t fifoBuffer[64];

Quaternion q;
VectorFloat gravity;
float ypr[3];

double setpoint = 182;

double Kp = 40.0; // Csökkentett Kp érték
double Kd = 1.0; // Kd érték módosítása
double Ki = 1.0; // Kis Ki érték a finomhangoláshoz

double input, output;
PID pid(&output, &input, &setpoint, Kp, Ki, Kd, DIRECT);
volatile bool mpuInterrupt = false;

void dmpDataReady()
{
mpuInterrupt = true;
}

void setup() {
Serial.begin(115200);
Wire.begin(21, 22);
Serial.println(F("Initializing I2C devices..."));
mpu.initialize();

Serial.println(F("Testing device connections..."));
Serial.println(mpu.testConnection() ? F("MPU6050 connection successful") : F("MPU6050 connection failed"));
devStatus = mpu.dmpInitialize();

mpu.setXGyroOffset(138);
mpu.setYGyroOffset(64);
mpu.setZGyroOffset(-52);
mpu.setZAccelOffset(630);

if (devStatus == 0) {
Serial.println(F("Enabling DMP..."));
mpu.setDMPEnabled(true);

Serial.println(F("Enabling interrupt detection (Arduino external interrupt 0)..."));
attachInterrupt(digitalPinToInterrupt(23), dmpDataReady, RISING);
mpuIntStatus = mpu.getIntStatus();

Serial.println(F("DMP ready! Waiting for first interrupt..."));
dmpReady = true;

packetSize = mpu.dmpGetFIFOPacketSize();

pid.SetMode(AUTOMATIC);
pid.SetSampleTime(10);
pid.SetOutputLimits(-255, 255);

} else {
Serial.print(F("DMP Initialization failed (code "));
Serial.print(devStatus);
Serial.println(F(")"));
return; // Kilépés, ha a DMP nem sikerült
}

pinMode(32, OUTPUT); // ENA
pinMode(33, OUTPUT); // ENB
digitalWrite(32, HIGH); // ENA HIGH
digitalWrite(33, HIGH); // ENB HIGH

pinMode(16, OUTPUT);
pinMode(17, OUTPUT);
pinMode(18, OUTPUT);
pinMode(19, OUTPUT);

digitalWrite(16, LOW);
digitalWrite(17, LOW);
digitalWrite(18, LOW);
digitalWrite(19, LOW);
}

void loop() {
if (!dmpReady) return;

while (!mpuInterrupt && fifoCount < packetSize) {
pid.Compute();

Serial.print(input);
Serial.print("==>");
Serial.println(output);

if (input > 150 && input < 200) {
  if (output > 0) Forward();
  else if (output < 0) Reverse();
} else {
  Stop();
}

}

mpuInterrupt = false;
mpuIntStatus = mpu.getIntStatus();

fifoCount = mpu.getFIFOCount(); // Helyes FIFO méret beállítása

if (fifoCount == 1024) {
mpu.resetFIFO();
Serial.println(F("FIFO overflow!"));
} else if (fifoCount >= packetSize) {
mpu.getFIFOBytes(fifoBuffer, packetSize);
fifoCount -= packetSize;
mpu.dmpGetQuaternion(&q, fifoBuffer);
mpu.dmpGetGravity(&gravity, &q);
mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
input = ypr[1] * 180 / M_PI + 180; // pitch (y) értéke
}
}

void Forward() {
digitalWrite(16, HIGH);
digitalWrite(17, LOW);
digitalWrite(18, HIGH);
digitalWrite(19, LOW);
Serial.print("F");
}

void Reverse() {
digitalWrite(16, LOW);
digitalWrite(17, HIGH);
digitalWrite(18, LOW);
digitalWrite(19, HIGH);
Serial.print("R");
}

void Stop() {
digitalWrite(16, LOW);
digitalWrite(17, LOW);
digitalWrite(18, LOW);
digitalWrite(19, LOW);
Serial.print("S");
}