kakopappa / arduino-esp8266-alexa-wemo-switch

Amazon Alexa + WeMos switch made with Arduino D1 Mini

Home Page:https://sinric.pro

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

alexa not discovering device

parus21 opened this issue · comments

thanks for making such a cool project searched all over for a way to control a relay through alexa. now if only i can get it to work. i run the code and open serial monitor. it says it connects to my wifi network and that http server started but when i try to discover new devices with alexa it doesnt show up? any help would be appreciated.

  1. Make sure ports or udp packets are not blocked from router.
  2. When you ask alexa to discover devices, do you see these printed in the serial window ? normally alexa does a udp broadcast when you request to discover new devices

########## Responding to setup.xml ... ########

or

########## Responding to eventservice.xml ... ########

in the serial monitor?

commented

I have also tried to set up this device and do not get a response all devices are on the same network UDP seems to be working on the network as I am getting a request showing up from the router on the serial port However nothing from Alexa i'm using Alexa on the Amazon fire tv using a ESP-01 if I navigate to the ESP's homepage Aka index.htnl I get hello world so I know it is connected

I am using the software on several nodemcu 8266 -12f modules and it works great.
Also reprogrammed the Sonoff modules with this code.
I use the arduino ide software to flash the new code. I choose the nodemcu.9v type

Changed the ssid and password and gave each one a new device name, reboot and
Told Alexa Echo dot to discover and all appeared.... wow! great stuff....

Thanks for Super Piece of Software!!
Joe

just looking back at the boards i ordered and realized that i ordered the d1 mini pro which looks like a different board. could this be causing the issue?

not seeing anything when i make a request from alexa in the serial monitor. just pauses at http server started.

I looked at the mini pro and it looks fine. It has more mem than most.
Should work ok.
I use frpm esp01 to 12f and nodemcu modules and all work ok.
Is your power source powerfull enough?
Joe

On Wed, Nov 16, 2016, 8:39 PM parus21 notifications@github.com wrote:

not seeing anything when i make a request from alexa in the serial
monitor. just pauses at http server started.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#7 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AWDpY0zFZ7jqwmu53iOuWceR7-U_I1iRks5q-6JRgaJpZM4KvPK8
.

It is beautiful code, and I am glad that someone has got it to work, but afraid I am not one of them. I know it is getting onto the router, as i can see it, I can also ping it. Just Alexa will not discover it. Granted that I have a professional meru wifi system, which has lots of settings that might stop the UDP etc... but also tried it on my back up router that EE provides and still nothing... You can't get the WeMo sockets for love or money (and a lot of money at that) to see if your network is the problem of if there is a bit of code that just doesnt like me! So close yet so far!

I must confess that I am not as clever as I might think I am and quite new to it all. I am programming the Sonoff and only got as far as looking at the single device. I do not know how to use the Serial Monitor to get anything useful out of it, so I do not even know if Alex is doing anythin....HOLY SMOKE!! Press the button.... I didn't even realise I needed to push the button.... DHO!

OK, I now have a WeMo Switch showing up on my Alexa.... Joe, you are my hero!!! Thank you....

Slow down! So with the Sonoff can you get the relay and green LED to work together, at the moment, it seems to only be "Alexa turn the light on" to turn on the light, then "Alexa turn the light on" to turn it off!! I think I need to study this code more... but at least I can now go to bed with some sense of achievement

Yes, it isn't as easy as I thought

void turnOnRelay() {
digitalWrite(relayPin, HIGH); // turn on relay with voltage HIGH
digitalWrite(ledPin, HIGH); // turn on the green LED
}

giving the value of 13 for the relay and 12 for the relay, but all it seems to do is to turn on the relay and not the LED.

Oh, thanks again, got the serial monitor working.... having fun now,..... shame it is 1am

One step behind you!
Right, off to bed
Night

Andrew (Hampshire, England)

Hello everyone, i am having some isssues...I can flash the Sonoff and i get this in the serial monitor:
.
Connected to HOME-1307-2.4
IP address: 10.0.0.229

Connecting to UDP
Connection successful
HTTP Server started ..

but no matter what i do, i cannot get alexa to see it. I also do not see the request from Alexa on the serial monitor. I have tried diffrent UDP ports but nothing....

