Can't read sensors value with http request

Hello everyone,

I build a robot for educational purpose. It's based on ESP32 and have multiple sensors (DHT22, Photoresistance, Ultrasonic).

I connect a device to the esp server on wifi and command the robot with http requests.

I can move the robot (servomotors) with SNAP like this :

But I can't read the sensors values. It's work with navigator.

Capture d’écran 2022-09-12 à 16.05.23

and here the code for "/LireDistance" request :

server.on("/LireDistance", HTTP_GET, [](AsyncWebServerRequest *request)

{
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

float duration = pulseIn(echoPin, HIGH);
float d = 0.017 * duration;

Serial.print("Distance = ");
Serial.println(d);
request->send(200, "text/plain", String(d));

});

I try to respond the request with json but it's the same. Snap would be able to read a string.

Can someone help me with this issue please ?

Sorry for my limited English I'm French.

Trying running Snap! from
http://extensions.snap.berkeley.edu/snap/snap.html

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.