Hi, This is my first project with an Arduino Nano 33 IoT and also my first post on this forum, so please let me know if theres any additional info i can provide.
I have a small servo controlling my window blinds, controlled by the arduino. it runs a very basic webserver that gets requests from homebridge, so i can control the position via apple home. My issue is, after the first http request, the code execution slows down by a factor of 20 roughly (i.e before the LED blinks every ~500ms and afterwards every ~10s ) and eventually the arduino doesnt respond at all. i added a small blinking script to the main loop to make this more visible. After some testing it seems like the server.available() call causes this. The issue persists, even when removing the entire control logic, thats why im just posting the code snippet without it.i cant find any info on why this happens exactly or how to fix it, any help is appreciated.
Stuff i've already tried:
replace all Strings with char[].
remove literally all code but the server.available() call
have client.stop() outside both if conditions
My Code:
int led_counter = 0;
bool led_status = 1;
int status = WL_IDLE_STATUS;
//more vars
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
myStepper.setSpeed(rolePerMinute);
//Setup wifi
while (status != WL_CONNECTED) {
status = WiFi.begin(ssid, pass);
delay(5000);
}
server.begin();
}
void loop() {
led_counter += 1;
if(led_counter>=50000){
digitalWrite(LED_BUILTIN,led_status);
led_counter = 0;
led_status = !led_status;
}
WiFiClient client = server.available();
if(client){
if(client.available()){
//read and parse request
client.stop();
}
}
}