No, i haven't tried the button. So do i hold the button down? press the button once and scan for devices?

Still nothing,,, i have a fire stick and tried the app but neither one sees it. Am i supposed to see the requests from the alexa units in the serial monitor?

If you are not seeing anything in the Serial Moniotor, that means

1.UDP packets sent by Alexa are being blocked by a firewall

  1. UDP multicasts are blocked from the router

  2. or you are connected to the wrong Wifi.

Try this.

Start a APN on your mobile.
Reconfigure Alexa to connect to APN
Connect the Swicth to APN

Try discovering

I tried the APN route and have the same result. i can see these repeating:
Received packet of size 313
From 192.168.43.113, port 48353

Received packet of size 322
From 192.168.43.113, port 48353

over and over but i never can discover the sonoffs. Both were connected to the APN and show a successful connection. I will keep trying different things...seriously considering getting the wemos tho....

Thank AndrewsHappy...well i have a list of blocked ports for comcast/xfinity and 1900 was on there. I have tried various ports and even placing the Sonoff's IP address in the DMZ on the router to no avail. I tested a diffrent code on the sonoffs to make sure they werent faulty and they worked as they should.

Hi,
Is this script compatible with none physical echo device for example "echosim.io" website or other sites and applications? Who has tested?

I have been trying to get alexa to discover devices and she just wont, my serial monitor will just stop at

Connecting to WiFi
Connecting .....
Connected to Am
IP address: 192.168.0.108
Begin multicast ..
Udp multicast server started at 239.255.255.250:1900
WebServer started on port:
80
WebServer started on port:
81
Adding switches upnp broadcast responder
Adding switch : office lights index : 0
Adding switch : kitchen lights index : 1

and when I ask alexa to discover devices, I don't see anything in the serial monitor. I am on the same network as alexa. I am using the nodemcu cp2102 dev board. I also tried slightly different code with esp8266, I was able to turn on and off the led from the browser but alexa is just not discovering devices. Can please get some help ?

Check whether IGMP / multicast is disabled in your router.

Also try starting an APN on your mobile and connecting Alexa and dev-board to the same APN.

Hi,
I am trying to create alexa controlled window blinds. I have servo motor and wemos d1-mini.

I uploaded code to wemos d1-mini and it seems to connected fine to mine wifi. (at this point servo motor is not plugged in to wemos, I just want to make sure alexa have access to it).

Message that I get in console:

Connecting to WiFi
Connecting ........
Connected to VM140913-2G
IP address: 192.168.0.13
Ask Alexa to discover devices

Connecting to UDP
Connection successful
HTTP Server started ..

Now, When Alexa tries to discover devices, she says that non found.

I can see in console that alexa hits wemos server:

192.168.0.10, port 50000
192.168.0.10, port 50000
192.168.0.10, port 50000
192.168.0.10, port 50000
192.168.0.10, port 50000
192.168.0.10, port 50000
192.168.0.10, port 50000
192.168.0.10, port 50000
192.168.0.10, port 50000
192.168.0.10, port 50000
192.168.0.4, port 49170
192.168.0.4, port 49170
192.168.0.4, port 49170
192.168.0.4, port 49170

Any suggestions? is it my router settings?

Thanks

@samazw Thank for your reply, but I tried both, asking alexa and using the app. In both cases no devices found. But I can see in the console that alexa hits my device with some requests, but for some reason, it does not recognise as a suitable device.

Code I use is latest code from here: https://github.com/kakopappa/arduino-esp8266-alexa-wemo-switch/blob/master/sinric.ino

Only thing that I changed is wifi connection details, And it seems to connect fine to my wifi.

Thanks. That seems to improve things. I can see that response is being sent.

Sending response to 192.168.0.10
Port : 50000
Response sent !
192.168.0.10, port 50000
Responding to search request ...

Sending response to 192.168.0.10
Port : 50000
Response sent !
192.168.0.10, port 50000
Responding to search request ...

Sending response to 192.168.0.10
Port : 50000
Response sent !

But still alex app and alexa itself say that no devices found. Do I need any skills enable? or any setup todo on the app?

I tried restarting wemos d1-mini and searching for devices as soon server started, but no success.
I don't have any smart home devices connected to my echo yet. But when I ask amazon to search for devices it says to me that I would make sure to enable skill. But I can not enable belkin wemos skill without real switch device.

