diff --git a/Makefile b/Makefile index 3840052..ce61547 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ help: # plot - Plot the latest measurement - # monitor - Build and monitor onto esp if connected to /dev/ttyUSB0 + # mon - Monitor onto esp if connected to /dev/ttyUSB0 + # push - Build and monitor onto esp if connected to /dev/ttyUSB0 # env - Start the esp environment on nix # server - Start the go server diff --git a/main/station_example_main.c b/main/station_example_main.c index 1d5bd07..fe37693 100755 --- a/main/station_example_main.c +++ b/main/station_example_main.c @@ -1,9 +1,9 @@ /* - Voltage measurement device over WiFi (batched, 30 Hz) + Voltage measurement device over WiFi (batched, ~30 Hz with jitter) */ #include - +#include #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/event_groups.h" @@ -11,7 +11,6 @@ #include "esp_event.h" #include "esp_log.h" #include "nvs_flash.h" - #include "esp_adc/adc_cali.h" #include "esp_adc/adc_oneshot.h" #include "esp_adc/adc_cali_scheme.h" @@ -21,12 +20,12 @@ #define SERVER_URL "http://192.168.178.157:8080/data" -#define SAMPLE_RATE_HZ 30 +#define SAMPLE_RATE_HZ 20 #define SAMPLE_PERIOD_MS (1000 / SAMPLE_RATE_HZ) #define BATCH_SIZE 100 #define CHANNEL ADC_CHANNEL_6 -#define CALIBRATION_FACTOR 1650.0f +#define CALIBRATION_FACTOR 1600.0f #define EXAMPLE_ESP_WIFI_SSID "Jaguar" #define EXAMPLE_ESP_WIFI_PASS CONFIG_ESP_WIFI_PASSWORD @@ -193,8 +192,9 @@ static void measure_task(void *arg) count = 0; } + int jitter = (rand() % 10) - 5; // ±2 ms random vTaskDelayUntil(&last_wake, - pdMS_TO_TICKS(SAMPLE_PERIOD_MS)); + pdMS_TO_TICKS(SAMPLE_PERIOD_MS + jitter)); } }