Need to improve the sampling rate of MPU6050 sensor... #8516
Replies: 2 comments
-
Going to be hard to improve due to file writing, maybe try and buffer the
data to sector size at a time and write it all at the same time or cluster
size.....also make sure i2c is set high like 400khz
…On Sat., Mar. 19, 2022, 01:04 maheshnakate009, ***@***.***> wrote:
Using MPU 6050 with arduino uno I am trying to get accelerometer and
gyroscope data through I2C protocol....Currently I am getting 27
accelerometer samples per second.....I want to get atleast 90 to 100
accelerometer samples per second.... Can somebody plz help me with the
proper programming code... Below is the code which I am using for my
project...
include <MPU6050_tockn.h> include <SPI.h> include <SD.h> include <DS3231.h>
DS3231 rtc(SDA, SCL); const int chipSelect = 4; MPU6050 mpu6050(Wire);
long timer = 0;
void setup() { Serial.begin(9600); rtc.begin(); rtc.setDate(27, 11, 2021);
rtc.setTime(10, 30, 0); mpu6050.begin();
Serial.print("Initializing SD card..."); if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present"); while (1); }
Serial.println("card initialized."); } void loop() { mpu6050.update();
Serial.print(rtc.getDateStr()); Serial.print(",");
Serial.write(rtc.getTimeStr()); Serial.print(",");
Serial.print(mpu6050.getAccX()); Serial.print(",");
Serial.print(mpu6050.getAccY()); Serial.print(",");
Serial.println(mpu6050.getAccZ());
File dataFile = SD.open("dataset1.txt", FILE_WRITE); if (dataFile) {
dataFile.print(rtc.getDateStr()); dataFile.print(",");
dataFile.print(rtc.getTimeStr()); dataFile.print(",");
dataFile.print(mpu6050.getAccX()); dataFile.print(",");
dataFile.print(mpu6050.getAccY()); dataFile.print(",");
dataFile.println(mpu6050.getAccZ()); dataFile.close();
}
else { Serial.println("error opening imulog.txt"); } }
—
Reply to this email directly, view it on GitHub
<#8516>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACBV22MOXHDCUXONIXRUJMLVAVN65ANCNFSM5RDQGQKA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Also I would read rtc once and track time on your own, too much overhead
reading it all the time
…On Sat., Mar. 19, 2022, 01:04 maheshnakate009, ***@***.***> wrote:
Using MPU 6050 with arduino uno I am trying to get accelerometer and
gyroscope data through I2C protocol....Currently I am getting 27
accelerometer samples per second.....I want to get atleast 90 to 100
accelerometer samples per second.... Can somebody plz help me with the
proper programming code... Below is the code which I am using for my
project...
include <MPU6050_tockn.h> include <SPI.h> include <SD.h> include <DS3231.h>
DS3231 rtc(SDA, SCL); const int chipSelect = 4; MPU6050 mpu6050(Wire);
long timer = 0;
void setup() { Serial.begin(9600); rtc.begin(); rtc.setDate(27, 11, 2021);
rtc.setTime(10, 30, 0); mpu6050.begin();
Serial.print("Initializing SD card..."); if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present"); while (1); }
Serial.println("card initialized."); } void loop() { mpu6050.update();
Serial.print(rtc.getDateStr()); Serial.print(",");
Serial.write(rtc.getTimeStr()); Serial.print(",");
Serial.print(mpu6050.getAccX()); Serial.print(",");
Serial.print(mpu6050.getAccY()); Serial.print(",");
Serial.println(mpu6050.getAccZ());
File dataFile = SD.open("dataset1.txt", FILE_WRITE); if (dataFile) {
dataFile.print(rtc.getDateStr()); dataFile.print(",");
dataFile.print(rtc.getTimeStr()); dataFile.print(",");
dataFile.print(mpu6050.getAccX()); dataFile.print(",");
dataFile.print(mpu6050.getAccY()); dataFile.print(",");
dataFile.println(mpu6050.getAccZ()); dataFile.close();
}
else { Serial.println("error opening imulog.txt"); } }
—
Reply to this email directly, view it on GitHub
<#8516>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACBV22MOXHDCUXONIXRUJMLVAVN65ANCNFSM5RDQGQKA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Using MPU 6050 with arduino uno I am trying to get accelerometer and gyroscope data through I2C protocol....Currently I am getting 27 accelerometer samples per second.....I want to get atleast 90 to 100 accelerometer samples per second.... Can somebody plz help me with the proper programming code... Below is the code which I am using for my project...
include <MPU6050_tockn.h> include <SPI.h> include <SD.h> include <DS3231.h>
DS3231 rtc(SDA, SCL); const int chipSelect = 4; MPU6050 mpu6050(Wire); long timer = 0;
void setup() { Serial.begin(9600); rtc.begin(); rtc.setDate(27, 11, 2021); rtc.setTime(10, 30, 0); mpu6050.begin();
Serial.print("Initializing SD card..."); if (!SD.begin(chipSelect)) { Serial.println("Card failed, or not present"); while (1); } Serial.println("card initialized."); } void loop() { mpu6050.update();
Serial.print(rtc.getDateStr()); Serial.print(","); Serial.write(rtc.getTimeStr()); Serial.print(",");
Serial.print(mpu6050.getAccX()); Serial.print(","); Serial.print(mpu6050.getAccY()); Serial.print(","); Serial.println(mpu6050.getAccZ());
File dataFile = SD.open("dataset1.txt", FILE_WRITE); if (dataFile) { dataFile.print(rtc.getDateStr()); dataFile.print(","); dataFile.print(rtc.getTimeStr()); dataFile.print(",");
dataFile.print(mpu6050.getAccX()); dataFile.print(","); dataFile.print(mpu6050.getAccY()); dataFile.print(","); dataFile.println(mpu6050.getAccZ()); dataFile.close();
}
else { Serial.println("error opening imulog.txt"); } }
Beta Was this translation helpful? Give feedback.
All reactions