Oh, ok. Did not see anywhere in readme mentioning this.

Thanks for your help Sascha

hi Mortoney,
I am also facing the exact same issue with my echo version 2 and esp8266 nodemcu board. Have you been able to solve this.

@jerrishjacob I still have this issue where alexa cannot discover my wemos d1-mini device. I also using 2nd generation Echo. Maybe that is the reason, it could expect a different response or something.

@kakopappa Yes, I have tried latest version with >= which improved things, Code now sends back a response to Alexa, but Alexa still does not recognise.

I have not tried a version of the code for multiple devices, I will try to do that later today.

Just tested with multi device version of the code and getting same issue:

Got UDP Belkin Request..

Sending response to 192.168.0.1
Port : 29352
Response sent !

Sending response to 192.168.0.1
Port : 29352
Response sent !
Got UDP Belkin Request..

Sending response to 192.168.0.1
Port : 29352
Response sent !

But Alexa does not recognize device.

Is it because I don't have any legit smart device connected, as Sascha suggested HUE light?

192.168.0.1 is router IP address

Amazon ehco ip: 192.168.0.10

Interesting that single device code sent repond to ip: 192.168.0.10 and multi device code sent repond to ip: 192.168.0.1

in both way alexa can't find device

@kakopappa I tried with the updated code.
I am getting the following in the serial monitor: 192.168.1.107 is the IP of alexa.

Connecting to WiFi
Connecting ........
Connected to Jerrish
IP address: 192.168.1.133
Ask Alexa to discover devices

Connecting to UDP
Connection successful
HTTP Server started ..
192.168.1.107, port 50000
Responding to search request ...

Sending response to 192.168.1.107
Port : 50000
Response sent !
192.168.1.107, port 50000
Responding to search request ...

Sending response to 192.168.1.107
Port : 50000
Response sent !
192.168.1.107, port 50000
Responding to search request ...

Sending response to 192.168.1.107
Port : 50000
Response sent !
192.168.1.107, port 50000
Responding to search request ...

Sending response to 192.168.1.107
Port : 50000
Response sent !
192.168.1.107, port 50000
Responding to search request ...

Sending response to 192.168.1.107
Port : 50000
Response sent !
192.168.1.107, port 50000
Responding to search request ...

Sending response to 192.168.1.107
Port : 50000
Response sent !
192.168.1.107, port 50000
Responding to search request ...

Sending response to 192.168.1.107
Port : 50000
Response sent !
192.168.1.107, port 50000
Responding to search request ...

Sending response to 192.168.1.107
Port : 50000
Response sent !
192.168.1.107, port 50000
Responding to search request ...

Sending response to 192.168.1.107
Port : 50000
Response sent !
192.168.1.107, port 50000
Responding to search request ...

Sending response to 192.168.1.107
Port : 50000
Response sent !
192.168.1.1, port 1900
192.168.1.1, port 1900
192.168.1.1, port 1900
192.168.1.1, port 1900
192.168.1.1, port 1900
192.168.1.1, port 1900
192.168.1.1, port 1900
192.168.1.1, port 1900
192.168.1.1, port 1900
192.168.1.1, port 1900
192.168.1.1, port 1900
192.168.1.1, port 1900

Hi

When I press the rest switch I get the below output on console:

⸮Hl⸮⸮⸮hl$⸮�y2h⸮⸮
Connecting to WiFi
Connecting .........
Connected to CiscoD
IP address: 192.168.1.41
Begin multicast ..
Udp multicast server started at 239.255.255.250:1900
WebServer started on port:
80
WebServer started on port:
81
Adding switches upnp broadcast responder
Adding switch : office lights index : 0
Adding switch : kitchen lights index : 1

When I ask alexa to search the device, I get the following lines on the console:

Got UDP Belkin Request..

Sending response to 192.168.1.6
Port : 50000
Response sent !

Sending response to 192.168.1.6
Port : 50000
Response sent !
Got UDP Belkin Request..

Sending response to 192.168.1.6
Port : 50000
Response sent !

Sending response to 192.168.1.6
Port : 50000
Response sent !
Got UDP Belkin Request..

Sending response to 192.168.1.6
Port : 50000
Response sent !

