Hello, I'm quite new to the whole networking stuff, so it might be easier than I thought.
I have a project where read a sensor with a relatively high refresh rate (~500Hz) and store it to an sd card. Meanwhile the ESP hosts a small page as AP showing infos about the measurement (not the stored data itself). After the measurement I can pull the Data over that page.
Now I want to live stream the sensor data to a remote pc, since the sensor works with an FIFO Buffer it should work with udp packages, but I don't really know how to do that.
And since the whole measurement takes place outside without no wifi networks around, the esp32 would need to host the network itself while sending said packages. Is that even possible?
My current sketch looks something like this (pseudocode)
#include <WiFi.h>
#include <WiFiAP.h>
#include <WebServer.h>
... other #include
char* ssid = "Sensor";
char* password = "password123";
... sensor and SD settings
WebServer server(80);
void setup(){
...
WiFi.softAP(ssid,password);
server.on("/",handleRoot);
server.onNotFound(handleFileReadURI);
server.begin();
...
}
void loop(){
timer.update();
server.handleClient();
}
void measure(){ //reads the sensor and writes it to the sd card -> callback from timer in loop
...
}
void handleRoot(){ //shows percentage of measurement done and the whole SD directory if done
if (measuring){
cont = ...
} else {
cont = ...
listDir(SD, "/", 2); // creates a link for every file on sd, so i can download them per handleFileReadURI (adds to cont)
}
server.send(200, "text/html", cont);
}
bool handleFileReadURI(){
if (measuring){
server.send(200, "text/plain", "measuring...");
}else{
file = SD.open(server.uri(),FILE_READ);
if (file){
String test = String(file.size());
size_t sent = server.streamFile(file, "text/comma-separated-values");
file.close();
} else {
server.send(200, "text/plain", "not found");
}
}
}