vintlabs / fauxmoESP

Add voice control of your ESP32 and ESP8266 devices using Amazon Alexa
MIT License
383 stars 69 forks source link

adding sensor data output #78

Closed pvint closed 5 years ago

pvint commented 5 years ago

Original report by Andy Droid (Bitbucket: rainyodd, ).


Not an issue but while i'm here! Is it possible to add a sensor to a gpio pin and send the data using the server created by fauxmoESP? Not to Alexa just to a web page. (although that would be cool to get message from her when my sensor triggered.) In the example file "fauxmoESP_External_Server" i find this. server.on("/index.html", HTTP_GET, [](AsyncWebServerRequest *request){ request->send(200, "text/plain", "Hello, world");

I find the IP address using serial monitor and go to index.html and sure enough i get the hello world message. But after that i'm lost. I can do all the sensor reading stuff just, lost on the sending data. Any help appreciated.

pvint commented 5 years ago

Original comment by Peter Feerick (Bitbucket: pfeerick, GitHub: pfeerick).


This snippet basically means that when the file 'index.html' is requested from device, a message of "Hello world" is sent as a response.

    server.on("/index.html", HTTP_GET, [](AsyncWebServerRequest *request){
        request->send(200, "text/plain", "Hello, world");

You could change the "/index.html" bit to just "/" and then you'd only have to type the device IP in. And if if you have your sensor data in a global global var, you can, for example, just tack it onto the end. Meaning that:

request->send(200, "text/plain", "Hello, world");

would look like

request->send(200, "text/plain", "Hello, world! My cool sensor value is " + sensorValue);
pvint commented 5 years ago

Original comment by Xose Pérez (Bitbucket: [Xose Pérez](https://bitbucket.org/Xose Pérez), ).


Thanks for the question & answer, but this is not the right place.