// Based on: https://wokwi.com/projects/455217870823491585
// Added I2C Scanner.
/*
Basic BMP180 pressure / MPU6050 Accel & Gyro Demo
February 2026
*/
#include <Wire.h>
#include <Adafruit_BMP085.h>
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
sensors_event_t a, g, temp;
Adafruit_MPU6050 mpu;
Adafruit_BMP085 bmp;
void setup() {
Serial.begin(115200);
// -------------------------------------------
// I2C Scanner.
// -------------------------------------------
Wire.begin();
Serial.print("Scanning I2C bus: ");
bool found = false;
for(int address = 1; address <= 127; address++)
{
Wire.beginTransmission(address);
int error = Wire.endTransmission();
if(error == 0)
{
found = true;
Serial.print("0x");
if(address < 0x10)
Serial.print("0");
Serial.print(address,HEX);
Serial.print(", ");
}
}
if(found)
Serial.println();
else
Serial.println("--> nothing found.");
// -------------------------------------------
delay(2000);
if (!bmp.begin()) {
Serial.println("BMP180 not found!");
while (1);
}
if (!mpu.begin()) {
Serial.println("MPU6050 not connected!");
while (1);
}
Serial.println("MPU6050 ready!");
Serial.println("BMP180 ready!\n");
}
void loop() {
// get data
int32_t pressure = bmp.readPressure();
float altitude = bmp.readAltitude();
float temperature = bmp.readTemperature();
mpu.getEvent(&a, &g, &temp);
// print it out
Serial.print("Temperature:\t");
Serial.print(temperature, 1);
Serial.println(" °C");
Serial.print("Pressure:\t");
Serial.print(pressure / 100.0);
Serial.println(" hPa");
Serial.print("Altitude:\t");
Serial.print(altitude);
Serial.println(" m");
Serial.print("Acceleration:\t");
Serial.print("X: ");
Serial.print(a.acceleration.x);
Serial.print(", Y: ");
Serial.print(a.acceleration.y);
Serial.print(", Z: ");
Serial.print(a.acceleration.z);
Serial.println(" m/s^2");
Serial.print("Rotation:\t");
Serial.print("X: ");
Serial.print(g.gyro.x);
Serial.print(", Y: ");
Serial.print(g.gyro.y);
Serial.print(", Z: ");
Serial.print(g.gyro.z);
Serial.println(" rad/s");
Serial.println();
delay(2000);
}
Loading
bmp180
bmp180