How can I make alexa discover devices made by Node MCU ESP8266

bobby8266
Posts: 1
Joined: Sun Aug 20, 2023 6:40 pm

How can I make alexa discover devices made by Node MCU ESP8266

Postby bobby8266 » Sun Aug 20, 2023 6:45 pm

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
#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
}

Who is online

Users browsing this forum: No registered users and 43 guests