Skip to content

Commit ebd31dd

Browse files
committed
rtc data added
1 parent 2ed9588 commit ebd31dd

File tree

5 files changed

+9
-225
lines changed

5 files changed

+9
-225
lines changed

examples/03-mpu9250/.DS_Store

6 KB
Binary file not shown.

examples/03-mpu9250/main.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
import utime
15-
from machine import SoftI2C, Pin
15+
from machine import SoftI2C, Pin, RTC
1616
import math
1717
from mpu9250 import MPU9250
1818
# from mpu6500 import MPU6500, SF_G, SF_DEG_S
@@ -71,6 +71,8 @@ def Kalman_filter(angle, gyroRate, accelAngle):
7171
toRad = 2.0*math.pi / 360
7272
toDeg = 1 / toRad
7373

74+
rtc = RTC()
75+
7476
i2c = SoftI2C(scl=Pin(22), sda=Pin(21))
7577
print(f"I2C configuration: {str(i2c)}")
7678

@@ -94,6 +96,8 @@ def Kalman_filter(angle, gyroRate, accelAngle):
9496
print("MPU9250 id: " + hex(sensor.whoami))
9597
print("\nPress `Ctrl+C` to stop\n")
9698

99+
print("datetime,roll,pitch,yaw")
100+
97101
try:
98102
while True:
99103
ax, ay, az = sensor.acceleration
@@ -127,9 +131,12 @@ def Kalman_filter(angle, gyroRate, accelAngle):
127131
yaw -= 2 * math.pi
128132
yaw = yaw * toDeg
129133

134+
(year, month, day, wday, hrs, mins, secs, subsecs) = rtc.datetime()
135+
print(f"{year}-{month}-{day} {hrs}:{mins}:{secs}.{subsecs},", end="")
136+
130137
# print(f"{roll:.1f},{pitch:.1f},{yaw:.1f},{temp:.1f}")
131138
print(f"{roll:.1f},{pitch:.1f},{yaw:.1f}")
132-
utime.sleep_ms(20) # 50 Hz
139+
utime.sleep_ms(1) # 50 Hz
133140

134141
except KeyboardInterrupt:
135142
# This part runs when Ctrl+C is pressed

examples/03-mpu9250/python/test_serial.py

-16
This file was deleted.

examples/03-mpu9250/python/vizualization_3d.py

-53
This file was deleted.

examples/11-gps/test_sentences.py

-154
This file was deleted.

0 commit comments

Comments
 (0)