I wanted to create a project using node mcu and alexa echo device, the first part of the project is where I wanted to know what the alexa is sending to node mcu by writing on serial monitor what node mcu has received from alexa.
The alexa device and the node mcu are on the same wifi network.
Below is my code but I am having a compilation error,
Compilation error: no matching function for call to 'Espalexa::addDevice(String&, void (&)())'
please help me fixing it
void setup() {
Serial.begin(9600);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
// Add a virtual device to be discovered by Alexa
espalexa.addDevice(requestBody, handleRequest); // Specify the callback function without parentheses
espalexa.begin();
server.on("/", HTTP_POST, handleRequest); // Specify the callback function without parentheses
server.begin();
}
void loop() {
server.handleClient();
espalexa.loop(); // Include this to handle Espalexa tasks
}
#include <ESP8266WiFi.h>
#include <Espalexa.h>
const char* ssid = "ssid";
const char* password = "password";
String requestBody = "Switch";
ESP8266WebServer server(80);
Espalexa espalexa;
void SwitchChanged();
void handleRequest() {
requestBody = server.arg("plain"); // Get the POST data
Serial.println(requestBody);
server.send(200, "text/plain", "Data received");
}
void setup() {
Serial.begin(9600);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
// Add a virtual device to be discovered by Alexa
espalexa.addDevice(requestBody, handleRequest); // Specify the callback function without parentheses
espalexa.begin();
server.on("/", HTTP_POST, handleRequest); // Specify the callback function without parentheses
server.begin();
}
void loop() {
server.handleClient();
espalexa.loop(); // Include this to handle Espalexa tasks
}Use code tags to format code for the forum
I moved your topic to an appropriate forum category @bobby8266 .
In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.