Тёмный

#48 Connect ESP8266 with the world (and IFTT) through MQTT and Adafruit.io (Tutorial) 

Andreas Spiess
Подписаться 485 тыс.
Просмотров 109 тыс.
50% 1

Опубликовано:

 

29 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 223   
@KennethTanFotografie
@KennethTanFotografie 8 лет назад
One of the best introductions into MQTT ever seen. Love the accent.
@AndreasSpiess
@AndreasSpiess 7 лет назад
Thanks!
@IoTLearner
@IoTLearner 6 лет назад
Well done sir...
@anycatdessai
@anycatdessai 6 лет назад
True!
@brianschwind6530
@brianschwind6530 8 лет назад
Your series of videos on the ESP8266 is incredibly helpful and informative, thanks so much for taking the time to make them! Your pacing and explanations are perfect.
@AndreasSpiess
@AndreasSpiess 8 лет назад
Thank you very much for your nice comment!
@PhG1961
@PhG1961 Год назад
Already 7 years ago... and still very enjoyable. I needed a refresh... so what else is there to do then watch these videos!
@AndreasSpiess
@AndreasSpiess Год назад
Indeed, a long time. And I always wonder where I found the time to create these videos during my active work...
@georgei2480
@georgei2480 3 года назад
This is a killer app! I spent days trying to accomplish the same task described in this video but with the use of WebSockets with no success. This took me less than 30 min to get set up and working!
@AndreasSpiess
@AndreasSpiess 3 года назад
Glad the video helped!
@planetcrypto8662
@planetcrypto8662 7 лет назад
Particularly like your teaching of practical usage, versus blinking LED's. A channel for the professional versus the student/hobbyist. Although easily digestible by both. We run MQTT servers and you're spot on. Great job, very useful, keep up the outstanding work.
@AndreasSpiess
@AndreasSpiess 7 лет назад
Thank you for your nice feedback. I try to do my videos the same way I like them when I want to learn something...
@spacefolder
@spacefolder 7 лет назад
You are a great teacher, with an AMAZING sense of humor! Thank you.
@AndreasSpiess
@AndreasSpiess 7 лет назад
Thanks!
@filipeterra8981
@filipeterra8981 8 лет назад
best youtube channel ever! great diagrams and a catchy voice. thank you for the esp8266 videos!
@AndreasSpiess
@AndreasSpiess 8 лет назад
+filipe terra Thank you very much for your compliment!
@rinokentie8653
@rinokentie8653 2 года назад
Andreas - this old video was of great help. I am trying to understand the workings of Adafruit.io. Thanks!
@AndreasSpiess
@AndreasSpiess 2 года назад
Glad it was helpful!
@techlander00
@techlander00 8 лет назад
Hi Andreas ! Simple, linear, pro, crystal clear. Thanks a lot for everythingM
@AndreasSpiess
@AndreasSpiess 8 лет назад
Thanks for this very nice comment!
@muhammadsameer883
@muhammadsameer883 7 лет назад
Very nice and to the point tutorial Andreas.. I like you accent. Very clear and very understandable.
@AndreasSpiess
@AndreasSpiess 7 лет назад
Thank you for your positive feedback!
@rolandomartin
@rolandomartin 7 лет назад
Andreas, you are a great communicator. Love your videos. Greetings from Canada!
@AndreasSpiess
@AndreasSpiess 7 лет назад
Thanks you!
@benfletcher7209
@benfletcher7209 6 лет назад
Really good intro to MQTT, looking forward to checking out more ESP8266 stuff. Thank you very much Andreas
@AndreasSpiess
@AndreasSpiess 6 лет назад
Thank you and enjoy my other videos on the ESP8266 and the newer ESP32
@luchoescobar
@luchoescobar 6 лет назад
Hey Andreas thanks for the video, what was the name of the esp you used in this video?? I can’t catched up well. The luminiscense sensor is attached to the board??
@jimmy21584
@jimmy21584 7 лет назад
This was very clear, and a great choice of libraries - thank you!
@AndreasSpiess
@AndreasSpiess 7 лет назад
Thank you!
@rmjjanssen2645
@rmjjanssen2645 7 лет назад
He Andreas, great tutorial.....yesterday evening I was able to replicate the setup......worked in one go. See a lot of other interesting video's on you channel . So thank you for getting me up to speed with this. Up to my first IoT project...
@AndreasSpiess
@AndreasSpiess 7 лет назад
Good. Thanks for the feedback!
@rmjjanssen2645
@rmjjanssen2645 7 лет назад
He, question .....have you come around a way to create Mqtt based apps for iOS? So an app that can publish data on topics of an mqtt broker like adafruit?
@AndreasSpiess
@AndreasSpiess 7 лет назад
+RMJ Janssen There are a few MQTT clients for smartphones available.
@AcessoTeleInfo
@AcessoTeleInfo 6 лет назад
Congratulations from Brazil! Very good!
@AndreasSpiess
@AndreasSpiess 6 лет назад
Thank you!
@kessedk
@kessedk 7 лет назад
MQTT made simple! Thanks again :) Did a small modification of your blink example, so that it sends a MQTT "command" ON/OFF every 3 seconds to adafruit, which it still subscribes to. So it now needs my wifi, internet connection and the adafruit service to be up and running in order to blink the LED :) Fun to play with! Next step is to make it IOTAppStory compatible :)
@AndreasSpiess
@AndreasSpiess 7 лет назад
Cool. And build your own MQTT server using a Raspberry Pi...
@kessedk
@kessedk 7 лет назад
Andreas Spiess yep I have it running on my orange ip zero with diet pi, and using the Xmas script ☺️ worked well! I haven't tried anything other than node red for testing the mqtt, but will have to test that also 😀
@AndreasSpiess
@AndreasSpiess 7 лет назад
:-)
@selvaaai
@selvaaai 8 лет назад
Hey Bro, I implemented a websocket client in node mcu which connects to SAP HANA websocket.It can do a bidirection communication.But after sometime,node mcu client is dead without notification.And also some time the message is not delivered to my node MCU client.Iam in the last phase of the project.Do you think ,i need to switch to MQTT for reliable communication.Please suggest.
@MMphego
@MMphego 7 лет назад
Hi Andreas, quick question on MQTT and ESP8266. Is it possible to have 2(two) brokers running on one ESP8266? local broker running on a raspberry pi and the other from cloud mqtt?
@AndreasSpiess
@AndreasSpiess 7 лет назад
+MphoMphego I never tried to connect in parallel to two brokers. But if you start two differen MQTT clients in parallel, this should be possible. Just try if the library is written in a good quality...
@MMphego
@MMphego 7 лет назад
I have been doing some research about this issue, and landed here: stackoverflow.com/questions/24109306/bridge-between-two-mosquitto-brokers It is achievable by using MQTT Bridge.
@Doolie_Doink
@Doolie_Doink 7 лет назад
Hi Andreas, I have installed libraries, ESP8266 and your sample code; I then get error when compiling "Error compiling for board Generic ESP8266 Module". I have tried compiling for another board i.e. Hazzah and still the same error. Any ideas please ?
@AndreasSpiess
@AndreasSpiess 7 лет назад
+Les Wilk Do you have more ? This is very generic. Do other examples compile?
@XerotoLabs
@XerotoLabs 8 лет назад
Very nice , great video . As old game coder here , i was thinking your were about to explain how to do NAT punch through with a ESP. that would have been very cool . That might have to be a reason for me to do a bit of game code again .
@AndreasSpiess
@AndreasSpiess 8 лет назад
+XerotoLabs That is exactly what I did not want! With NAT as I knew it you have to have fixed ip adresses in your WLAN. This is ok for a printer. But for sure not for devices I tinker around. My at least 10 ESP modules would create always address conflicts and adjust the ports on the route would be an additional nightmare. For me, MQTT is a very elegant solution, at least if you only want to transport data...
@XerotoLabs
@XerotoLabs 8 лет назад
+Andreas Spiess yeah it can be a mess. The way i do NAT punch in game code , i have a public server some place that manages all the handshakes . so it would be no diff' that the MQTT broker 's job . After watching your video , I agree for devices the NAT punch is a waste of resources , but I may do it just for fun . Also for fun , I still want to try having one of my ESPv12E 's run a CNC via TCP , or UDP depending on what i find easier or most fun . I know they support TCP easy . Any how great videos as ever .
@AndreasSpiess
@AndreasSpiess 8 лет назад
+XerotoLabs Thanks for the compliment! I just did some milling and just now switched the CNC off. My problems with this technology is not the processor at the machine, it is the processor between my ears! Milling for me is still very difficult and I still make many mistakes. And, even if I have a 6040 it is quite often too small. And then I need work-arounds. Very time-consuming. 3D-printing is much easier but for big parts and for aluminium or wood I still use the CNC. So, now it is 1 AM here and I go to bed ;-)
@sikotryne
@sikotryne 8 лет назад
Dave Jones reference made me laugh. Good video Andreas, appreciated.
@AndreasSpiess
@AndreasSpiess 8 лет назад
+Sindre Thanks for your comment. I appreciate it!
@josephtanner248
@josephtanner248 5 лет назад
Grüezi Andreas is your account still working and public (with account)? I could connect (node-red green), but got this errors: MQTT ERROR: jsail 212.51.158.172 SUBSCRIBE sensorsiot/feeds/command rejected, resource not available or not authorized MQTT ERROR: jsail 212.51.158.172 SUBSCRIBE sensorsiot/feeds/clientstatus rejected, resource not available or not authorized
@AndreasSpiess
@AndreasSpiess 5 лет назад
This is an old video and it is well possible that no all services still work.
@siddharthachatterjee9959
@siddharthachatterjee9959 8 лет назад
Hi, I have another question please. Can anyone please help on how to install Mosquitto (or any other MQTT service) on 64 bit PC with Windows 8 or 10 ? I have tried the Windows 7 method available on the Internet, but it does not work on 64 bit PC with Windows 8. Thanks.
@davem1492
@davem1492 8 лет назад
Thank you.Your video was informative. I like the accent neat.
@AndreasSpiess
@AndreasSpiess 8 лет назад
Thanks for the compliment!
@MightyTechGuy
@MightyTechGuy 6 лет назад
Your videos are priceless! Thanks for all this knowledge :)
@AndreasSpiess
@AndreasSpiess 6 лет назад
You are welcome!
@PunitSoni00
@PunitSoni00 8 лет назад
Didnt know that my router protects my "wifey" :) JK, nice video.!
@AndreasSpiess
@AndreasSpiess 8 лет назад
+Punit Soni You are never too old to learn something about your "wifey"! :-) I will change my pronincition in the future...
@ramixnudles7958
@ramixnudles7958 8 лет назад
+Andreas Spiess We love the accent, but as long as we can suggest pronunciation, "this is the age of the gauge!" At least here, gauge rhymes with age. :-)
@AndreasSpiess
@AndreasSpiess 8 лет назад
Thanks! Good example..Try to improve ;-)
@junaidahmed-kc6li
@junaidahmed-kc6li 4 года назад
@@AndreasSpiess Is it possible to retrieve feed data and control actuator ? If yes, then please let me know which board i can use to control it. Thank you :-)
@abhinavkumar1253
@abhinavkumar1253 6 лет назад
I have made a block in adafruit mqtt in which the value differ from 1 to 10 . And i want to read this as integer in nodemcu i.e in arduino IDE while compiling...i mean i want to set it as ....when the value will be 1 in the feed then it on LED 1 when value in broker will be 2 then ON LED2 and so on.... Please help... How to get it as integer value
@AndreasSpiess
@AndreasSpiess 6 лет назад
I cannot do software support for 55'000 subscribers. Sorry.
@1_HighDuke
@1_HighDuke 2 года назад
How would you go about retrieving the last known value for the Command ("On/off") feed? Say you want your lamp to immediately be on or off depending on the position of the button in the Adafruit.io Dashboard. Is there a way to do this in the setup() function? I'm asking because everything I've seen until now requires you to change the state/value of the feed before it gives you the first value -- so say the dashboard button is "Off", well upon running the code, your mqtt subscription will not give you a value until you switch the button in the Dashboard to "On", then it will work ok. But I'm interested in the last known value for that feed upon initialization.
@AndreasSpiess
@AndreasSpiess 2 года назад
You can either change the value by receiving an MQTT message on your ESP or you have to save the last value in the memory of the ESP. If you want it survives a power down, in the "EEPROM"
@alanpowell328
@alanpowell328 7 лет назад
Hi Andreas, I created an account and got started. Am I correct in thinking that I can subscribe to sensorsiot/feeds/luminosity and check out/ operate your light? I had a quick attempt without success. I will go to learning.adafruit and RTFM. Many thanks for an excellent introduction to MQTT. Alan
@AndreasSpiess
@AndreasSpiess 7 лет назад
I cancelled my part since a longtime because I had no reaction. Sorry...
@MPElectronique
@MPElectronique 7 лет назад
Hi Andrea. What is the diffrence between adafruit io library and mqtt library ?
@AndreasSpiess
@AndreasSpiess 7 лет назад
I do not know the details. Recently, I used the pubsub library and also once the async mqtt client
@troncquoS
@troncquoS 8 лет назад
Another nice video, thank you for that Andreas. Und jetzt schnell ein ESP8266 Modul suchen / kaufen und losgehen ;)
@AndreasSpiess
@AndreasSpiess 8 лет назад
+Sven Troncquo Danke. Das ist wohl das kleinste Problem. Die gibt's ja unterdessen überall!
@troncquoS
@troncquoS 8 лет назад
+Andreas Spiess Is the "build-in" photocel connected to the ADC input of the esp? I'm trying to connect a DHT22 with my NodeMCU . I ordered a DOIT and got an AMICA, but looks like the DOIT and is also breadboard friendly. I saw on the net that the analog ADC input is only capable of 1V maximum. This means that I have to make a voltage divider?
@AndreasSpiess
@AndreasSpiess 8 лет назад
+Sven Troncquo 1. the LDR is connected to the ADC, but only on the Witty board 2. Yes, it has a max. Of ca.1Volt and yes, you have to use a voltage divider or a potentiometer to get the maximum (you might not get the exact resistor values needed)
@hgravina
@hgravina 8 лет назад
There is any way to read a value from broker again? I am having some Dropped Packeges ... so i want to my device read the topics every 5 seconds!
@AndreasSpiess
@AndreasSpiess 8 лет назад
MQTT protocol offers so called QOS levels. QOS=1 means, that each packet is delivered at least once. QOS=2, that is is exactly delivered once.
@Real_Barbunia
@Real_Barbunia 5 лет назад
dont we have a chance to access from internet to our esp without anay other webpage? i want to get connected to my esp but dont want to spend time in adafruit's page. is there any chance to use mqtt in other ways?
@AndreasSpiess
@AndreasSpiess 5 лет назад
Yes. Maybe you google?
@shoaibiqbal9788
@shoaibiqbal9788 7 лет назад
Hi, I'm looking for something similar but using a Wifly sheild for the Arduino but have had no luck, the shield connects to the internet but does not connect through mqtt to adafruit.io.
@AndreasSpiess
@AndreasSpiess 7 лет назад
So, there is some additional work to be done. I used MQTTlens (a chrome extension) to first test the connection to adafruit.io. Like that, you can find out, if your problem is in the call (like credentials, etc.) or in your sketch.
@shoaibiqbal9788
@shoaibiqbal9788 7 лет назад
Andreas Spiess Thanks, I'll try it out asap
@dennbauer
@dennbauer 7 лет назад
Hi, I am having the following problem and am desperatly looking for help: I run an Nodemcu ESP8266 12E board, programmed in Arduino. I would like to connect three input buttons to D6, D7 an D8. Each button is linked to a separate pullup-resistor of 10K Ohm. The button on D6 is working fine, if connected alone. But if I connect the others on the circuit board, they do not work. Also I can see that the button on D6 is triggering the input on D7. First questions: Are 10K Ohn the right choice when running more than one pull-up resistor? Are D6 (GPIO 1512), 7 (GPIO 1513) and 8 (GPIO 15) GPIO I can use for inputs? Will try to add a picture of my circuit and example code as soon as possible. Thank you in advance for helping!
@AndreasSpiess
@AndreasSpiess 7 лет назад
I am not sure how you connected your switches, but you need an independent pull-up resistor for each pin. Otherwise, your pins are all connected together. Then, check if the levels on each pin is really 0 and 3.3 volt. It is well possible, that D8 will not reach 3.3 volt, because on many boards, it has a pull-down resistor attached to it. GPIO15 is used for the boot process, so, it often is pulled down. And last, I would try one after the other and remove all others completely.
@dennbauer
@dennbauer 7 лет назад
Dear Andreas, thank you for your answer! I wired everything up like this: goo.gl/photos/ZTKjQTtsgF3nsg8D9 If I connect only SW2/R1 (GPIO12), everything works fine. If I connect SW2/R1 (GPIO12) and SW3/R2 (GPIO13), the following scenario occurs: Triggering SW2 will trigger both Pins: GPIO12 and GPIO13 Triggering SW3: nothing happens. Is my wiring correct? Thank you again for your help!
@AndreasSpiess
@AndreasSpiess 7 лет назад
The wiring seems to be correct. But please do your measurements and tests as I wrote before, because somethings seems not to work properly. Also have a look at the software. Do not use complicated software, just a few statements which exactly do what you want to test (like the blink sketch). Pinmode, digital read, serial.print, delay. Not more.
@dennbauer
@dennbauer 7 лет назад
Ok, thanks again. Measurements done and first part of the solution found: When triggering the first button, the pullup-resistor for the second seems to be not strong enough. So I tried 10k and 100k which prevents the second pin from getting pulled by triggering the first button. the code I use is quote simple. I will doublecheck again, but think the solution lies somehow in choosing the correct resistors.
@AndreasSpiess
@AndreasSpiess 7 лет назад
I usually resistors around 5k for pullup.
@colfaxschuyler3675
@colfaxschuyler3675 8 лет назад
I'm glad you number these! Makes keeping notes much easier... I signed up for the Adafruit beta, and tried to see your feeds from online. Evidently I haven't figured out how to do that yet... Adafruit foiled me at every turn. CAN we see your dashboard? Do I misunderstand, or is it just limited to MQTT traffic through devices (which I haven't, yet). I've tried the obvious strings that you've supplied in the video, and various searches on project and user name. Maybe my account is not configured correctly?
@craiglarson2346
@craiglarson2346 3 года назад
I keep going back to the Spiess LIbrary to learn more. Thanks for building a great one. In this video, you say that "MQTT transfers all values as characters". I've read that one of the MQTT advantages is that MQTT is data agnostic for M-2-M communications. Transfering a 16-bit variable (e.g. 65565) would require 5 bytes as characters, but only 2 bytes as binary. Could you please comment on why the MQTT standard is character based? Thanks.
@AndreasSpiess
@AndreasSpiess 3 года назад
I am not sure if there is any standard or if people just do it. I assume you can also transfer "coded" numbers if you own the backend and know how to decode it.
@craiglarson2346
@craiglarson2346 3 года назад
@@AndreasSpiess Thank you, Andreas.
@danialvarez9
@danialvarez9 6 лет назад
Hi!, i've got a ask.. How can i do to see "My Feeds" in Adafruit.io?
@AndreasSpiess
@AndreasSpiess 6 лет назад
I did not use this service for a long time
@hassanahmad9597
@hassanahmad9597 6 лет назад
first thank you second , i wanna create 2 way switch with adafruit i mean in one way you can turn on/off the led(relay) by adafruit io and , in another way you can turn on/off the led(relay) by using a push button
@AndreasSpiess
@AndreasSpiess 6 лет назад
This is an old video and I am not sure if you can send messages from Adafruit.io
@stevenathandesa208
@stevenathandesa208 6 лет назад
Great tutorial!
@AndreasSpiess
@AndreasSpiess 6 лет назад
Thank you!
@philippecorbel7365
@philippecorbel7365 8 лет назад
Hi Andreas! very good video thanks a lot have question using ESP8266 and io.adafruit mqtt I’am using esp8266 with solar power batterie, publishing mqtt every 5mn or so, then going in sleep mode for saving batterie (thanks Andreas). If in mean time button change ON or OFF, when ESP8266 connect next time for publishing it can’t get the subscriptions change ON/OFF? Or other way to solve it, would it be able to read any value at each time esp8266 is connect to mqtt server. do you have a solution? Thanks Philippe
@AndreasSpiess
@AndreasSpiess 8 лет назад
+Philippe CORBEL Google "MQTT quality of service levels". There you will find the solution. Not sure, it works with adafruit
@padmanabhareddy2918
@padmanabhareddy2918 4 года назад
I am getting an error esptool.FatalError.Falied to connect to Esp8266:Time out waiting for packet header
@AndreasSpiess
@AndreasSpiess 4 года назад
Maybe you try to upload a blink sketch first. It seems to be a basic error.
@TechInventorAman
@TechInventorAman 5 лет назад
how do you make your videos or which software do you use ?
@AndreasSpiess
@AndreasSpiess 5 лет назад
Maybe you watch my lab reports. I use Powerdirector 14
@Jasmohan
@Jasmohan 8 лет назад
Can you help me out with something? I have an Arduino which is connected to an analog sensor. The values of the sensor are converted into a number we can understand like degrees celcius. I am sending that number to ESP8266 through Serial port. I am hosting a webpage on my local network. When a client(like my desktop) connects to the ESP8266, I get the webpage on my browser. On the page, the number from the analog sensor is shown. To update the number I use this:- I have used this in the HEAD of the webpage I am sending. Due to this, the page refreshes after 5 seconds so that the client requests again, and ESP8266 sends the full webpage again. I want that the whole page does not refresh, just the the number on the webpage. Do you know any method to do this?
@AndreasSpiess
@AndreasSpiess 8 лет назад
+Jasmohan Singh Narula In episode #30 I use a technique called AJAX to do someting like that. You can have a look at this programm. It separates the text from the content. Maybe, with this method you can get what you want if you only once send the text and manytimes send the numbers. You find also a link to the "inventor".
@AndreasSpiess
@AndreasSpiess 8 лет назад
+Jasmohan Singh Narula Maybe this is also interesting in this context: babaawesam.com/2015/11/26/control-input-output-of-esp8266-with-ajax/
@Jasmohan
@Jasmohan 8 лет назад
+Andreas Spiess Thank you my friend. I'll check the episode and link you gave.
@norbertoestrada971
@norbertoestrada971 6 лет назад
great tutorial on mqtt, but most of all, the humour cracked me up :))
@AndreasSpiess
@AndreasSpiess 6 лет назад
Thanks!
@IoTLearner
@IoTLearner 6 лет назад
I'm working with Adafruit_mqtt library, you have make the feeds on your own at Adafruit.io....Don't know about pubsubClient
@AndreasSpiess
@AndreasSpiess 6 лет назад
Just google. It is very well documented.
@ivangarrido6240
@ivangarrido6240 7 лет назад
Hi (sorry i am a newbie) I tried to do it through Adafruit MQTT, installed all 3 libraries and changed values on ESP_MQTT_PUBSUB sketch.Using a wemos d1 mini with a photolight sensor. i could not include the library "credentials_Adafruit_IO.h" library is not found when compiled and couldn't find it in any of the 3 libraries. i disabled it to try and sketch runs, it connects to wifi and initially connects/measures to MQTT then stays mostly trying to reconnect. on the IO.Adafruit site on the opened account, it didn't get the feed to show up. current version is different. not sure if need to add the feed somehow or should be recognized when the sketch loaded with right credentials. also not clear on the "credential_adafruit_IO" library missing. really appreciate if given a clue what i am missing.
@ivangarrido6240
@ivangarrido6240 7 лет назад
never mind. didn't realized the topic sensorsiot was expired. once i changed it to my Feeds username, the luminosity feed started loading. great tutorial!
@AndreasSpiess
@AndreasSpiess 7 лет назад
:-)
@NansEverything
@NansEverything 7 лет назад
Excuse me, I have replaced my Feeds username but it still can't find credentials_Adafruit_IO.h What should I do???
@AndreasSpiess
@AndreasSpiess 7 лет назад
You have to create your own credentials for adafruit on their homepage.
@NansEverything
@NansEverything 7 лет назад
I'm the beginner of MQTT, could you please guide me which page in Adafruit that used for create the credential?
@deangreenhough3479
@deangreenhough3479 7 лет назад
I've been struggling with this topic. Why didn't I think to check here first DOH😂😂
@AndreasSpiess
@AndreasSpiess 7 лет назад
:-)
@Popart-xh2fd
@Popart-xh2fd 7 лет назад
Do you know how to use the ESP8266 together with an Arduino Board and be able to connect trough MQTT? It looks like people only knows to use the ESP8266 alone when it comes to MQTT, for MQTT connections I still haven't saw anyone that have used an ESP8266 as a WiFi module only with sketches uploaded to the Arduino board instead...!
@AndreasSpiess
@AndreasSpiess 7 лет назад
No, I do not know of such a concept. But I never searched for one. The concept of using the ESP as a wifi module is no more used by many people.
@Popart-xh2fd
@Popart-xh2fd 7 лет назад
Andreas Spiess As you know, the ESP8266 (ESP-01) has only Digital GPIOs, no Analog ones. These cheap modules are clearly limited when it comes to GPIO pins, so is reasonable to center the programming in a Arduino board with lots of GPIOs and rely on the ESP only for wireless connections. I did that for Analog sensors report trough HTTP to the dweet.io site. MQTT is different from HTTP in the way that the headers are Binary and not ASCII text, so you are unable to just post AT commands with textual Headers when it comes to MQTT... I realize that the only solution to center sensors in a common Arduino Board is to transmit the data throughout a Serial connection between the Arduino and the ESP8266 where ESP8266 deals with the MQTT protocol and the Arduino board with all the sensors, you just have to use the Read and Write Serial functions to make the sensors' data communication between the two devices, something avoidable if it was possible to use the AT commands for MQTT connections at the Arduino board!
@AndreasSpiess
@AndreasSpiess 7 лет назад
+Popart 2015 If you watch my todays video you find exactly this scenario...
@Popart-xh2fd
@Popart-xh2fd 7 лет назад
Andreas Spiess After seeing your last video, and knowing that the ESP-01 has 1 MBytes of Flash memory and the Arduino Uno has only 32 kBytes, I must realize that the ESP8266 is the device that should be in the center of things and not the typical Arduino board. These boards without the ESP8266 are only useful due to their extra GPIOs, so, when in use as is the case of your last video, it's only to feed the ESP with sensor data... In conclusion, considering the new protocol MQTT, makes no sense to buy an Arduino board without an ESP8266!
@AndreasSpiess
@AndreasSpiess 7 лет назад
I agree with you and plan to do an MQTT interface for the Sonoff (ESP8266 based).
@err_404_not_found
@err_404_not_found 5 лет назад
Mindblowing
@AndreasSpiess
@AndreasSpiess 5 лет назад
:-)
@watawonderfulworld
@watawonderfulworld 8 лет назад
Thanks Andreas as usual. Looking forward to more videos. By the way, for local communication, can we use ESP8266 itself as MQTT broker?
@AndreasSpiess
@AndreasSpiess 8 лет назад
Newer tried that.
@AhmadAsmndr
@AhmadAsmndr 5 лет назад
thank you very much.. Vielen Dank!!
@AndreasSpiess
@AndreasSpiess 5 лет назад
You are welcome!
@archgloom
@archgloom 7 лет назад
will it work if internet gets disconnected but WiFi router switched on ?
@AndreasSpiess
@AndreasSpiess 7 лет назад
If your MQTT broker is in the internet, it will not work. Then, you would have to build you own MQTT broker (which is not too complicated). Watch my newest videos if you are interested in this.
@reugrech
@reugrech 8 лет назад
Great video Andreas! Luv the accent! Have a question. Is there any way one could create a simple web interface on the ESP8266 which would be password protected but would allow to enter the WiFi and MQTT usernames and passwords dynamically, and not have them hardcoded?
@AndreasSpiess
@AndreasSpiess 8 лет назад
+Reuben Grech Thanks for your compliment! First, the ESP does usually not support SSL. So, the information is readable. An second, yes. If you watch my video series about creating an IOT infrastructure for the ESP you will see, that I present there a solution to connect the ESP first to a smartphone or browser to enter the WiFi credentials. But of course, you can use the same thing to enter the MQTT credentials. Just add the two fields. If you do it right they should be stored in "EEPROM" and be available the next times you start the ESP.
@reugrech
@reugrech 8 лет назад
+Andreas Spiess Thanks for your feedback and keep your videos coming!!
@chi-tinhnguyen5176
@chi-tinhnguyen5176 6 лет назад
thank your video much sir please help me when I open serial monitor, It issue some word : Not authorized to connect How can I solve this problem ?
@AndreasSpiess
@AndreasSpiess 6 лет назад
I do not know. You have to find the error yourself. Maybe wrong password?
@altsushant674
@altsushant674 7 лет назад
@0:45 It's like "your router firewall protects your wife from other people surfing the internet".
@AndreasSpiess
@AndreasSpiess 7 лет назад
Of course, it does ;-)
@altsushant674
@altsushant674 7 лет назад
true ......but here I am trying to find a wife for me on internet and firewalls coming in my way. :D
@HGMtyfilms
@HGMtyfilms 8 лет назад
yo no se mucho pero si tienes una luz y algo que detecta luz, ...para detectar si funciona le detector pones la luz enfrente, y si cambia lo detecta, cierto? :-)
@AndreasSpiess
@AndreasSpiess 8 лет назад
Unfortunately, I do not understand Spanish.
@izoumashka
@izoumashka 8 лет назад
very nice video.one question: what is the #include "credentials_Adafruit_IO.h" file?
@AndreasSpiess
@AndreasSpiess 8 лет назад
+fun electronics videos Because I do not want to disclose my credentials on github i have a system that I put these into a file in the library folder. Then, I am sure that I do not publish them accidentally. It has the same info as the few lines below the line: /* definition of credentials and feeds In this example it is also easy to change from one broker to another with the same sketch. Then, I just have to change the include file.
@piyushtailor3608
@piyushtailor3608 6 лет назад
Sorry,but I didnt get it.
@HGMtyfilms
@HGMtyfilms 8 лет назад
Do not worry Sir, your explanation is very very good. I just saying that seems a little too much code, because, if you have somthing that "detetects ligth" and One "light" a side...makes sense (to me) that; if you put them somehow together, you may detect if works or not...i'm i right?....jijijiji
@AndreasSpiess
@AndreasSpiess 8 лет назад
Yes, you are right.
@rezvanrezaei7500
@rezvanrezaei7500 8 лет назад
Thanks for your good video :) I think TLS is really necessary for MQTT. But some MQTT client libraries such as pubsub library doesn't support TLS. I need a library to work on esp8266 and can use it in arduino ide. do you know any of them?
@AndreasSpiess
@AndreasSpiess 8 лет назад
I do not know a lot about internet protocols, so I am no help here.
@SamZorSec
@SamZorSec 8 лет назад
You can use WiFiClientSecure instead of WiFiClient. Link: io.adafruit.com/blog/security/2016/07/05/adafruit-io-security-esp8266/
@rezvanrezaei7500
@rezvanrezaei7500 8 лет назад
YES! thanks indeed :))
@fuzzie4755
@fuzzie4755 8 лет назад
Hi Andreas, based on you great input, I do now have more a less a platform to connect different sensors and interact with them. Since yesterday there where some sudden reboots when MQTT send/receive and an interrupt on an GPIO happened. Really bad to reproduce but happen from time to time and reboot the ESP. I found more or less by accident this really important add on in function declaration that now avoid any interrupt conflict. ICACHE_RAM_ATTR. You can google on it. For example I modify the MQTT callback like this: "void ICACHE_RAM_ATTR mqtt_callback(char* topic, byte* payload, unsigned int length) {.....}" Maybe you have seen similar and wondering what happened.
@AndreasSpiess
@AndreasSpiess 8 лет назад
So far, I did not have problems I was not able to solve. I use the standard attachInterrupt of Arduino. But good to know if it happens to me too... Thanks!
@fuzzie4755
@fuzzie4755 8 лет назад
+Andreas Spiess: it only happens if you handle with different interrupts like the watch dog and Mqtt listener and a interrupt on GPIO.
@AndreasSpiess
@AndreasSpiess 8 лет назад
Aha! Thanks
@sajjadahmad5298
@sajjadahmad5298 7 лет назад
Nice tutorial. sir i am trying to establish ssl connection between esp8266 client and MQTT broker, but don't know how to do that. any help in this regard will be appreciated.
@AndreasSpiess
@AndreasSpiess 7 лет назад
Maybe you look at the HTTPSRequest example or WiFiClientSecure. I do not know what has to be done for the MQTT libaries. And google ( internetofhomethings.com/homethings/?p=1820 )
@PIYUSHTAILORstillalive
@PIYUSHTAILORstillalive 6 лет назад
I am getting SSID (20): Labhansh Photography Passphrase (9): thakkar69 BSSID set: 0 Attempting MQTT connection... failed, rc=-2 try again in 5 seconds Measure Attempting MQTT connection... failed, rc=-2 try again in 5 seconds Please help!
@AndreasSpiess
@AndreasSpiess 6 лет назад
Maybe you check if you have all passwords and keys of adafruit correct in your sketch
@PIYUSHTAILORstillalive
@PIYUSHTAILORstillalive 6 лет назад
Ichecked but no progress.Can there be any other issue?
@AndreasSpiess
@AndreasSpiess 6 лет назад
Obviously it is another problem ;-) maybe you use mqttlens in the chrome beowser to test adafruit witout your ESP
@PIYUSHTAILORstillalive
@PIYUSHTAILORstillalive 6 лет назад
Sorry,but coul d ypu please elaborate?
@prasadjadhav624
@prasadjadhav624 5 лет назад
Hi Andreas, nice video, very detail information. i tried this it worked well. One issue i am facing is my nodemcu does not respond after 10-15 minutes. it seems it is dead. I tried following code too WiFi.setSleepMode(WIFI_NONE_SLEEP) but it seems its not working. It works only for 10 mins after restart. can you suggest something to keep nodemcu alive forever. thanks in advance
@AndreasSpiess
@AndreasSpiess 5 лет назад
Maybe you insert some serial.print statements to see where it crashes. I cannot do remote debugging:-(
@siddharthachatterjee9959
@siddharthachatterjee9959 8 лет назад
Hi, nice video. Thanks. Further can you suggest a resource where I can lean MQTT-SN ? Thanks in advance.
@AndreasSpiess
@AndreasSpiess 8 лет назад
I do not know MQTT-SN (even if it was developed also in IBM Switzerland). So, I cannot help.
@siddharthachatterjee9959
@siddharthachatterjee9959 8 лет назад
Okay. Thank you.
@pedrobravo6972
@pedrobravo6972 4 года назад
Hi Andreas, thank you for this wonderfull video!! However I can´t find the adafruit.io in Playstore. Do you use another one? I need it to use it in an Android device. Another thing, I try the sketch you publish in GitHub, but it don´t work properly. Any possibility to have the complete sketch you use in the video??? (this is based in pubsubclient library...) I am developing an MQTT app which can send topics, call back and send SMS to the user. Thank you for your help. Have a nice day. With best regards, Pedro
@AndreasSpiess
@AndreasSpiess 4 года назад
This is an old video and things might be different now. But adafruit.io is still running. It was never in the playstore.
@RishiRajKoul
@RishiRajKoul 2 года назад
How does MQTT create connection with remote device without knowing its IP?
@AndreasSpiess
@AndreasSpiess 2 года назад
All devices only connect to the (known) address of a broker.
@RishiRajKoul
@RishiRajKoul 2 года назад
@@AndreasSpiess How does Brocker send messages back to Clients that have a Private IP?
@AndreasSpiess
@AndreasSpiess 2 года назад
@@RishiRajKoul There is a connection made by the client.
@RishiRajKoul
@RishiRajKoul 2 года назад
@@AndreasSpiess thanks. A quick one. Does MQTT work if Private IP is behind a NAT server?
@AndreasSpiess
@AndreasSpiess 2 года назад
@@RishiRajKoul Yes
@erikjorpes1325
@erikjorpes1325 7 лет назад
Thanks for a good inspiration. I currently working on a similar project and have much help from you videos. My project is based on Adafruit MQTT Library ESP8266 Example and including #include "Adafruit_MQTT.h". #include "Adafruit_MQTT_Client.h". What I do not understand is how it should be possible for the main loop to to more than sleep. Assume I have a readSubscription every 5 sek while ((subscription = mqtt.readSubscription(5000))) {... the main loop does nothing in the sleep time. Assume, I will read a motion sensor and interrupt a MQTT message as soon interrupt happens, how is that possible? Currently I inly enter my motionSensorAnalogReadingThing every 5000 ms, independen where I put it in main loop(). Thanks for your engeneering analytics! /E
@AndreasSpiess
@AndreasSpiess 7 лет назад
I only used this library once. Now I usually use the pubsub library. So I cannot help you. Maybe you find the info in the usually good documentation of Adafruit.
@eduardfc
@eduardfc 8 лет назад
Very instructional video! In my case, I prefer to use DDNS and create a DMZ on my Firewall.
@AndreasSpiess
@AndreasSpiess 8 лет назад
Thanks! Also a good concept with a DMZ...
@stokseelalleen1913
@stokseelalleen1913 7 лет назад
The humour :) Subscribed. Also the information was superb. Thank you
@AndreasSpiess
@AndreasSpiess 7 лет назад
Thanks for your support!
@enricosaccheggiani3192
@enricosaccheggiani3192 5 лет назад
Andreas this is the guy with italian accent: You are a genius , you have solved my problem. Thanks a lot There is a problem . I don't find MQTT.h header file no such file or directory. what do we have to do ? Thanks a lot
@AndreasSpiess
@AndreasSpiess 5 лет назад
This is an old video and many things changed since then. So I do not know and unfortunately I do not have the time to keep all my videos up-to-date :-(
@tejeetmagar2846
@tejeetmagar2846 8 лет назад
why the adfruit gives this internal server error
@AndreasSpiess
@AndreasSpiess 8 лет назад
I do not know
@jesuishalil
@jesuishalil 8 лет назад
The joke at 2:35 cracked me up! Esp8266 has no wpa2 for hosting the web server right? So would have a secure log in page when using https and a password?
@AndreasSpiess
@AndreasSpiess 8 лет назад
+Glychee S Unfortunately, I do not understand what you mean. To my knowledge, WPA protocols are used in LAN environment behind the firewall. And as far as I know, MQTT does not need a webserver on the ESP. Fact is, that currently all traffic from the ESP to Adafruit.io is open. I do not use SSL. This is mybe the next step, but not easy for me, because I do not know a lot about certificates etc. But the test data I transfer for the moment are not very valuable.
@jesuishalil
@jesuishalil 8 лет назад
I should have posted it as a seperate question, when using a smartphone to log into your esp8266 which is hosting a web page, there is no wpa2 security, i have heard. To have proper security, would hosting a web page with HTTPS and a log in password be more secure?
@AndreasSpiess
@AndreasSpiess 8 лет назад
First: In this video there is no log-in necessary on the ESP and there is no webserver running on the ESP. The webserver you see is on adafruit.com. Second: HTTPS would be save, yes. Unfortunately, the ESP8266 does not support that (at least to my knowledge). We have to wait for the ESP32 for this feature. Third: WPA is a different level. It is the protocol used by your Wi-Fi hardware between your device or PC and the access point. It prevents that somebody can listen to your private WiFi trafic. HTTPS is on a higher level and works not only in your wifi, but worldwide from the server to the client.
@jesuishalil
@jesuishalil 8 лет назад
Great! thanks =)
@phaniharsha5306
@phaniharsha5306 6 лет назад
Sir plz tell me how to install mqtt library
@AndreasSpiess
@AndreasSpiess 6 лет назад
Like any other MQTT library. It is in the Arduino IDE. If you do not know how to install an Arduino library, Google is your friend ;-)
@Tanishqdhanuka
@Tanishqdhanuka 5 лет назад
error rc=7 could mean?
@AndreasSpiess
@AndreasSpiess 5 лет назад
I do not know
@edilmarlulab1981
@edilmarlulab1981 5 лет назад
what is broker?
@AndreasSpiess
@AndreasSpiess 5 лет назад
Maybe you ask Google?
@edilmarlulab1981
@edilmarlulab1981 5 лет назад
@@AndreasSpiess thank you that was very informative
@soumahend4015
@soumahend4015 7 лет назад
first : I use mosquitto MQTT local offline MQTT. and it havn't a username and key. second : in my code WiFi.begin(ssid, password); and WiFi.status() dosn't work. this is my code: //ItKindaWorks - Creative Commons 2016 //github.com/ItKindaWorks // //Requires PubSubClient found here: github.com/knolleary/pubsubclient // //ESP8266 Simple MQTT light controller #include #include //EDIT THESE LINES TO MATCH YOUR SETUP #define MQTT_SERVER "192.168.173.1" const char* ssid = "zed_2017"; const char* password = "zed__2017"; //LED on ESP8266 GPIO2 const int lightPin = 2; char* lightTopic = "topic"; //"/test/light1"; void callback(char* topic, byte* payload, unsigned int length); WiFiEspClient wifiClient; PubSubClient client(MQTT_SERVER, 1883, callback, wifiClient); void setup() { //initialize the light as an output and set to LOW (off) pinMode(lightPin, OUTPUT); digitalWrite(lightPin, LOW); //start the serial line for debugging Serial.begin(115200); delay(100); //start wifi subsystem Serial.println("Connecting to "); Serial.println(ssid); delay(1000); WiFi.begin(ssid, password); //attempt to connect to the WIFI network and then connect to the MQTT server reconnect(); //wait a bit before starting the main loop delay(2000); } void loop(){ //reconnect if connection is lost Serial.println("loop"); Serial.println(client.connected()); delay(1000); //Serial.println(WiFi.status()); //delay(1000); if (!client.connected() && WiFi.status() == 3) { Serial.println("reconnect avant"); delay(1000); reconnect(); } Serial.println("loop client avant"); delay(1000); //maintain MQTT connection client.loop(); //MUST delay to allow ESP8266 WIFI functions to run delay(10); } void callback(char* topic, byte* payload, unsigned int length) { //convert topic to string to make it easier to work with String topicStr = topic; //Print out some debugging info Serial.println("Callback update."); Serial.print("Topic: "); Serial.println(topicStr); //turn the light on if the payload is '1' and publish to the MQTT server a confirmation message if(payload[0] == '1'){ digitalWrite(lightPin, HIGH); client.publish("/test/confirm", "Light On"); } //turn the light off if the payload is '0' and publish to the MQTT server a confirmation message else if (payload[0] == '0'){ digitalWrite(lightPin, LOW); client.publish("/test/confirm", "Light Off"); } } void reconnect() { //attempt to connect to the wifi if connection is lost if(WiFi.status() != WL_CONNECTED){ //debug printing Serial.print("Connecting to _reconnect"); Serial.println(ssid); //loop while we wait for connection while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } //print out some more debug once connected Serial.println(""); Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(WiFi.localIP()); } //make sure we are connected to WIFI before attemping to reconnect to MQTT if(WiFi.status() == WL_CONNECTED){ // Loop until we're reconnected to the MQTT server while (!client.connected()) { Serial.print("Attempting MQTT connection..."); // Generate client name based on MAC address and last 8 bits of microsecond counter String clientName; clientName += "esp8266-"; uint8_t mac[6]; WiFi.macAddress(mac); clientName += macToStr(mac); //if connected, subscribe to the topic(s) we want to be notified about if (client.connect((char*) clientName.c_str())) { Serial.print("\tMTQQ Connected"); client.subscribe(lightTopic); } //otherwise print failed for debugging else{Serial.println("\tFailed."); abort();} } } } //generate unique name from MAC addr String macToStr(const uint8_t* mac){ String result; for (int i = 0; i < 6; ++i) { result += String(mac[i], 16); if (i < 5){ result += ':'; } } return result; } AND the Out in moniteur serie it is : Connecting to zed_2017 Connecting to zed_2017 Connecting to zed_2017 Connecting to zed_2017 I don't understande what is the probleme? can U help me pliiiz
@AndreasSpiess
@AndreasSpiess 7 лет назад
Maybe you ask the author of this sketch first?
@wilsonmassamiishihara6475
@wilsonmassamiishihara6475 4 года назад
It's easy, but more expensive
@AndreasSpiess
@AndreasSpiess 4 года назад
Compared with what?
@Schnorschel
@Schnorschel 8 лет назад
lumiNosity, not lumiosity. There is an "n" in there, and it is not silent when pronounced.
@AndreasSpiess
@AndreasSpiess 8 лет назад
Thanks!
Далее
Family♥️👯‍♀️🔥 How old are you? 🥰
00:20
Home automation over WiFi using WeMos ESP8266
15:00
Просмотров 656 тыс.
#112 LoRa / LoRaWAN De-Mystified / Tutorial
20:25
Просмотров 1 млн
How do Graphics Cards Work?  Exploring GPU Architecture
28:30
Family♥️👯‍♀️🔥 How old are you? 🥰
00:20