Hi,
I'm doing a test on ESP32 with MPU6050 accelerometer for brake light (LED) but i could not get accel reading from output. The sketch below could
compile and the setup part is ok with output ( Setup complete ). It then just hang there. I've check for loose connection which is ok (see attached pic). Since the vcc, scl and sda pin are all in 3.3v , i didn't use any level shifter. i've added 3k ohms pullup resistor each to scl and sda line.
Any help to solve this problem is much appreciated. Thanks.
==================================================================================================
#include <Wire.h>
const int MPU_ADDR = 0x68; // equals to 0b1101000
int AcX, AcY, AcZ;
float gForceX, gForceY, gForceZ;
const float g = 16384.0;
void setup() {
Serial.begin(115200);
Wire.begin((int)21, (int)22, (uint32_t)100000);
Wire.beginTransmission( MPU_ADDR );
Wire.write( 0x6B ); // PWR_MGMT_1 register
Wire.write( 0 ); // set to zero (wakes up the MPU−6050)
Wire.endTransmission( true );
Serial.println( "Setup complete" );
}
void loop() {
Wire.beginTransmission( MPU_ADDR );
Wire.write( 0x3B ); // starting with register 0x3B (ACCEL_XOUT_H)
Wire.endTransmission( true ); // true to Wire.endTransmission() >>> ESP32 send stop command and release I2C lines
Wire.beginTransmission( MPU_ADDR );
Wire.requestFrom( (int)MPU_ADDR , (int)6 , (int)true ); // request a total of 6 registers
AcX = Wire.read() << 8 | Wire.read(); // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)
AcY = Wire.read() << 8 | Wire.read(); // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
AcZ = Wire.read() << 8 | Wire.read(); // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
gForceX = AcX / g;
gForceY = AcY / g;
gForceZ = AcZ / g;
Serial.print( gForceX ); Serial.print( " , " );
Serial.print( gForceY ); Serial.print( " , " );
Serial.print( gForceZ ); Serial.println( " , " );
}
MPU6050 accelerometer without serial output
MPU6050 accelerometer without serial output
- Attachments
-
- 20220427_033219.jpg (3.14 MiB) Viewed 2584 times
学习中找战友。
-
- Posts: 101
- Joined: Tue Mar 22, 2022 5:23 am
Re: MPU6050 accelerometer without serial output
Hi, what error are you seeing? Is there no data in the serial monitor? Or you're getting unrealistic data?
Did you use the 4.7k ohms resistors as shown here?
https://www.theengineeringprojects.com/ ... u6050.html
If your board already has these resistors, then you don't need these 4.7 K ohm pull-up resistors.
You can check this too to see if you're missing any point: https://randomnerdtutorials.com/esp32-m ... e-arduino/
Did you use the 4.7k ohms resistors as shown here?
https://www.theengineeringprojects.com/ ... u6050.html
If your board already has these resistors, then you don't need these 4.7 K ohm pull-up resistors.
You can check this too to see if you're missing any point: https://randomnerdtutorials.com/esp32-m ... e-arduino/
Re: MPU6050 accelerometer without serial output
Hi,
Thanks for the 2 links , i'm going over it.
1) the output that i got (see below) , then it just hang. I press reset button, same thing happen.
I actually tried on arduino nano with mpu6050 and level shifter, it work with g readings.
20:57:39.648 -> ets Jun 8 2016 00:22:57
20:57:39.648 ->
20:57:39.648 -> rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
20:57:39.648 -> configsip: 0, SPIWP:0xee
20:57:39.648 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
20:57:39.648 -> mode:DIO, clock div:1
20:57:39.648 -> load:0x3fff0030,len:1324
20:57:39.648 -> ho 0 tail 12 room 4
20:57:39.648 -> load:0x40078000,len:13508
20:57:39.648 -> load:0x40080400,len:3604
20:57:39.648 -> entry 0x400805f0
20:57:39.648 -> Setup complete
2) I change the external pullup resistor to 4.7k ohms for scl and sda lines, but still no result. even try up to 10k ohms still no go.
3) did you mean 4.7k ohm in MPU6050 board? i saw a resistor with 472 marking.
Thanks for the 2 links , i'm going over it.
1) the output that i got (see below) , then it just hang. I press reset button, same thing happen.
I actually tried on arduino nano with mpu6050 and level shifter, it work with g readings.
20:57:39.648 -> ets Jun 8 2016 00:22:57
20:57:39.648 ->
20:57:39.648 -> rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
20:57:39.648 -> configsip: 0, SPIWP:0xee
20:57:39.648 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
20:57:39.648 -> mode:DIO, clock div:1
20:57:39.648 -> load:0x3fff0030,len:1324
20:57:39.648 -> ho 0 tail 12 room 4
20:57:39.648 -> load:0x40078000,len:13508
20:57:39.648 -> load:0x40080400,len:3604
20:57:39.648 -> entry 0x400805f0
20:57:39.648 -> Setup complete
2) I change the external pullup resistor to 4.7k ohms for scl and sda lines, but still no result. even try up to 10k ohms still no go.
3) did you mean 4.7k ohm in MPU6050 board? i saw a resistor with 472 marking.
学习中找战友。
Who is online
Users browsing this forum: No registered users and 23 guests