Aircoookie / Espalexa

Alexa voice control for ESP8266/ESP32 (including brightness and color!)
MIT License
548 stars 137 forks source link

Echo Dot Won't Find ESP8266 Feather Huzzah #87

Open carson-51 opened 5 years ago

carson-51 commented 5 years ago

I've tried the 2nd and 3rd gen Echo Dots to no avail.

WiFi connected IP address: 192.168.1.20 Constructing device 1 Adding device 1 Espalexa Begin... MAXDEVICES 10 Done Connecting to MQTT... Failed to subscribe Retrying MQTT connection in 5 seconds... MQTT Connected! Got UDP! M-SEARCH * HTTP/1.1 HOST: 239.255.255.250:1900 ST: ssdp:all MAN: "ssdp:discover" MX: 3

Temperature published! Humidity published! Got UDP! M-SEARCH * HTTP/1.1 HOST: 239.255.255.250:1900 ST: upnp:rootdevice MAN: "ssdp:discover" MX: 3

Responding search req... Temperature published! Humidity published!

Responding to description.xml ...

Sending :<?xml version="1.0" ?>10http://192.168.1.20:80/urn:schemas-upnp-org:device:Basic:1Espalexa (192.168.1.20)Royal Philips Electronicshttp://www.philips.comPhilips hue Personal Wireless LightingPhilips hue bridge 2012929000226503http://www.meethue.combcddc22ba89euuid:2f402f80-da50-11e1-9b23-bcddc22ba89eindex.html Got UDP! M-SEARCH * HTTP/1.1 HOST: 239.255.255.250:1900 ST: ssdp:all MAN: "ssdp:discover" MX: 3

Temperature published! Humidity published! Got UDP! M-SEARCH * HTTP/1.1 HOST: 239.255.255.250:1900 ST: upnp:rootdevice MAN: "ssdp:discover" MX: 3

Responding search req... Temperature published! Humidity published! Got UDP! M-SEARCH * HTTP/1.1 HOST: 239.255.255.250:1900 ST: ssdp:all MAN: "ssdp:discover" MX: 3

Temperature published! Humidity published! Not-Found HTTP call: URI: /api Body: {"devicetype": "Echo"} AlexaApiCall ok devType Got UDP! M-SEARCH * HTTP/1.1 HOST: 239.255.255.250:1900 ST: upnp:rootdevice MAN: "ssdp:discover" MX: 3

Responding search req... Temperature published! Humidity published! Connecting to MQTT... MQTT Connected! Got UDP! M-SEARCH * HTTP/1.1 Host: 239.255.255.250:1900 Man: "ssdp:discover" MX: 3 ST: ssdp:all

Temperature published! Humidity published! Got UDP! M-SEARCH * HTTP/1.1 Host: 239.255.255.250:1900 Man: "ssdp:discover" MX: 3 ST: upnp:rootdevice

Responding search req... Temperature published! Humidity published!

Responding to description.xml ...

Sending :<?xml version="1.0" ?>10http://192.168.1.20:80/urn:schemas-upnp-org:device:Basic:1Espalexa (192.168.1.20)Royal Philips Electronicshttp://www.philips.comPhilips hue Personal Wireless LightingPhilips hue bridge 2012929000226503http://www.meethue.combcddc22ba89euuid:2f402f80-da50-11e1-9b23-bcddc22ba89eindex.html Got UDP! M-SEARCH * HTTP/1.1 Host: 239.255.255.250:1900 Man: "ssdp:discover" MX: 3 ST: ssdp:all

Temperature published! Humidity published! Got UDP! M-SEARCH * HTTP/1.1 Host: 239.255.255.250:1900 Man: "ssdp:discover" MX: 3 ST: upnp:rootdevice

Responding search req... Temperature published! Humidity published! Got UDP! M-SEARCH * HTTP/1.1 Host: 239.255.255.250:1900 Man: "ssdp:discover" MX: 3 ST: ssdp:all

Temperature published! Humidity published! Got UDP! M-SEARCH * HTTP/1.1 Host: 239.255.255.250:1900 Man: "ssdp:discover" MX: 3 ST: upnp:rootdevice

Responding search req... Temperature published! Humidity published! Got UDP! Temperature published! Humidity published!

