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.
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.