BMP180 Grove how to get it working on core2?
-
Hi,
I have been trying to get the BMP180 connected via Grove I2C to work and failed, Yes I'm new to the M5Stacks and struggling!My code is below, anyone tell me what's wrong or point me at an M5Core2 example?
#define M5STACK_MPU6886 #define SDA 25 #define SCL 13 #include <M5Core2.h> #include <Wire.h> //TwoWire Wire1 = TwoWire(1); #include <Adafruit_BMP085.h> Adafruit_BMP085 bmp; float pitch = 0.0F; float roll = 0.0F; float yaw = 0.0F; //averages float pitcha = 0.0F; float rolla = 0.0F; float yawa = 0.0F; int i = 0; void setup(){ // Initialize the M5Stack object M5.begin(); Wire.begin(SDA, SCL); //M5Stack SDA, SC //Wire1.begin(SDA, SCL, 400000); M5.IMU.Init(); delay(200); M5.Lcd.fillScreen(BLACK); M5.Lcd.setTextColor(GREEN , BLACK); M5.Lcd.setTextSize(2); if (!bmp.begin()) { M5.Lcd.println("BMP Error"); } } // the loop routine runs over and over again forever void loop() { // put your main code here, to run repeatedly:1 M5.IMU.getAhrsData(&pitch,&roll,&yaw); pitcha += pitch; rolla += roll; yawa += yaw; if (i > 60) //average every i loops { pitch = pitcha/i; roll = (rolla/i)-90; yaw = yawa/i; pitcha = 0; rolla = 0; yawa = 0; i=0; M5.Lcd.setCursor(10, 20); M5.Lcd.printf(" Bank %3.0f Pitch %3.0f ", pitch, roll); M5.Lcd.println(bmp.readTemperature()); } i++; delay(10); }
-
Hello,
could you please properly comment your code so it will be easier to copy paste it?
you can use ``` twice one on top of the code one on the bottom to comment it such asprint("hello world")
-
Hello @wadoadi
just curious, where did you get those pin numbers from?
#define SDA 25
#define SCL 13The Groove port (red) on M5Core2 uses GPIO32 / 33 for SDA and SCL.
Thanks
Felix -
@felmue I saw it in this thread commented out for the M5Stack
https://community.m5stack.com/topic/255/m5cam-and-bmp180/3I now have my application working, I had stupidly loaded the BMP180 when in fact, I have BMP280! also it has the alternative slave address...
-
Hello @wadoadi
I am glad to hear you got it working. And thanks for reporting back.
Happy Stacking!
Felix