Sending response to 192.168.1.6
Port : 50000
Response sent !
Got UDP Belkin Request..

Sending response to 192.168.1.6
Port : 50000
Response sent !

Sending response to 192.168.1.6
Port : 50000
Response sent !
Got UDP Belkin Request..

Sending response to 192.168.1.6
Port : 50000
Response sent !

Sending response to 192.168.1.6
Port : 50000
Response sent !
Got UDP Belkin Request..

Sending response to 192.168.1.6
Port : 50000
Response sent !

Sending response to 192.168.1.6
Port : 50000
Response sent !
Got UDP Belkin Request..

Sending response to 192.168.1.6
Port : 50000
Response sent !

Sending response to 192.168.1.6
Port : 50000
Response sent !
Got UDP Belkin Request..

Sending response to 192.168.1.6
Port : 50000
Response sent !

Sending response to 192.168.1.6
Port : 50000
Response sent !
Got UDP Belkin Request..

Sending response to 192.168.1.6
Port : 50000
Response sent !

Sending response to 192.168.1.6
Port : 50000
Response sent !
Got UDP Belkin Request..

Sending response to 192.168.1.6
Port : 50000
Response sent !

Sending response to 192.168.1.6
Port : 50000
Response sent !
Got UDP Belkin Request..

Sending response to 192.168.1.1
Port : 53967
Response sent !

Sending response to 192.168.1.1
Port : 53967
Response sent !

My modem details: DSL-2750U Firmware Version:IN_1.02

Firewall is disabled on the modem, and Echo Plus, Lolin NodeMcu V3, my mobile with alexa app is on the same network.

I have two NodeMCU V3 module and I am getting the same result. Both devices are working as I have tried blink example on it.

I am power the device through laptop usb port. I have not connected any relay or circult to nodemcu to remove the doubt of low power.

I am using the exactly same device as shown in the below url:
https://www.amazon.in/Centiot-ESP8266-NodeMCU-Development-Board/dp/B01M98LHT4

Now, every time I ask alexa to discover, it fail to find to find nodemcu. I have also tried the same through alexa app on android (on galaxy C9 pro). But alexa fail to detect the device.

Am I missing any additional step required to let echo plus discover nodemcu?

Hi Sascha,
You said "Use the App and do not ask Alexa. This does not work". So, I have two doubts.

There are lot of videos out there on youtube which shows that this works with alexa. Below is the URL of one such video. So how this is working of them.

https://www.youtube.com/watch?v=Be36aL6smig&lc=z22fzxx42mztut2yu04t1aokgdoikabhjuk2xefailkmbk0h00410.1514700472803318

When you say app do you mean alexa app or some other app?

Hi Sascha,

Thanks for clarifying. With app also its not working, though I can see the request received from mobile app on console and response send:
Sending response to 192.168.1.6 <<~~~~~~~~My mobile IP
Port : 50000
Response sent ! <<~~~~~~~~~~~~

In Switch.cpp I printed value of response:

Serial.println("Response sent !");
Serial.println(response);

and I got the output given below which states that my app and nodemcu is communicating. Even when I ask alexa, I get the same response with the same IP 192.168.1.6. I am still trying to figure out what is missing in the code.

Sending response to 192.168.1.6
Port : 50000
Response sent !
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=86400
DATE: Sat, 26 Nov 2016 04:56:29 GMT
EXT:
LOCATION: http://192.168.1.41:101/setup.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: b9200ebb-736d-4b93-bf03-835149d13983
SERVER: Unspecified, UPnP/1.0, Unspecified
ST: urn:Belkin:device:**
USN: uuid:Socket-1_0-38323636-4558-4dda-9188-cda0e670fa2e-101::urn:Belkin:device:**
X-User-Agent: redsonic

These codes enables esp8266 to simulate a Belkin Wemo switch. But somehow it is not working.

The code reaches void Switch::respondToSearch(IPAddress& senderIP, unsigned int senderPort), but alexa doesn't respond to the response sent by nodemcu, so I believe Alexa is expecting a different response.

Anyone who have something more to say/add?

there is no request generated from alexa for

/setup.xml
/upnp/control/basicevent1
/eventservice.xml

