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

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 พ.ค. 2024
  • In this video I connect my ESP8266 to the world. I build a MQTT connection to Adafruit.io and from there, to ,my IPAD, to IFTT and to a node-red instance hosted on IBM bluemix service.
    I also show why this is one of the simplest concepts to solve the connection problem from behind your firewall to the internet.
    For my tests, I used three different MQTT client libraries:
    github.com/i-n-g-o/esp-mqtt-a...
    pubsubclient.knolleary.net/
    github.com/adafruit/Adafruit_...
    Witty Board: s.click.aliexpress.com/e/EY3GoAy
    They are all included in the Arduino IDE.
    For your convenience, I posted the sketches I used for my tests to github. If you replace the credentials (and the feeds) you should be able to start with MQTT.
    Example code: github.com/SensorsIot/MQTT-Ex...
    Supporting Material and Blog Page: www.sensorsiot.org
    Github: www.github.com/sensorsiot
    If you want to support the channel and buy from Banggood use this link to start your shopping: bit.ly/2jAQEf4 (no additional charges for you)
    Official Wemos Store: s.click.aliexpress.com/e/jUzBiIq
    / sensorsiot
    / spiessa
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 225

  • @brianschwind6530
    @brianschwind6530 7 ปีที่แล้ว +7

    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  7 ปีที่แล้ว +2

      Thank you very much for your nice comment!

  • @KennethTanFotografie
    @KennethTanFotografie 8 ปีที่แล้ว +34

    One of the best introductions into MQTT ever seen. Love the accent.

  • @spacefolder
    @spacefolder 7 ปีที่แล้ว +1

    You are a great teacher, with an AMAZING sense of humor! Thank you.

  • @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...

  • @techlander00
    @techlander00 7 ปีที่แล้ว +1

    Hi Andreas ! Simple, linear, pro, crystal clear. Thanks a lot for everythingM

    • @AndreasSpiess
      @AndreasSpiess  7 ปีที่แล้ว +2

      Thanks for this very nice comment!

  • @filipeterra8981
    @filipeterra8981 8 ปีที่แล้ว +5

    best youtube channel ever! great diagrams and a catchy voice. thank you for the esp8266 videos!

    • @AndreasSpiess
      @AndreasSpiess  8 ปีที่แล้ว +2

      +filipe terra Thank you very much for your compliment!

  • @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...

  • @rolandomartin
    @rolandomartin 6 ปีที่แล้ว

    Andreas, you are a great communicator. Love your videos. Greetings from Canada!

  • @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

  • @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!

  • @jimmy21584
    @jimmy21584 6 ปีที่แล้ว

    This was very clear, and a great choice of libraries - thank you!

  • @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!

  • @rinokentie8653
    @rinokentie8653 2 ปีที่แล้ว

    Andreas - this old video was of great help. I am trying to understand the workings of Adafruit.io. Thanks!

  • @AcessoTeleInfo
    @AcessoTeleInfo 6 ปีที่แล้ว

    Congratulations from Brazil! Very good!

  • @MightyTechGuy
    @MightyTechGuy 5 ปีที่แล้ว

    Your videos are priceless! Thanks for all this knowledge :)

  • @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.

  • @anokhautomation4453
    @anokhautomation4453 3 ปีที่แล้ว

    Very helpful totorial sir. I am already build a project with adafruit mqtt +ifttt+google assistant voice command.

  • @sikotryne
    @sikotryne 8 ปีที่แล้ว

    Dave Jones reference made me laugh. Good video Andreas, appreciated.

    • @AndreasSpiess
      @AndreasSpiess  8 ปีที่แล้ว

      +Sindre Thanks for your comment. I appreciate it!

  • @davem1492
    @davem1492 8 ปีที่แล้ว +2

    Thank you.Your video was informative. I like the accent neat.

  • @kessedk
    @kessedk 6 ปีที่แล้ว

    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  6 ปีที่แล้ว

      Cool. And build your own MQTT server using a Raspberry Pi...

    • @kessedk
      @kessedk 6 ปีที่แล้ว

      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  6 ปีที่แล้ว

      :-)

  • @stevenathandesa208
    @stevenathandesa208 5 ปีที่แล้ว

    Great tutorial!

  • @colfaxschuyler3675
    @colfaxschuyler3675 7 ปีที่แล้ว

    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?

  • @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 ปีที่แล้ว +1

      +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 ;-)

  • @luchoescobar
    @luchoescobar 5 ปีที่แล้ว +1

    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??

  • @err_404_not_found
    @err_404_not_found 4 ปีที่แล้ว

    Mindblowing

  • @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 ปีที่แล้ว +1

      +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)

  • @stokseelalleen1913
    @stokseelalleen1913 7 ปีที่แล้ว

    The humour :) Subscribed. Also the information was superb. Thank you

  • @watawonderfulworld
    @watawonderfulworld 7 ปีที่แล้ว

    Thanks Andreas as usual. Looking forward to more videos. By the way, for local communication, can we use ESP8266 itself as MQTT broker?

  • @norbertoestrada971
    @norbertoestrada971 6 ปีที่แล้ว

    great tutorial on mqtt, but most of all, the humour cracked me up :))

  • @AhmadAsmndr
    @AhmadAsmndr 4 ปีที่แล้ว

    thank you very much.. Vielen Dank!!

  • @hassanahmad9597
    @hassanahmad9597 5 ปีที่แล้ว

    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  5 ปีที่แล้ว

      This is an old video and I am not sure if you can send messages from Adafruit.io

  • @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 ปีที่แล้ว +2

      +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 ปีที่แล้ว +1

      +Andreas Spiess Thanks for your feedback and keep your videos coming!!

  • @fuzzie4755
    @fuzzie4755 7 ปีที่แล้ว

    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  7 ปีที่แล้ว

      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 7 ปีที่แล้ว +1

      +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  7 ปีที่แล้ว

      Aha! Thanks

  • @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 ปีที่แล้ว +1

      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.

  • @eduardfc
    @eduardfc 7 ปีที่แล้ว

    Very instructional video! In my case, I prefer to use DDNS and create a DMZ on my Firewall.

    • @AndreasSpiess
      @AndreasSpiess  7 ปีที่แล้ว

      Thanks! Also a good concept with a DMZ...

  • @deangreenhough3479
    @deangreenhough3479 7 ปีที่แล้ว

    I've been struggling with this topic. Why didn't I think to check here first DOH😂😂

  • @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...

  • @HGMtyfilms
    @HGMtyfilms 7 ปีที่แล้ว

    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

  • @PunitSoni00
    @PunitSoni00 8 ปีที่แล้ว +33

    Didnt know that my router protects my "wifey" :)
    JK, nice video.!

    • @AndreasSpiess
      @AndreasSpiess  8 ปีที่แล้ว +9

      +Punit Soni You are never too old to learn something about your "wifey"! :-)
      I will change my pronincition in the future...

    • @ramixnudles7958
      @ramixnudles7958 7 ปีที่แล้ว +3

      +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  7 ปีที่แล้ว +2

      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 :-)

  • @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.

  • @erikjorpes1325
    @erikjorpes1325 6 ปีที่แล้ว

    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  6 ปีที่แล้ว

      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.

  • @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"

  • @enricosaccheggiani3192
    @enricosaccheggiani3192 4 ปีที่แล้ว

    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  4 ปีที่แล้ว

      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 :-(

  • @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?

  • @selvaaai
    @selvaaai 7 ปีที่แล้ว

    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.

  • @sajjadahmad5298
    @sajjadahmad5298 6 ปีที่แล้ว

    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  6 ปีที่แล้ว

      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 )

  • @rezvanrezaei7500
    @rezvanrezaei7500 7 ปีที่แล้ว

    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  7 ปีที่แล้ว

      I do not know a lot about internet protocols, so I am no help here.

    • @SamZorSec
      @SamZorSec 7 ปีที่แล้ว +1

      You can use WiFiClientSecure instead of WiFiClient. Link: io.adafruit.com/blog/security/2016/07/05/adafruit-io-security-esp8266/

    • @rezvanrezaei7500
      @rezvanrezaei7500 7 ปีที่แล้ว

      YES! thanks indeed :))

  • @philippecorbel7365
    @philippecorbel7365 7 ปีที่แล้ว

    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  7 ปีที่แล้ว +1

      +Philippe CORBEL Google "MQTT quality of service levels". There you will find the solution. Not sure, it works with adafruit

  • @siddharthachatterjee9959
    @siddharthachatterjee9959 7 ปีที่แล้ว

    Hi, nice video. Thanks.
    Further can you suggest a resource where I can lean MQTT-SN ?
    Thanks in advance.

    • @AndreasSpiess
      @AndreasSpiess  7 ปีที่แล้ว

      I do not know MQTT-SN (even if it was developed also in IBM Switzerland). So, I cannot help.

    • @siddharthachatterjee9959
      @siddharthachatterjee9959 7 ปีที่แล้ว

      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.

  • @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.

  • @leswilk1601
    @leswilk1601 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?

  • @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.

  • @prasadjadhav624
    @prasadjadhav624 4 ปีที่แล้ว

    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  4 ปีที่แล้ว

      Maybe you insert some serial.print statements to see where it crashes. I cannot do remote debugging:-(

  • @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.

  • @IoTLearner
    @IoTLearner 5 ปีที่แล้ว

    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  5 ปีที่แล้ว

      Just google. It is very well documented.

  • @hgravina
    @hgravina 7 ปีที่แล้ว

    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  7 ปีที่แล้ว

      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.

  • @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

  • @siddharthachatterjee9959
    @siddharthachatterjee9959 7 ปีที่แล้ว

    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.

  • @HGMtyfilms
    @HGMtyfilms 7 ปีที่แล้ว

    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  7 ปีที่แล้ว

      Unfortunately, I do not understand Spanish.

  • @archgloom
    @archgloom 7 ปีที่แล้ว

    will it work if internet gets disconnected but WiFi router switched on ?

    • @AndreasSpiess
      @AndreasSpiess  7 ปีที่แล้ว +1

      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.

  • @canerdonmez3587
    @canerdonmez3587 4 ปีที่แล้ว

    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?

  • @altsushant674
    @altsushant674 6 ปีที่แล้ว

    @0:45 It's like "your router firewall protects your wife from other people surfing the internet".

    • @AndreasSpiess
      @AndreasSpiess  6 ปีที่แล้ว

      Of course, it does ;-)

    • @altsushant674
      @altsushant674 6 ปีที่แล้ว

      true ......but here I am trying to find a wife for me on internet and firewalls coming in my way. :D

  • @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

  • @josephtanner248
    @josephtanner248 4 ปีที่แล้ว

    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  4 ปีที่แล้ว

      This is an old video and it is well possible that no all services still work.

  • @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

  • @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.

  • @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 ;-)

  • @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).

  • @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 ปีที่แล้ว +2

      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 =)

  • @tejeetmagar2846
    @tejeetmagar2846 7 ปีที่แล้ว

    why the adfruit gives this internal server error

  • @ivangarrido6240
    @ivangarrido6240 6 ปีที่แล้ว

    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 6 ปีที่แล้ว

      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  6 ปีที่แล้ว

      :-)

    • @NansEverything
      @NansEverything 6 ปีที่แล้ว

      Excuse me, I have replaced my Feeds username but it still can't find credentials_Adafruit_IO.h
      What should I do???

    • @AndreasSpiess
      @AndreasSpiess  6 ปีที่แล้ว

      You have to create your own credentials for adafruit on their homepage.

    • @NansEverything
      @NansEverything 6 ปีที่แล้ว

      I'm the beginner of MQTT, could you please guide me which page in Adafruit that used for create the credential?

  • @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

  • @RishiRajKoul
    @RishiRajKoul 2 ปีที่แล้ว

    How does MQTT create connection with remote device without knowing its IP?

    • @AndreasSpiess
      @AndreasSpiess  2 ปีที่แล้ว +1

      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 ปีที่แล้ว +1

      @@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 ปีที่แล้ว +1

      @@RishiRajKoul Yes

  • @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.

  • @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?

  • @Tanishqdhanuka
    @Tanishqdhanuka 4 ปีที่แล้ว

    error rc=7 could mean?

  • @edilmarlulab1981
    @edilmarlulab1981 5 ปีที่แล้ว

    what is broker?

    • @AndreasSpiess
      @AndreasSpiess  5 ปีที่แล้ว +1

      Maybe you ask Google?

    • @edilmarlulab1981
      @edilmarlulab1981 5 ปีที่แล้ว

      @@AndreasSpiess thank you that was very informative

  • @wilsonmassamiishihara6475
    @wilsonmassamiishihara6475 3 ปีที่แล้ว

    It's easy, but more expensive

  • @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?

  • @Schnorschel
    @Schnorschel 7 ปีที่แล้ว

    lumiNosity, not lumiosity. There is an "n" in there, and it is not silent when pronounced.