// This code runs in the Wokwi online ESP32 simulator
// Define tremor characteristics for Parkinson's
const float TREMOR_FREQUENCY = 5.0; // 5 Hz, typical for Parkinson's
const float AMPLITUDE = 0.5; // Tremor intensity
const int SAMPLING_RATE_HZ = 100; // 100 samples per second
const int DELAY_MS = 1000 / SAMPLING_RATE_HZ;
unsigned long startTime = 0;
void setup() {
Serial.begin(115200);
startTime = millis();
// Print a header that matches your Python script's column names
Serial.println("Timestamp,Accel_X,Accel_Y,Accel_Z,Gyro_X,Gyro_Y,Gyro_Z");
}
void loop() {
// Calculate elapsed time in seconds
float t = (millis() - startTime) / 1000.0;
// Simulate a 5 Hz tremor on the Z-axis of the gyroscope
float gyro_z = AMPLITUDE * sin(2 * PI * TREMOR_FREQUENCY * t);
// Create a CSV formatted string with placeholder values for other axes
String dataString = String(t) + "," +
"0.0," + "0.0," + "9.8," +
"0.0," + "0.0," + String(gyro_z);
// Print the data to the serial monitor
Serial.println(dataString);
// Wait for the correct amount of time to maintain the sampling rate
delay(DELAY_MS);
}