To add a Sensor to the ESP32 first search for the Sensor name on the ESPHome Website:
In our example we search for MPU6050 and come to this page:
https://esphome.io/components/sensor/mpu6050.html
As we can read in the second Line on the page this Sensor uses I2C Bus so we also come to this page:
To add I2C Bus to our Firmware we need to add it to our Config with the right GPIO Pins for our board.
The PIN out of our ESP32s is this:
As we can see we have SDA = GPIO21 and SLC = GPIO22.
So we connect our Sensor to this Ports and also added them to the config:
On the Website for the MPU6050 we can see that the Sensor captures Data for Acceleration and Angle in X, Y, Z as well as Temprature.
For this example we only going to use the Acceleration Data so we add the following Lines to our Config:
Now we can create a new Firmware and load it onto the ESP32 like before.
If we take a look at the Logs of a freshly booted device we should see the following: