-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from senseshift/feature/mpu6050
✨ Add MPU6050
- Loading branch information
Showing
13 changed files
with
891 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ | |
.vscode/c_cpp_properties.json | ||
.vscode/launch.json | ||
.vscode/ipch | ||
|
||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include <I2CDevLib.h> | ||
#include <i2cdev/mpu6050.hpp> | ||
|
||
i2cdev::MPU6050 mpu6050; | ||
|
||
void setup(void) { | ||
Serial.begin(115200); | ||
while (!Serial) | ||
delay(10); // will pause Zero, Leonardo, etc until serial console opens | ||
|
||
Wire.begin(); | ||
|
||
Serial.println("I2CDevLibContrib MPU6050 test!"); | ||
|
||
// Wait for the MPU6050 to be ready | ||
delay(1000); | ||
|
||
if (mpu6050.check() != I2CDEV_RESULT_OK) { | ||
Serial.println("Failed to find MPU6050 chip"); | ||
while (true) {} | ||
} | ||
Serial.println("MPU6050 Found!"); | ||
|
||
if (mpu6050.reset() != I2CDEV_RESULT_OK) { | ||
Serial.println("Failed to reset MPU6050 chip"); | ||
while (true) {} | ||
} | ||
|
||
mpu6050.setAccelerometerRange(MPU6050_ACCEL_RANGE_8G); | ||
mpu6050.setGyroscopeRange(MPU6050_GYRO_RANGE_500_DEG); | ||
mpu6050.setFilterBandwidth(MPU6050_BANDWIDTH_21_HZ); | ||
|
||
Serial.println(""); | ||
delay(100); | ||
} | ||
|
||
void loop() { | ||
auto measurements = mpu6050.getAllMeasurements(); | ||
|
||
Serial.print("Accelerometer X: "); Serial.print(measurements.accel.x); Serial.print(" Y: "); Serial.print(measurements.accel.y); Serial.print(" Z: "); Serial.println(measurements.accel.z); | ||
Serial.print("Gyroscope X: "); Serial.print(measurements.gyro.x); Serial.print(" Y: "); Serial.print(measurements.gyro.y); Serial.print(" Z: "); Serial.println(measurements.gyro.z); | ||
Serial.print("Temperature: "); Serial.print(measurements.temperature); Serial.println(" C"); | ||
Serial.println(""); | ||
|
||
delay(500); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"version": 1, | ||
"author": "Leonid Meleshin", | ||
"editor": "wokwi", | ||
"parts": [ | ||
{ "type": "wokwi-arduino-uno", "id": "uno", "top": 0.6, "left": -0.6, "attrs": {} }, | ||
{ | ||
"type": "wokwi-mpu6050", | ||
"id": "imu1", | ||
"top": -131.42, | ||
"left": 166.12, | ||
"rotate": -90, | ||
"attrs": {} | ||
} | ||
], | ||
"connections": [ [ "uno:A4.2", "imu1:SDA", "green", [ "v0" ] ], [ "uno:A5.2", "imu1:SCL", "green", [ "v0" ] ] ], | ||
"dependencies": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: Test MPU6050/BasicReadings | ||
version: 1 | ||
author: Leonid Meleshin | ||
|
||
steps: | ||
- wait-serial: "MPU6050 Found!" | ||
|
||
- wait-serial: "Accelerometer X: 0.00 Y: 0.00 Z: 1.00" | ||
- wait-serial: "Gyroscope X: 0.00 Y: 0.00 Z: 0.00" | ||
- wait-serial: "Temperature: 24.00 C" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[wokwi] | ||
version = 1 | ||
firmware = "./firmware.hex" | ||
elf = "./firmware.elf" | ||
|
||
gdbServerPort=3333 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.