`/*** Adafruit ESP8266 Sensor Module Must use ESP8266 Arduino from: https://github.com/esp8266/Arduino Works great with Adafruit's Huzzah ESP board: ----> https://www.adafruit.com/product/2471 Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit! Written by Tony DiCola for Adafruit Industries. MIT license, all text above must be included in any redistribution ****/

// Libraries

include

include "Adafruit_MQTT.h"

include "Adafruit_MQTT_Client.h"

include "DHT.h"

//add Alexa functionality

define ESPALEXA_DEBUG

include

// DHT 11 sensor

define DHTPIN 14

define DHTTYPE DHT22

// Somfy Control

define shade_up_pin 2

define shade_down_pin 0

// WiFi parameters

define WLAN_SSID "***"

define WLAN_PASS "***"

// Adafruit IO

define AIO_SERVER "io.adafruit.com"

define AIO_SERVERPORT 1883

define AIO_USERNAME "***"

define AIO_KEY "***" // Obtained from account info on io.adafruit.com

// DHT sensor DHT dht(DHTPIN, DHTTYPE, 15);

// Create an ESP8266 WiFiClient class to connect to the MQTT server. WiFiClient client; // Setup the MQTT client class by passing in the WiFi client and MQTT server and login details. Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_KEY);

// Setup feeds for temperature & humidity Adafruit_MQTT_Publish temperature = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/temperature"); Adafruit_MQTT_Publish humidity = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/humidity");

Adafruit_MQTT_Subscribe shade_up = Adafruit_MQTT_Subscribe(&mqtt, AIO_USERNAME "/feeds/shade-up"); Adafruit_MQTT_Subscribe shade_down = Adafruit_MQTT_Subscribe(&mqtt, AIO_USERNAME "/feeds/shade-down");

// connect to adafruit io via MQTT void MQTT_connect() { int8_t ret;

// Stop if already connected. if (mqtt.connected()) { return; }

Serial.print("Connecting to MQTT... ");

uint8_t retries = 5; while ((ret = mqtt.connect()) != 0) { // connect will return 0 for connected Serial.println(mqtt.connectErrorString(ret)); Serial.println("Retrying MQTT connection in 5 seconds..."); mqtt.disconnect(); delay(5000); // wait 5 seconds retries--; if (retries == 0) { // basically die and wait for WDT to reset me while (1); } } Serial.println("MQTT Connected!"); }

Espalexa espalexa;

//espalexa void firstDeviceChanged(uint8_t brightness) { //brightness parameter contains the new device state (0:off,255:on,1-254:dimmed)

if (brightness == 255) { digitalWrite(shade_down_pin, LOW); delay(500); digitalWrite(shade_down_pin, HIGH); Serial.println("Got on. Shade down"); } if (brightness == 0) { digitalWrite(shade_up_pin, LOW); delay(500); digitalWrite(shade_up_pin, HIGH); Serial.println("Got off. Shade up"); } }

/*** Sketch Code ****/

void setup() {

// Init sensor dht.begin();

// shade control pinMode(shade_up_pin, OUTPUT); digitalWrite(shade_up_pin, HIGH); pinMode(shade_down_pin, OUTPUT); digitalWrite(shade_down_pin, HIGH);

Serial.begin(115200); Serial.println(F("ESP8266_humidity_temp_shade"));

// Connect to WiFi access point. Serial.println(); Serial.println(); delay(10); Serial.print(F("Connecting to ")); Serial.println(WLAN_SSID);

WiFi.begin(WLAN_SSID, WLAN_PASS); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print(F(".")); } Serial.println();

Serial.println(F("WiFi connected")); Serial.println(F("IP address: ")); Serial.println(WiFi.localIP());

// connect to adafruit io

mqtt.subscribe(&shade_up); mqtt.subscribe(&shade_down);

espalexa.addDevice("Shade", firstDeviceChanged); espalexa.begin(); }

void loop() {

// ping adafruit io a few times to make sure we remain connected MQTT_connect();

espalexa.loop();

// Grab the current state of the sensor int humidity_data = (int)dht.readHumidity(); int temperature_data = (int)dht.readTemperature();

temperature_data = temperature_data*(9.0/5.0) + 32.0;

// Publish data if (! temperature.publish(temperature_data)) Serial.println(F("Failed to publish temperature")); else Serial.println(F("Temperature published!"));

if (! humidity.publish(humidity_data)) Serial.println(F("Failed to publish humidity")); else Serial.println(F("Humidity published!"));

// this is our 'wait for incoming subscription packets' busy subloop Adafruit_MQTT_Subscribe subscription; while ((subscription = mqtt.readSubscription(3000))) { if (subscription == &shade_up) { Serial.print(F("Got: ")); Serial.println((char )shade_up.lastread); if (strcmp((char )shade_up.lastread, "ON") == 0) { digitalWrite(shade_up_pin, LOW); delay(500); digitalWrite(shade_up_pin, HIGH); Serial.println("Shade Up"); } } if (subscription == &shade_down) { Serial.print(F("Got: ")); Serial.println((char )shade_down.lastread); if (strcmp((char *)shade_down.lastread, "ON") == 0) { digitalWrite(shade_down_pin, LOW); delay(500); digitalWrite(shade_down_pin, HIGH); Serial.println("Shade down"); } }
}

// ping the server to keep the mqtt connection alive

if(! mqtt.ping()) { mqtt.disconnect(); } delay(1000); }`

Aircoookie commented 4 years ago

Hi and sorry for responding almost 2 months late!

If this is still relevant, try going to 192.168.1.20/espalexa. Does it work? I believe Adafruit IO might be interfering with the webserver somehow...

Happy holidays :)