Control ESP8266 from anywhere with Alexa & Google (IFTTT) | Tutorial # 10
Вставка
- Опубліковано 12 сер 2017
- Visit my channel for Arduino Projects and ESP8266 Projects
.
control esp8266 from anywhere
Control single ESP8266 with Alexa and Google Home using IFTTT without opening a router's port/firewall.
Heroku:
dashboard.heroku.com/apps
IFTTT:
ifttt.com
Source Code on GitHub:
github.com/nassir-malik/IFTTT... - Наука та технологія
Hey Netmedias,
haven't been able to get your app to work for more than a few hours before it crashes. It could be me though as I've incorporated your code with my Alexa code (that's been stable for weeks).
Only thing I changed in your code is a MQTT library and the Delay(2000) in your loop to Delay(200) to try and remove some delay in the commands. Anyway this is what the terminal threw up to me. I'm using an Adafruit 8266 board that has been extremely reliable. I'm going to return your code to it's default guise and test some more.
Connected!
Got data
Disconnected!
Connecting...
Connected!
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
Fatal exception 29(StoreProhibitedCause):
epc1=0x4000e1b2, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x00000000
Exception (29):
epc1=0x4000e1b2 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
ctx: sys
sp: 3ffffda0 end: 3fffffb0 offset: 01a0
>>>stack>>>
3fffff40: 3fffdc00 000002f4 3ffefbf0 401004f4
3fffff50: 00000000 00000000 3ffefbf0 40107148
3fffff60: 4010522e b6100043 402188e8 40218466
3fffff70: 4022a0b0 3fff0b28 40218926 00000002
3fffff80: 4022a0d6 3fffdab0 40219b23 3fffdab0
3fffff90: 00000000 3fffdab0 3fff1510 4020f967
3fffffa0: 40000f49 40000f49 3fffdab0 40000f49
Try to use a better power supply.
Hi Netmedias,
I'm running your code with a terminal monitor open to check it's stability. For the most part it seems stable, but every now and again when running a Google applet/request I get the spoken response from Google Home, but no response on my device.
The program isn't crashing anymore so I'm happy with my power supply.
I'm thinking that the disconnecting from Heroku could be the issue.
I'm wondering if paying for the basic monthly subscription to Heroku ($7) I could eliminated the disconnection issues? Would it also mean a change to your Heroku programming? I really don't like how the app needs to disconnect every few seconds.
Your thoughts?
thanks,
Robert.
I am working on the fix. Let you know soon.
Robert Yates I made a fix and update the GitHub code. Download and flash ESP sketch. Let me how it is working for you.
Hey Netmedis. Thanks. I copied you code into my custom sketch and it seems to be working good. Haven't seen any disconnects yet. Just to confirm that it was just the "PingCount" code in the loop I had to copy.
Will get back to you after the program has been running a good length of time.
Thanks for your prompt reply.
Robert
Excellent instructions, and excellent diagrams. Thank you.
Great Sir. Thanks you very much.Very Well explained. God Bless You
Nassir, You do a very nice job of showing how easy it can be. It gives confidence to new users to try something new. You should publish ebooks at a reasonable cost. I would purchase some particularly should you get into more detailed projects such as using Node Red and a broker for a 'status' display using an inexpensive Android tablet.
David Moran Thank you for your kind words & suggestions.
Good tutorial. Thanks.
Hey Netmedias,
Great tutorial, Thank you for your project , finally it worked for me, kindly do some upgrade to project to work with 4 or 8 channel relay or multiple devices
Ranjith kumar Thank your for your feedback. I will do that as soon as I get some time.
I used your code for uploading it to the ESP8266
Works Great!, thank you
aborigen py Thanks
Good job
Great videos!!! I would like your help if you can generate a video showing how to read information from a device (like temperature sensor) and shared with Alex.
Great tutorial. Are you able to explain how to control multiple devices and incorporate a three way switch like in tutorial no 6.Much appreciated. Thanks Charles
Awesome
Hello Nassir, thanks to your tutorials I could control several lights with 3 way switches too, I have a question, maybe you know how could I make the ESP send me a notification when the outputs change? Thank you very much
Thanks man.
This will be very nice implementation in sonoff tasmota for wemos d1 mini.
works.....Thank you
HP L'Atlas Thank you for confirmation.
great tutorials! i like it very much, i wish you explain a little more about the code. im from mexico and i like it very much if i can translate it to spanish, i will try. thank you
I will do sir. stay tuned.
So what should I do, upgrade to a paid service on HEROKU and then?
Hi in the Tutorial you have used port 80, I noticed in Heroku docs that now there are Automated Certificate Management for TLS, have you ever tried this same project with a secure connection using port 443?
Fee Heroke has limited functionality and it keeps upgrading python version and forces you to upgrade, So I don't use it anymore. I will better alternative once I have it ready. It may be a while. thanks
Been struggling a bit with stability on this. Kinda works "from time to time". The Heroku seems to get a blank command from IFTTT. As the log shows " Req-->" to be blank... (And serial monitor displays "Command is not recognized!") Changing the URL in IFTTT from HTTPS:// to HTTP:// Though.. And it works every time.. Whats up with that.. ? Any experience with HTTPS making this unusable.... ?
Tore André Lie There may be an issue with the service. It should work for both.I will look into it. Thanks
Hello, you please tell me how to add more GPIOS to be control because your code only control on GPIO 16?
Really nice project, but is it somehow possible to control two devices(relays) on one ESP8266 ESP-12E? Thanks!
Hey Netmedias,
I have been exploring your project more and now have several lights setup and working via Alexa and Google in the same sketch.
My next task is to see if I can get them to dim. I have some dimming
lights working from my tablet but want to get them to work via Google assistant.
Using your tutorial instructions I'm making a Google Assistant applet in
IFTTT and selecting "Say a phrase with a number" I'm selecting "dim
lights to # percent". My problem is how to construct the JSON code for
the Body of the command. What I have so far is.
{"location":"\House \Living \Dimmer","device":"living", "devicevalue":"#"}The location is a MQTT topic, device is my living light and devicevalue is the percentage dimming value.
All I'm getting back from this command is 0, thus the light is turning off and not dimming. JSON is not my strong point.
Appreciate if you could help.
cheers,
Robert.
Sorry I posted a response for Alexa and then realized your question was for Google Home and deleted it.
Ok, Here is what you need to do.
1.) Create an IFTTT Google applet "Say a phrase with both a number and a text ingredient" and type in phrase "dim kitchen lights to # $"
2.) Enter everything else similar to the tutorial
3.) Enter json "{"location":"\House \Living \Dimmer","device":"living", "devicevalue":" {{NumberField}}"}"
Jenjoy!
The IFTTT Google applet has an option to send a variable value as a number using the # key. I was hoping that by value could be passed using JSON and it be used to in my MQTT message. What you're doing here is providing constant values only, if I'm reading it correctly. Thanks again.
Sorry! I posted for Alexa. Read my other response.
Hey, you're the man. Works great. Thank you.
Hello, thanks for the great tutorial, when signing up for Heroku when I want to start a new project it asks what programming language, what language do I select? Thanks.
Steve Tripoli Python
Thanks
Hey Net, I am having some problems. I wrote a sketch to control power to a relay controlling a light. It only responded to the "on" command. In other words. I can turn the light on, the relay latches on the "on" command. Yet it does not unlatch the relay with the "off" command. I downloaded your sketch thinking its a sure thing but it still only responds to the "on" command. I have to ask alexa to turn the light on, it energizes. Then I have to ask her to turn it off, and nothing happens, light is still lit and then ask her again to turn it on, and it actually de-energizes the relay and the light goes off....on the "on" command. Any ideas?
Tim can you share the Arduino serial output.
hey netmedias
i got a problem my relay not working so checked the ifttt applet for log there i got error show this applet sikpped and applet filled,there was a problem with the webhooks services
Same with me, Did you get any solution ?
still did not get solution
finally it worked for me
Hello. If you have ifttt setup why do you need Heroku then ?
THanks.
Marc.
Thank you for your hard work. I did follow all the directions, I included the libraries and copied the sketch, but wen I verified an error of WebSocketClien.h: no such file or directory appears. what should I do?
do you need help to solve this problem
Thank for your video bro, it's really awesome :D
But I'm wondering that, can I change the name of location or device? Example from "kitchen" to "bedroom"
Yes, change it in IFTTT json for location and name. Good luck.
I have problems . The serial return says Command is not recognized!. Is there any line of code i can add to monitor what am i receiving from the web-socket ? edit: could it be firewall issue ?
So what should I do to make your project work?
Alright I'm having some trouble deploying the app... I've been researching and reading the comments and I assume it's something with the Python version. When I go to my app web page I get an Application error. Could I get some help on what to do? And also, lets say my app is up and running correctly, will it stop working if ever the python version changes on Heroku?
Edit : I just found the in the install log and it says it installed Python 3.6.6. , no warning about the wrong version. So I don't know what the issue is then?
What are you seeing in Arduino serial output?
excellent material. I have a question: These intermediate applications like ifttt, heroku, alexa, google api must be paid or would be completely free for these tasks as on and off.
I'm sorry, but I do not have Alexa or Google home yet
pablo nuñez They are free for low usage.
Netmedias thanks for the answers.
And if instead of using a Google home hardware, I use only the Google home application of the smartphone? Would it work? Could I communicate with the ESP only with the app?
Hey Netmedias great tutorial and it work for me too.
Will you please help me how to control 2 or more relay with single applet in ifttt for Google Home?
Thanks
Tushar Kulkarni I have this tutorial on my to do list. Stay tuned.
ok, so i have flashed the esp, i have created the google applets and the heroku app
google response when i say turn on kitchen lamp however ifttt says applet never ran and horoku doesn't see anything in the log!
please help!
devilclarke If applet is not running that means it is not linked to your account correctly. Please unlink and link your google account with ifttt again. Good luck.
I have the same problem , can you resolved?
Nope i have tried @Netmedias suggestion but to no avail
Hello , it sounds really interesting , but a question : what about using more than one ESP8266 , all connected @ the same Wifi ?
I mean , is it possible address different units ( I.e. 1 in the kitchen , 1 living room , etc.. ) ?
Thanks so much
Fabio Rocchi you can your the device as key for multiple devices. Based on device name or number set the assigned GPIO low high. Good luck.
Can you create a video for upgrading HEROKU
So I want to use Heroku to handle my request. Can you write an example file that I can just deploy to Heroku via something like Dropbox? It should support the launch event and the intent request. The problem is there a very few simple sketches on the internet and those that are are either in Python or another language that I don't know (I just know node.js) or I don't understand them and if I deploy them to Heroku I don't know how to use them.
I would be very thankful if you could do this.
Oh and by the way I'm just interested in Alexa and not Google
Bastian Springer I am very busy right now I will do this in future so stay tuned.
Netmedias nice. I'll definitely watch it!
Tutorial will be good if you explain the coding part of it also without jus posting the code. And i would like to know how to pass the commands recieved by wifi moudle to arduino and raspberry pi so as to control many devices using them other than using wifi module alone to control devices.
My intention is to get folks complete a project with minimal effort to build an interest and cut through the noise and let them explorer. I don't think most of the folks here want to deep dive into the coding. It takes time to learn coding but if you know coding you can figure it out.
Nevertheless, I will do a detailed code walkthrough video soon.
bro 8channel relay esp8266 with apple homekit and siri ??
Hi Nassir, I used your concepts to create my controlled dog feeder, and everything works great. Except for one thing .. Well, from time to time the request object does not appear in Arduino and instead of this it being shown "Command is not recognized!" - I solved it differently - by each request, the state simply changes to the opposite, without checking the request object.
However, this is not the best way for more complex projects.
I see that someone has already mentioned it in the comments - so maybe have you already found a solution for it?
And yes, for me putting "http" instead of "https" also helped
Thanks this is a very useful video, however after i deployed the code in Heroku it worked well for a while with IFTTT now it stopped working suddenly and IFTTT logs are saying it is getting a ETIMEDOUT from the web request. I also checked the application logs in Heroku i noticed ValueError: Line without CRLF. I am not sure if this was before but i did not change any code ?!! can you please advise.
Please make sure you the supported python version. Heroku free account keeps changing the supported python version.
@@netmedias7657 let's assume it is the case, what should i exactly do? I do not want to upgrade to the paid version it was working very nice for nearly a month. Appreciate if you could explain a bit more please.
here is the log...
Req-->{"location":"Outdoor","device":"car", "state":"on","query":"cmd"}
2020-03-12T20:49:45.679750+00:00 heroku[router]: sock=client at=warning code=H27 desc="Client Request Interrupted" method=POST path="/" host=button-presser.herokuapp.com request_id=44282229-8450-4b79-8a6a-0090a21d2b22 fwd="34.234.87.206" dyno=web.1 connect=0ms service=15354ms status=499 bytes= protocol=https
2020-03-12T20:49:48.689478+00:00 app[web.1]: ('Line without CRLF',)
2020-03-12T20:52:05.835583+00:00 app[web.1]: ('Line without CRLF',)
2020-03-12T20:54:22.624670+00:00 app[web.1]: ('Line without CRLF',)
2020-03-12T20:56:39.848254+00:00 app[web.1]: ('Line without CRLF',)
In ifttt app/website google assistant >> choose trigger is missing.
So I can troubleshoot which one is causing the issue
In the Alexa/Google now app.y script, you added a _read_ready procedure that is set in asyncio.selector_events, as compared to the Alexa garage door version of app.py.
Is this added due to the combined Alexa Google functionality, or is this something you found useful in general.
In other words, would it be useful to have this also in the Alexa garage door version of app.py?
There is an issue the way Heroku posts json to ESP and message body is truncated. May be an issue with websocket library I am using. So I did a function overloading and added 10 milliseconds delay in the code and that helps.
I plan on using the technique in Tutorial #8, so I'll add the function into that. I want to use the tutorial #8 method to control my thermostat. It's fully integrated into my (very old tech) home automation system. I've been able to use a hue bridge simulator to get the lights and other on/off things to work, but controlling and getting status from the thermostat was a big issue. A modified version of your solution for the garage doors will work fine for getting the thermostat integrated into Alexa (I hope!) Thanks again for the great tutorials!
Ron Good luck! Keep us updated on your progress. Thanks
After some hand-holding by Nassir, I got my mod of the Alexa garage door method working and talking to my thermostat! Thanks for the great tutorials! Anyone interested can find the code at github.com/rebel7580/ESP8266-Alexa_Skills_Thermostat
But be aware that you would need to have a specific (and old) Home Automation system for this to be useful to most people.
Ron thank you for your hard work. You did a great job.
hi! i have a problem... There was a problem with the Webhooks service.
JOIRO NETO Can you share the issue or error so I can help. Thanks
Can you help me ? dont work for me , i tell de command to google home and they understand me but the esp8266 dont receive the signal .
Alex Diaz Ok I think I found the issue. Heroku is using Python 3.6.3 not 3.6.1 anymore. I updated the GitHub code. Redeploy it to Heroku and try it again. Good luck.
I am getting Application error
when i open the app.
Application error h13
An error occured in the application and your page could not be served.if you are application owner ,check your logs for details
please help
Chethan Bhandarkar Ok I think I found the issue. Heroku is using Python 3.6.3 not 3.6.1 anymore. I updated the GitHub code. Redeploy it to Heroku and try it again. Good luck.
Looks like Heroku is using 3.6.4 now. is there anyway you can updated the GitHub again please? Here is the log from my deployment.
The latest version of Python 3 is python-3.6.4 (you are using python-3.6.3, which is unsupported).
! We recommend upgrading by specifying the latest version (python-3.6.4).
Learn More: devcenter.heroku.com/articles/python-runtimes
I am also getting this error.
Yo, will it run on NODE-MCU ESP8266?
I tried it on my device and its not working. google shows the message from IFTTT but still the light doesnt turn on.
how can i check that my heroku app works properly?
i can't even figure out where it fails. plz help
Amit Magnezi Yes it works with NodeMcu, check your Arduino serial output for debug info.
How can i check it? btw the code compiles and uploads fine
Amit Magnezi When you flash it with Arduino IDE it tells you that code was compiled and uploaded to esp successfully. You need to look at serial out to find out if it is working correctly. Please follow the video tutorial.
I have the same board and the same problem do you resolved?
But can you control the kitchen lights with both Alexa and Google Assistant?
Yes, you can.
Can you explain what exactly we are uploading on heroku
It is proxy app to get around the firewall.
i am keep on getting this on serial monitor.
connected with Ankit_airtel, channel 2
dhcp client start...
Connecting to state: 5 -> 0 (0)
rm 0
......................scandone
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 2
cnt
hello i have a problem, i'm blocked in this stat : switch(type) {
case WStype_DISCONNECTED:
Serial.println("Disconnected! ");
Serial.println("Connecting..."); in a loop loop :
Connecting...
Disconnected!
Connecting...
Disconnected!
Connecting...
Disconnected!
Connecting...
.... did u you know why?
Nobody knows how to solve the problem ???
djkrom2003 Please make sure your Heroku app is installed successfully. They keep changing python version. Update you config file and redeploy it. Good luck.
I have the same problem right now. Did you find a solution? Even If I install the latest version of python there is this issue
can you add physical switch?
Yes, see my 3/4 way switch tutorial. ua-cam.com/video/5SgB6wzgxY0/v-deo.html
Not sure where i am wrong, but its not working
then i wanted to test my Heroku Deployement
but the URL heater-app.herokuapp.com/?location=kitchen&device=lights&state=on&query=cmd
it doesnt work
what can be the case ??
Nakul Kundra what do you see in Arduino serial output?
That i have not checked , as the IFTTT Applet is not working.
one suspect i have is , i think the code which we are uploading is in older version of python . which is not supported by heroku .... See the Build Logs
-----> Python app detected
! The latest version of Python 3 is python-3.6.3 (you are using python-3.6.1, which is unsupported).
! We recommend upgrading by specifying the latest version (python-3.6.3).
Learn More: devcenter.heroku.com/articles/python-runtimes
-----> Installing python-3.6.1
-----> Installing pip
-----> Installing requirements with pip
Collecting websockets==3.2 (from -r /tmp/build_41b7bff15f2e2612b40ef3379a4ac3e5/nassir-malik-IFTTT-Alexa-And-GoogleHome-Control-Single-Device-a476f1d/requirements.txt (line 1))
Downloading websockets-3.2-py33.py34.py35-none-any.whl
Installing collected packages: websockets
Successfully installed websockets-3.2
-----> Discovering process types
Procfile declares types -> web
-----> Compressing...
Done: 57.8M
-----> Launching...
Released v3
heater-app.herokuapp.com/ deployed to Heroku
also can you guide, what happens when you open {yourappname}.herokuapp.com in the browser , for my deployment of your code, it says Application Error ..
It should be blank.
This looks good. What do you see in Arduino IDE console?
Can't upload this project to arduino because it for example says:
C:\Users\bruger\AppData\Local\Temp\Rar$DIa8424.44764\ESP8266_WebSocketClient\ESP8266_WebSocketClient.ino:11:18: fatal error: Hash.h: No such file or directory
#include
The arrow shows with these 3 libraries
, and . I have copied ArduinoJson and arduinoWebSockets into Arduino IDE library folder. Pls help me
Are you using ESP8266 or NudeMcu?
@@netmedias7657 I'm using ESP8266
Did you create IFTTT templates? I am assuming you have installed ESP8266 Arduino supported libraries?
@@netmedias7657 I have tried to install all the libraries form tutorial #4, but I am not sure I did it right, because it can't find the libraries. I have not created the FTTT templates, because I have not reached that part of the tutorial yet. Thank you!
???
Hey Netmedias, great tutorial it works great! But, I got a 8 pack relay off of amazon for real cheap, and was wondering how to control multiple devices?
Patrick Hennessey You can watch my following tutorial.
ua-cam.com/video/OC6QSXzkQU8/v-deo.html
Thanks, but that tutorial is for alexa, I'm wondering if there was a way to do it for Google Home?
Patrick Hennessey It is very easy to add more devices to this sketch. Createa new IFTTT on/off template for each device and add if or switch statement in "processWebScoketRequest" function.
I already have include a parameter for device name you can use that to supply device name in IFTTT template. Good luck.
String device = (const char*)root["device"];
Let me know how it goes. Thanks
I see the "processWebScoketRequest" but what should the if statement look like?
The quick and dirty way is to right before the following line
if(query == "cmd"){ //if query check state
Add your statment like this
If(device=="kitchen"){
relayPin =gpio_pin_number_for_device;
}else if(device=="bedroom"){
relayPin =gpio_pin_number_for_device;
}else if(){....
how to do this for esp8266 for 8ch relay
Jay ranjan.J Please see the following tutorial.
ua-cam.com/video/OC6QSXzkQU8/v-deo.html
How can I test separately heroku from IFTTT?
Just check the IFTTT template if it is getting triggered. If it is then the issue is in Heroku app setup. Make sure install python 3.6.5 version by updating cloning updating GitHub code.
Netmedias hello so to see if IFTTT is getting trigger them just talk to Alexa or Google? And then check where?
Then check Arduino IDE serial window.
Please tell me..how can we control that devices on our mobile app...
Tình Nguyễn You can use mobile app to control ESP or create your mobile or web app. You can search for ESP app on Android or iso app store. Good luck.
Netmedias I still have no app android to control that..Please show me what app you get
Tình Nguyễn I will be doing a tutorial on this soon. Stay tuned.
The Google voices commands are working but not ALEXA
If Google Home is working then Heroku and ESP code is good. You need to check your Alexa IFTTT template. Also try to re-link you Alexa account with IFTTT account.
Sir i have tried lot my device relay not working .
ESP 12E requires more power to run the program. After you flash it use better power source. USB TTL converter/programmer does not have enough power to run ESP
The serial monitor is showing some error lines
If Google Home is working then Heroku and ESP code is good. You need to check your Alexa IFTTT template. Also try to re-link you Alexa account with IFTTT account.
my IFTTT account activity shows :
Action skipped
Dec 12 - 9:17 PM
Google Assistant
If You say "turn off kitchen lights", then make a web request
Hide details
Ingredients
CreatedAt
(none)
my esp com port get
connected with NETGEAR75, channel 11
dhcp client start...
ip:192.168.0.14,mask:255.255.255.0,gw:192.168.0.1
Connecting to Connected to wi-fi
pm open,type:2 0
Disconnected!
Connecting...
Fatal exception 28(LoadProhibitedCause):
Bob Lu Looks like you client is not connecting to Heroku app. After "Connecting..." you should see a connected text but it is throwing exception. Please double check all the steps.
would the IDE sketch work, if i do the port forwarding on my esp ? instead of using heroku domain...
found my typo in the sketch ... it is now working with heroku app... thanks!
I have a problem webhooks failds
WEBHOOKS error:etimedout
help pleas
Ben Rajeb Amir Try it later. It may be having some service interruption. Thanks
the same problem every time :/ error:etimedout
i'm working with google home
Ben Rajeb Amir are you seeing this in API.ai? Make sure use the https url for webhook.
My esp8266 keeps saying:
Disconnected!
Connecting...
You need to update python version in your app and re-deploy it. See the error in Heroku deploy log. Use the same version.
I need this application to work
3rd party services like iftt are not to be trusted anymore, they must a way to do this directly
Who to connect
subham bhattacharjee I am not sure what you are asking
Can you help me
Can you help me or create a video for this, I could pay you for your time
can you please sent ne the codes for it
It is on github. github.com/nassir-malik/IFTTT-Alexa-And-GoogleHome-Control-Single-Device
Yes, but ALEXA is not working
If Google Home is working then Heroku and ESP code is good. You need to check your Alexa IFTTT template. Also try to re-link you Alexa account with IFTTT account.
Hello, my friend can you help me personally, I will pay you and help me with with my project
Tell me something do you have to pay on heroin to make this work?