#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>
const float BETA = 3950;
Adafruit_MPU6050 mpu;
void setup() {
Serial.begin(9600);
analogReadResolution(10);
pinMode(15,INPUT);
pinMode(14,OUTPUT);
if (!mpu.begin()) {
Serial.println("Failed to find MPU6050 chip");
while (1) {
delay(10);
}
}
mpu.setAccelerometerRange(MPU6050_RANGE_8_G);
mpu.setGyroRange(MPU6050_RANGE_250_DEG);
mpu.setFilterBandwidth(MPU6050_BAND_21_HZ);
Serial.println("");
delay(1000);
}
void loop() {
int analogValue = analogRead(15);
float celsius = 1 / (log(1 / (1023. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
Serial.println("");
Serial.print("Temperature: ");
Serial.print(celsius);
Serial.print(" ℃");
Serial.println("");
sensors_event_t a, g, temp;
mpu.getEvent(&a, &g, &temp);
Serial.println("Acelerometro:");
Serial.print(a.acceleration.x);
Serial.print(",");
Serial.print(a.acceleration.y);
Serial.print(",");
Serial.println(a.acceleration.z);
Serial.println("");
Serial.println("Giroscopio:");
Serial.print(g.gyro.x);
Serial.print(",");
Serial.print(g.gyro.y);
Serial.print(",");
Serial.print(g.gyro.z);
Serial.println("");
delay(1000);
}