vintlabs / fauxmoESP

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

After many hours trying I still cannot get Alexa to discover my ESP8266 #145

Closed PauloFDO closed 3 years ago

PauloFDO commented 3 years ago

as the title says I'm as lost as I was when I started, for some reason I cannot get Alexa to discover my ESP8266, I tried everything that I could find online or think about, changed the code many times, my device is correctly connected (I can see it connected in my router), and the code seems to be running fine (the serial.println is showing everything just fine) but the device cannot be discovered on my Alexa APP no matter what, I noticed the "?" on the github main page so can I assume that this in an combability issue Or am I'm doing something silly?

my ESP8266 : https://www.amazon.co.uk/gp/product/B08NJGVZVR/ref=ppx_yo_dt_b_asin_title_o03_s00?ie=UTF8&psc=1 My amazon echo dot: https://www.amazon.co.uk/gp/product/B084DWCZXZ/ref=ppx_yo_dt_b_asin_title_o02_s00?ie=UTF8&psc=1

Code:

`

#include <ESP8266WiFi.h>          //https://github.com/esp8266/Arduino
#include <ESP8266WebServer.h>
#include <DNSServer.h>
#include <WiFiManager.h>  
#include <Arduino.h>
#include <fauxmoESP.h>
#include <ESPAsyncTCP.h>
#include <Hash.h>

fauxmoESP fauxmo;
bool MoveCommand = false;

void setup() {
  Serial.begin(115200);
  WifiSetup();
  AlexaSetup();
}

void AlexaSetup(){

  fauxmo.addDevice("motor on");
    fauxmo.setPort(80); // required for gen3 devices
    fauxmo.enable(true);

  fauxmo.onSetState([](unsigned char device_id, const char * device_name, bool state, unsigned char value) {
    Serial.println("alexa can hear you");
        MoveCommand = true;
    });

      Serial.println("alexa device setup complete");
}

void WifiSetup(){
    // put your setup code here, to run once:
  // initialize the LED digital pin as an output.
  Serial.println("\n Starting wifi");
  unsigned long startedAt = millis();
  WiFi.printDiag(Serial); //Remove this line if you do not want to see WiFi password printed
  Serial.println("Opening configuration portal");
  //Local intialization. Once its business is done, there is no need to keep it around
  WiFiManager wifiManager;  
  //sets timeout in seconds until configuration portal gets turned off.
  //If not specified device will remain in configuration mode until
  //switched off via webserver.
  if (WiFi.SSID()!="") wifiManager.setConfigPortalTimeout(60); //If no access point name has been previously entered disable timeout.

  //it starts an access point 
  //and goes into a blocking loop awaiting configuration
  if (!wifiManager.startConfigPortal("My happy gadget","password")) {//Delete these two parameters if you do not want a WiFi password on your configuration access point
     Serial.println("Not connected to WiFi but continuing anyway.");
  } else {
     //if you get here you have connected to the WiFi
     Serial.println("connected...yeey :)");
     }

  Serial.print("After waiting ");
  int connRes = WiFi.waitForConnectResult();
  float waited = (millis()- startedAt);
  Serial.print(waited/1000);
  Serial.print(" secs in setup() connection result is ");
  Serial.println(connRes);
  if (WiFi.status()!=WL_CONNECTED){
    Serial.println("failed to connect, finishing setup anyway");
  } else{
    Serial.print("local ip: ");
    Serial.println(WiFi.localIP());
  }
}

void loop() {
 fauxmo.handle();

 if(MoveCommand){
  Serial.println("completed!");
 }
}

`

PauloFDO commented 3 years ago

I do apologise, apparently the problem is wifimanager, just tried to connect with a hardcoded password and it found my device just fine

pvint commented 3 years ago

No worries - sorry I missed replying to this right away... I could have saved you some time. :|