:(

Hi All,
At this point I can confirm that the problem I am facing is with Echo plus, with Echo Dot, it is working. Can anyone suggest what can be done for Echo Plus?

commented

Hi sunilda,
change the string response to:

String response =
"HTTP/1.1 200 OK\r\n"
"CACHE-CONTROL: max-age=86400\r\n"
"DATE: Fri, 15 Apr 2016 04:56:29 GMT\r\n"
"EXT:\r\n"
"LOCATION: http://" + String(s) + ":80/setup.xml\r\n"
"OPT: "http://schemas.upnp.org/upnp/1/0/\"; ns=01\r\n"
"01-NLS: b9200ebb-736d-4b93-bf03-835149d13983\r\n"
"SERVER: Unspecified, UPnP/1.0, Unspecified\r\n"
"ST: ssdp:all\r\n"
"USN: uuid:" + persistent_uuid + "::upnp:rootdevice\r\n"
"X-User-Agent: redsonic\r\n\r\n

this is working on my Echo Plus.

Hello guys

Past few weeks I have been working on a smart home skill and a website which allows you add development boards such as WEMOS D1 to Alexa eco system without emulating as a belkin switch. Mainly, because some people have issues in the UDP broadcast and different Alexa devices such as ECO, DOT has different XML formats and this is logic is quite difficult to code. So, I belive moving forward using the smart home skill is the right thing to do;

So, I would like to invite everyone to give it a try.

  1. Goto sinric.com

  2. Create an account

  3. Use the API key displayed on the home screen to connect your WEMOS D1 to sinric. Here is the code . Just replace the API KEY
    https://github.com/kakopappa/sinric/blob/master/arduino_sinric_example.ino

  4. Install smart home skill from
    https://www.amazon.com/dp/B078RGYWQQ/ref=syps?s=digital-skills&ie=UTF8&qid=1515150398&sr=1-18&refinements=p_n_date%3A14284925011

4.1 Link, eneter you login details to sinric.com

  1. Discover.

  2. Rate the Skill so other people can easily find it!

You can turn on/off same like emulating a belkin device.

No need to say like Alexa ask sinric to turn on bedroom lights. Simple as a Alexa turn on bedroom lights.

If you have any issue or comments report it here;
https://github.com/kakopappa/sinric

Thanks
kakopappa

It would be a great shame if we needed to start relying on an external web site for things like this. Won’t it introduce extra latency, too?

@JanB97 There was a \ and ; missing in the code you gave and I applied, but it didn't worked.

I believe Sascha can help creating a standalone version, I believe then SupraJames will have no security issue.

@kakopappa dose the website communication with the device work on MQTT protocol ? if yes what broker are u using ?

I am working on a similar website, using the alexa skill dose make it easy.

what about the guys who dont have alexa and would like to emulate the device ?

commented

@sunilda I am sorry, I did not copy the last two characters.

This is the full response string I'm using, I did not change anything else. (this is a direct copy of my working sketch so it should be right).

String response =
"HTTP/1.1 200 OK\r\n"
"CACHE-CONTROL: max-age=86400\r\n"
"DATE: Fri, 15 Apr 2016 04:56:29 GMT\r\n"
"EXT:\r\n"
"LOCATION: http://" + String(s) + ":80/setup.xml\r\n"
"OPT: "http://schemas.upnp.org/upnp/1/0/\"; ns=01\r\n"
"01-NLS: b9200ebb-736d-4b93-bf03-835149d13983\r\n"
"SERVER: Unspecified, UPnP/1.0, Unspecified\r\n"
"ST: ssdp:all\r\n"
"USN: uuid:" + persistent_uuid + "::upnp:rootdevice\r\n"
"X-User-Agent: redsonic\r\n\r\n";

@JanB97 Not sure how the above said code even got compiled as it missing the very first \ after OTP:

"OPT: "http://schemas.upnp.org/upnp/1/0/\"; ns=01\r\n"

anyways I added the \ and the code compiled, but still alexa (Echo Plus) fail to detect devices.

thank for your project and now I would like to know how can I you mqtt to communicate with alexa..I use adafruit io mqtt connect esp8266
Please help me

Sorry but now I can't access the link (the new code) you provide, can you sent it again. Thank you so much!
Here is link:
https://github.com/kakopappa/sinric/blob/master/arduino_sinric_example.ino