|
1 | 1 | #include <Arduino.h> |
2 | | -#include "sensors/max30102.h" |
3 | | -#include "sensors/am2303.h" |
4 | | -#include "sensors/lm393.h" |
5 | | -#include "actuators/ermc1604syg.h" |
6 | | -#include "actuators/sfm27.h" |
7 | | -#include "modes/monitoring.h" |
8 | | - |
9 | | -// Create sensor and actuator objects |
10 | | -HeartRateSensor hrSensor; |
11 | | -Environmental envSensor; |
12 | | -LightSensor lightSensor; |
13 | | -Display display; |
14 | | -Buzzer buzzer; |
15 | | - |
16 | | -// Monitoring system instance |
17 | | -MonitoringSystem monitoring(&hrSensor, &envSensor, &lightSensor, &display, &buzzer); |
| 2 | +#include "sensors/mpu6050.h" |
| 3 | + |
| 4 | +MotionTracker motion; |
18 | 5 |
|
19 | 6 | void setup() { |
20 | 7 | Serial.begin(115200); |
21 | | - while (!Serial) ; // wait for Serial monitor |
| 8 | + delay(1000); |
22 | 9 |
|
23 | | - Serial.println("=== Monitoring System Test ==="); |
| 10 | + Serial.println(); |
| 11 | + Serial.println("=== MotionTracker Test ==="); |
24 | 12 |
|
25 | | - // Initialize system |
26 | | - if (!monitoring.initialize()) { |
27 | | - Serial.println("Initialization failed. Check sensors."); |
28 | | - while (1) delay(1000); |
| 13 | + if (!motion.begin()) { |
| 14 | + Serial.println("ERROR: MPU6050 not detected!"); |
| 15 | + while (true) { |
| 16 | + delay(1000); |
| 17 | + } |
29 | 18 | } |
30 | 19 |
|
31 | | - // Calibrate sensors |
32 | | - monitoring.calibrateSensors(); |
| 20 | + Serial.println("MPU6050 detected successfully."); |
| 21 | + delay(500); |
33 | 22 |
|
34 | | - // Start continuous monitoring |
35 | | - monitoring.startMonitoring(); |
| 23 | + motion.autoCalibrate(); |
| 24 | + Serial.println("Starting live data output..."); |
| 25 | + Serial.println(); |
36 | 26 | } |
37 | 27 |
|
38 | 28 | void loop() { |
39 | | - // Update monitoring system |
40 | | - monitoring.update(); |
| 29 | + motion.update(); |
41 | 30 |
|
42 | | - // Optional: debug output via Serial |
43 | | - MonitoringData data = monitoring.getCurrentData(); |
| 31 | + Serial.print("Pitch: "); |
| 32 | + Serial.print(motion.getPitch(), 2); |
| 33 | + Serial.print(" deg | Roll: "); |
| 34 | + Serial.print(motion.getRoll(), 2); |
| 35 | + Serial.print(" deg"); |
44 | 36 |
|
45 | | - Serial.print("HR: "); Serial.print(data.heartRate); |
46 | | - Serial.print(" bpm | SpO2: "); Serial.print(data.spO2); |
47 | | - Serial.print("% | Temp: "); Serial.print(data.bodyTemp); |
48 | | - Serial.print("°C | Ambient: "); Serial.print(data.ambientTemp); |
49 | | - Serial.print("°C | Humidity: "); Serial.print(data.humidity); |
50 | | - Serial.print("% | Light: "); Serial.println(data.lightLevel); |
| 37 | + Serial.print(" | Ax: "); |
| 38 | + Serial.print(motion.getAccelX(), 3); |
| 39 | + Serial.print(" g"); |
51 | 40 |
|
52 | | - delay(1000); |
| 41 | + Serial.print(" | Ay: "); |
| 42 | + Serial.print(motion.getAccelY(), 3); |
| 43 | + Serial.print(" g"); |
| 44 | + |
| 45 | + Serial.print(" | Az: "); |
| 46 | + Serial.print(motion.getAccelZ(), 3); |
| 47 | + Serial.print(" g"); |
| 48 | + |
| 49 | + Serial.print(" | FwdAcc: "); |
| 50 | + Serial.print(motion.getForwardAcceleration(), 3); |
| 51 | + Serial.print(" g"); |
| 52 | + |
| 53 | + Serial.print(" | SideAcc: "); |
| 54 | + Serial.print(motion.getSideAcceleration(), 3); |
| 55 | + Serial.print(" g"); |
| 56 | + |
| 57 | + Serial.println(); |
| 58 | + |
| 59 | + delay(500); // ~20 Hz output |
53 | 60 | } |
0 commit comments