#33 Internet of Things with ESP8266 #5: Watchdogs, Timers & Stability

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ธ.ค. 2015
  • In this tutorial I show and explain how to create your own watchdog to stabilize your ESP8266 "Thing". It is applicable for all modules like ESP-01, ESP-07 and ESP12 /ESP-12E.
    And I show different concepts of writing responsive code without using the delay(); statement.
    You will also find a very brief introduction to interrups and timers including the ticker library.
    This is the last video of a series of 5. You find the code on github: github.com/SensorsIot/Interne...
    All programming is done in the Arduino IDE
    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
  • วิทยาศาสตร์และเทคโนโลยี

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

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

    The ribbon on the head of the "watchdog" adds a pinch of humor to a very clear explanation. Thumbs up!

  • @arifranciscogomes
    @arifranciscogomes 8 ปีที่แล้ว +1

    Great service Mr. Andreas Spiess, thanks for sharing knowledge

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

      +Ari Francisco Gomes Thank you for your nice comment, too. Comments like that help to sometimes go an extra mile. And I learn also a lot from other youtubers...

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

    I watch many youtube channels, but your's Andreas is simply the best!. Exceptional knowledge and ideas, very *clear* explanation, simple fantastic.
    As a bavarian guy I also like your accent very much ;-)
    Johann

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

      Thanks for your nice words!

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

    Andreas, I have not the rigth words for describe the excelent job what you did. Thank you again.

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

    Wow, that watchdog stuff is involved.
    Many thanks for sharing this, it's an interesting concept that I had no idea about.

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

    Thanks for the work you've put in, excellent tutorial!

  • @jhana.2023
    @jhana.2023 5 ปีที่แล้ว

    Great. I'm having difficulties with my esp because it's crashing. I'll do as you taught here. And then I'll tell you what the test was like. Thank you very much for the very clear and enlightening video. Ah!! Like !!!

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

      Good luck in finding the problem!

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

    Very clear and straight to the point!!! Well done and thank you.

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

    This old video is great!!! Thanks Andreas!

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

    Great video it helps me to understand crashes better! Great channel!!! Thanks, Andreas!

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

    Yay I finally got my wemos weather station to run without crashing. Thank you very much for sharing!

  • @KM-ey4lg
    @KM-ey4lg 6 ปีที่แล้ว

    Excellent and very helpful video. Thank you.

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

    Sir you are a great man , your guidance solved my hanging problem so far!!!!!!

  • @m.s.3346
    @m.s.3346 3 ปีที่แล้ว

    This video was again very helpful and solved my problem. Thank you very much.

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

    This series is awesome!

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

    one word. Excellent explanation.

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

    why didn't i see your channel earlier. so good :-)

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

    Great content! Thanks Andreas!

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

    Excellent video!

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

    Great explanation, great quality presentation as ever. . I did not know about yield() , i thought delay() was the only way .
    re GPIO , i have see some fine solder work that can gain 4 more GPIO from a ESP v1 .

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

      +XerotoLabs Thanks. Concerning the solder work: This is for sure possible, because it uses the same chip as the bigger ESP modules. But for me, the "OTA" thing is anyway a very good Idea because I do not have to remove the module for an update.

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

    Wow! You are the TH-cam guru of the ESP8266, great videos! Could you tell me if it is possible for the 8266 to take a reading from a sensor once per day, transmit the data over wifi, and then power down (or stay in a low power state) and then repeat this every day. I'm concerned about power usage and time accuracy, I wouldn't want it to get off schedule by more than an hour and preferable run for weeks or months at a time. Thanks! Keep the videos coming.

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

      +Revelation612 Because the ESP is connected to the internet you can read atomic time from a NTP server. Google it and you should get examples. I used NTP server in my videoseries #29-#33 and it works fine. If you do not find better sources you can take the code I used there.
      You can set the ESP for max 8 sec asleep (if I remember correctly). Then it starts again and you can count the number of times it was asleep for 8 seconds. If the time is about ok you can read the NTP time server and decide on how long you still have to wait and go asleep this time. Then you read the sensor.
      This is not simple but possible. Maybe I make once a video about it because you also have to use RTC memory to store the values.
      If you have no power constraints you can read the NTP every few minutes and use millis() in the meantime. There is no need for sleep.

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

    Hi Andreas, Thnks for sharing your knowledge. Where Can i get the sketch of the last practice (external interrupts with a push button on the ESP, i cant do the practice by myself) I have been looking for it in your repository in Gibthub but i couldnt find it! Thanks again

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

      If it is not on Github, I do not have it anymore. This is quite an old video.

  • @craiglarson2346
    @craiglarson2346 4 หลายเดือนก่อน

    I just had a WDT experience I want to share after spending several wasted days. I know this video (excellent as always) is focused on ESP's. However, be aware that the AVR/Arduino ProMini bootloader has a WDT bug that was not fixed in software due to product obsolescence. The solution is to bootload a ProMini as if it was an Uno. But then you must continually remember that the MCU selection is an Uno.
    i hope this saves somebody some time.

    • @AndreasSpiess
      @AndreasSpiess  4 หลายเดือนก่อน

      I did not know this fact. Thanks for mentioning it!

  • @69danielei
    @69danielei 7 ปีที่แล้ว

    Great presentations, I love your videos.
    Did you think about encryption for iot ?

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

      So far, my data is not so important to encrypt them. I decided to wait for the ESP32 for SSL because it is hard with the ESP8266. I hope, this chip will somehow support SSL natively as the MKR1000.

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

    Why TH-cam is missing BIG LIKE, i need it NOW

  • @valeryivanov4732
    @valeryivanov4732 6 ปีที่แล้ว +1

    Hi! So I have a Wemos D1 R2 board with ESP8266 chip connected to PC running some code and once I restart my PC, Wemos hangs and does not run code any more. I suspect it is because of serial connection is opened and that causes board being reset by PC. How could I disable it? Also once I power up my board, it needs reset 2 time to start running code. Dont know whats up with that... Thanks for any help!

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

      Maybe you try with a simple sketch like the blink sketch to make sure it is not the sketch making problems. ESP8266 need a stable power supply. Otherwise it crashes (WDT reset). I made some videos about that.

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

    Thanks for all the videos, they are very informative. I implemented your watchdog and now my OTA updates don't complete. After authenticating it starts uploading, pauses and then asks me to authenticate again. I think the main loop isn't executing but the interrupts is? Should I just increase the number of watchdog counts to ensure it has enough time to update or is there a better method?

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

      You have to do the timing analysis to find out what to do and where the "feed" the dog.

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

    hey thank you so much for your videos.....................

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

    Are these same constraints the same on the 12E version?
    Thanks for all your great videos!
    73…

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

      All ESP8266 boards use the same chip.

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

    Thanks a lot for sharing your knowledge! Nice accent by de way :-)

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

    Dear Andreas spiess,
    Thank you very much for sharing such information on Watchdogs particularly. I applied it with my ESP8266 because it runs the code unstably. Putting the provided code seems to stabilize the program, however, when it crashes it cannot reset/restart the programming. May you please help to solve this problem.

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

      I suggest you solve the real issue before you try a watchdog. ESP8266s should run stable by now. If your error message contains "WDT" you might have to add some yield() statements in the loops.

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

      @@AndreasSpiess Thank you very much, I have not responded you quickly sorry. I was out of city. By the way, how is the PIN connected?

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

    Greetings Andreas!
    Have you had any luck dealing with the issue of a WDT reset bringing the ESP8266 into bootloader mode instead of normal sketch execution?
    I am referring to the ticket you opened github.com/esp8266/Arduino/issues/1017
    Having the same issue here...
    Needless to say this is serious reliability trouble -- defeats the purpose of using the chip in the first place, at least in applications where human presence is not guaranteed at all times.
    PS. This is my first youtube comment, and your channel is the first to subscribe, though I've watched many of your videos before opening my channel -- excellent subject picking and delivery. Just keep at the Swiss accent ;-)

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

      I do not have any particular problem with it since quite a while. But you have to pay attention to the levels of the different GPIOs during boot. Otherwise, it ends in not booting. What kind of issues do you have?

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

      My adaptor-powered ESP8266 (NodeMCU v1) WDT-resets every one to three days and then becomes irresponsive unless I manually reset it.
      To my best understanding the only thing that could be triggering the irresponsiveness is the chip entering UART programming mode after the WDT reset
      I had seen this behavior directly in the logs of the serial port at the time of sketch development -- at that time I had several problems with wdt resets which (I thought, at least that's what it seemed) I resolved with stabilizing capacitors.
      The levels of the 3 pins during boot is a real headache. Since the WDT reset occurs at unpredictable time, the pins of interest can have *any* value (I use them in actual communication with peripherals). Thus, one can never guarantee the correct pin levels that lead to normal sketch execution after the wdt reset.
      In addition, there are other weird, fuzzy things in regards to the GPIO levels at boot, for example
      github.com/esp8266/Arduino/issues/1017#issuecomment-156708759 : though GPIO9 is pulled up, the problem still persists, or
      github.com/esp8266/Arduino/issues/1017#issuecomment-200605576 where it is mentioned that at boot time the bootloader doesn't *actually* sample the pins to determine their state (but instead does something else which I do not understand)

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

      My question would be "why does it reset"? And I try to not use the three pins as input. If you use them as output, you still can put pull-ups there to get a defined status at boot, if necessary. I also do not know it they changed anything in code since then.

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

      I am almost certain the main reason for the resets is the power related. I'll try some bigger capacitors and see the results then.
      However, I am still worried since
      a) capacitors cannot account for all flaws that may appear in the mains power, and thus propagated through the adapter to the VCC of the ESP.
      b)surprisingly, even with the correct pull ups (!!) there still is the chance that a wdt reset leads the chip to firmware download mode, see eg igrr's comment github.com/esp8266/Arduino/issues/1017#issuecomment-156703421
      To my best understanding, a genuine solution to the problem is to find a *reliable* way to put the esp in normal sketch execution each and every time a wdt reset occurs (since *completely* eliminating wdt resets cannot be achieved in real-life conditions as far as I can see).
      After gathering more info, I'll open a thread in esp8266.com and I'll post the link here, an by all means please stop by there then to provide your insight. Thank you for our dialogue! I look forward to our next one ;-)

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

      Greetings! The link to the thread is www.esp8266.com/viewtopic.php?f=6&t=13206 if you have an account there please provide your insight!

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

    Hello,
    I tried it and it works well.
    Is there an equivalent ESP.reset() for Arduino?
    In particular, I would like to be able to reset the Arduino Ethernet shield from software.
    Thanks

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

      I never used it. But googling of "Arduino Watchdog" and "Arduino software reset" give many hits

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

      Yes, you are right.
      But the proposed methods are different and they are based on using the arduino reset pin (through hardware and/or software).

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

    That's a mean looking watchdog :)

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

    HI Andreas,
    I am a having a problem. My ESP8266-01 freezes after running for some time. Then at times it recovers by itself, and most of the times I have to manually reset it.
    Sometimes it freezes in 2 hours and sometimes the whole day it keeps working good. The behavior is not consistent.
    If I implement auto-reset with your ISR then at each reset the GPIOs will also reset and the devices connected will also turn off.
    Need your help on that. Thanks.

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

      Usually, it is best to run the serial monitor to log where the processor stops. Then, you get information on what happens. Pay also attention to a proper power supply. You find some videos in my playlist about that

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

    thank you so much

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

    I’m using a NodeMCU with an Apple HomeKit Arduino sketch but every couple days it stops working. Will try your watchdog example and see how it improves, thanks for sharing your knowledge!

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

      I would also try to investigate why it stops...

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

    Holly sh*t! My poor heart have stumble when he saw that blue screen!!

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

    I want to use this. I have 4 espo1s and they all eventually hang, I have tried the capacitor, stable power, etc. Is there a way to do this without using a delay. Like using millis?

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

      If you get the error wdt reset, you need some yield() statements in your loops.

  • @E3CB
    @E3CB 2 หลายเดือนก่อน

    Thanks! My esp8266 crashed after 6 days of great monitoring. It this happens again, I'll add this watchdog! (y)

    • @AndreasSpiess
      @AndreasSpiess  2 หลายเดือนก่อน

      Maybe you first check the power supply and the error handling of WiFi. It should not crash.

  • @ljl451
    @ljl451 6 ปีที่แล้ว +1

    Hello,
    do you know a way to make it work for ESP32?
    Ticker.h does not seem to be available in the ESP32 libraries.

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

      I never looked in the timers of the ESP32. But I found this links: github.com/Pedroalbuquerque/Ticker-ESP32 or github.com/sglvladi/Ticker_ESP32

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

      Thanks!
      I tried the library in the first link and the code compiles fine.
      I only had to change ESP.reset() in ESP.restart()

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

      But it does not seem to work.
      Even if in the loop I only put
      watchdogCount = 0;
      ISRwatchdog() is executed continuously

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

      Maybe you open an issue at Github. Usually, you should get help from the creator of the library.

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

      If you still haven't found the answer, maybe you can find it in the following link: th-cam.com/video/7kLy2iwIvy8/w-d-xo.html
      It was pretty helpful for me.

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

    Hello bro
    First of all thank you for giving us such a beautiful and informative video.
    I had some questions about ESP8266 NodeMCU v3. If I want to make a repeater with it. So my question is
    1 / What will be the maximum range of NodeMCU repeater?
    2 / What is the maximum data speed of NodeMCU WiFi?
    3 / NodeMCU repeater maximum number of people can use together?

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

      I cannot answer your questions. But all will be lower than a standard cheap repeater from Aliexpress.

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

    Hi Andreas Spiess,
    I use NODEMCU watchdog timer code like your video , i got stuck with this
    ets Jan 8 2013,rst cause:4, boot mode:(1,6)
    wdt reset
    how can i solve that problem ?
    Thanks

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

      Usually you have a loop which blocks the ESP too long. You can try to insert yield() statements in all loops.

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

    Could it be that "ESP.reset" has changed in the meantime and now is "ESP.restart"? I always get errors with ESP.reset. Or is it because I use an ESP32 not an ESP8266? Thanks for your answers in advance!

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

      You are right. They changed it.

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

    Many thanks

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

    Hi Andreas i am using an esp32 to control my automatic curtain . The curtain takes 13 seconds to close so the internal watchdog timer bit. I had to insert esp_task_wdt_reset(); into the subroutine that runs the stepper motor to keep the esp from restarting. So it has an internal WDT.
    BUT today the esp became unresponsive and did not reset itself i could not get any reaction from it so had to pull the power. once restarted it worked fine. I could later see from a temp and barometric sensor i have attached exactly when it crashed. it was out for several hours. i guess my only way to counteract this automatically is to make an external WDT as the internal one seems to have failed. I will make a node red routine that checks for missing updates from the temp /barometric sensor so i know when it happens again. do you have any other insights or suggestions ? Thank you for your videos they are always helpful.

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

      I also have a node-red flow for my most important sensors. The send me a telegram message when the expected update does not happen. If it is too often, then you hae to find hte root cause. Not easy.

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

      @@AndreasSpiess thanks for your reply. Yes I'll have to keep an eye on it. BTW did you try NORA? Super easy way to connect everything to Google home

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

      No, so far I never tried it

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

    I'm adding this to my esp basestation, hope it will help with my random unresponsiveness (sometimes after 3 days, sometimes after 14 days)

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

      Also good power supply helps (big capacitors). I have some videos about that

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

    Dear sir,
    I have a problem with TMS320F28377D. The reset pin is toggling after sometime. I think it was due to watch dog timer, but I don't know how to disable it. Can you help me sir pls

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

      I do not know this chip, so I cannot help

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

    What a great video !!!! I was just looking for this because my smart lighting setup at home use to be non responsive after a day or so but after the watchdog code the ESP32 would reset automatically and return back to an operational mode. I am working to see why the problem is caused in the first place

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

      IYou are right, it is always good practice to find the root cause first!

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

    Sir, I'm making code for AC light dimming process. N I've included yield(). But it isn't helping. I'm continuously getting the problem of rat cause:2, boot mode:(3,6)

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

      Search for this message with google and you will find the cause

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

    Andreas, is it okay to do this :
    void setup()
    ...
    ESP.wdtDisable();
    ESP.wdtEnable(WDTO_8S);
    and in the loop...
    void loop()
    ESP.wdtFeed();
    yield();
    Thank You.l
    Marc.

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

    Thx verymuch

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

    I have been using an ESP_01 with an Arduino Mega to get data from an aquaculture plant.
    The data collected are pH,Temperature and Dissolved oxygen. The oxygen level is controlled using a servo motor and all the data are viewed and controlled using Blynk application. Lately i have been having issues with the ESP_01 module i think it freezes because i have to transfer too much data.And the resetting is to be done manually can you suggest me a solution for this?

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

      I want to know something regarding this watchdog concept I'm using an Arduino mega+ ESP8266 (ESP01) to monitor and control an aqua culture system. The system transfers the data to the BLYNK cloud which is viewed and controlled over the mobile. The system freezes because the esp01 fails to connect to the wifi network from time to time which requires manual resetting. Will it be ok if i upload this code to my arduino mega in order to solve this problem.... And please be kind enough to add a link to where i can get the ticker.h library.
      Thanks for uploading this nice video.
      Great job!!!

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

      Unfortunately I cannot do remote debugging. Ticker.h should be part of normal ESP8266 Arduino isntallation. So no additional installation is needed (I did not try now)

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

    Excuse me , i got a different problem which is resetting because of
    Exception 9,
    So what can i do with this exception ,
    Thanks in advance
    Thanks for the video

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

      Unfortunately I cannot help with remote debugging.

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

    Sir....i like your video a lot ..but i need your help how can we use timer in ESP8266

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

    My esp8266 iot control stops responding from time to time. I think it is when the router is reset. How do I set it to reset when the wifi is missing?

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

      Unfortunately, I cannot do remote debugging.

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

    Great tutorial. Amazingly good. Explanations are very clear. I learned a lot from you. Thank you for taking the time to put it together. I only have one question, so far: Where may I find the library ? - I have made a lot of searches and looks like none of those I have found are suitable for this application. - Can you help ?

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

      +hugo salom You are very welcome! Thank you.. The credentials is not a library. It is a trick for me that I do not publish my credentials by accident. So, just remove the include credentials.h and fill in your credentials in SSID and password.

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

      +Andreas Spiess - I just did what you said. I have also been reading the comments and questions at Github and the videos in this tutorial trying to find answers to my questions before I ask you the next question. Unfortunately I have not found the answers and, even though I would rather not to bother you, I need to ask you the following question: What am I doing wrong? - I am using a ESP8266 12E by AI-Thinker (eBay item 262123867975) and compiling it using Arduino IDE 1.6.5 defining the board as a a NodeMCU 1.0 (ESP-12E Module)" with CPU frequency of 80 MHz and Upload Speed of 115200. Now, with that being said, and having the #define ESP_12 without slashes on helpers.h library, I get the following errors when compiling:
      **************************************************************
      Arduino: 1.6.5 (Windows 7), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, 115200"
      BVB_WebConfig_OTA_V7:50: error: 'defDirection' does not name a type
      BVB_WebConfig_OTA_V7:54: error: variable or field 'storeDirToEEPROM' declared void
      BVB_WebConfig_OTA_V7:54: error: 'defDirection' was not declared in this scope
      BVB_WebConfig_OTA_V7.ino: In function 'void customLoop()':
      BVB_WebConfig_OTA_V7:239: error: 'storeDirToEEPROM' was not declared in this scope
      BVB_WebConfig_OTA_V7:245: error: 'readButton' was not declared in this scope
      'defDirection' does not name a type
      This report would have more information with
      "Show verbose output during compilation"
      enabled in File > Preferences.
      *************************************************************
      Any comments and or suggestions ?
      Thanks in advance.

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

      +hugo salom No problem because of the question. 10 minutes ago downloaded my files from github, did the same settings as you and had no problems with compiling. If you look at your error messages something is interesting: The line numbers of the errors do not at all correspond with the line numbers in the coding. This is strange! I use the ESP version 2.1.0-rc1 board definition in the board manager. Maybe you check. Otherwise I have no idea why this is happening. Try to find out, why the line numbers are so different.
      I use the NodeMCU boards only for boards with serial adapters on the same board (see my video about boards), not for plain ESP modules. For modules I use "generic ESP module" as board. There are a few differences between them:
      1. The signaling for the programmer
      2. The names of the pins.
      So, the ESP_12 define has to be set according to the board you chose for compilation, not the module you use.
      Concerning debugging: I assume, that your setup works fine with other sketches. Otherwise start with the blink sketch to make sure, your "toolchain" works.
      Just a tip: You can save time if you go to 921600 upload speed. It should work with most of the modules and is nearly 10x faster...

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

      +Andreas Spiess Just to let you know I went the route you suggested. Apparently I damaged the contents of the main ino file while manipulating it, so I erased the whole thing and downloaded again. Added the SSID and the respective password, removed the slashes from the #define ESP_12 and proceeded to compile. ...And guess what happened: It did compile with no errors. Thanks for your assistance. Next step shall be to upload it on the ESP module and test it. I will let you know. Thanks.

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

      Glad to hear that!

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

    Danke für den Yield Tipp, genau den Fehler hatte mich blockiert. Für parallele Ausführungen wäre vielleicht das FreeRTOS etwas für Dich, es läuft auch auf dem Arduino UNO mit der Arduino IDE.

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

      +norm1124 Danke. Ich werde mir dieses FreeRTOS mal ansehen, wenn ich Zeit habe. Scheint ein interessantes Konzept zu sein. Was aber für mich sicher entscheidend sein wird sind die Libraries. Da habe ich keine Ahnung, wie man die einbindet oder ob das schon jemand gemacht hat. Kommt im nächsten Jahr.
      Jetzt muss ich den 2-rädrigen "Roboter" vorstellen. Hatte ich versprochen und schon Nachfragen gehabt. Das gibt auch wieder etwa 3 Episoden: Self Balancing, bi-directional communication mit NRF24l01 und Ultrasonic Subsystem mit drei Sensoren und einem attiny... Und dann wollte ich noch ein Weihnachts-Special machen.

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

      +Andreas Spiess Cool. Ich habe das Fenster mit WS2811/Neopixel (gebogen als Zahlen) verziehrt. Und mit dem ESP8266 will ich einen Internetradio für $10 umsetzen (dumme "Wette" mit einem Arbeitskollegen): github.com/espressif/ESP8266_MP3_DECODER. - Viel Spass mit dem Roboter (Bin gespannt auf die IMU-Tricks - mit Kalmann Filter ?) und auch auf alles andere.

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

      +norm1124 Das mit dem Fenster müsstest Du mir als Foto zeigen, damit ich es mir vorstellen kann...
      Betreffend Kalmann Filter: Ich habe keinen verwendet und er steht trotzdem. Allerdings musste ich eine Zweiweg-Kommunilation zwischen Fernsteuerung und Roboter aufbauen, um die Parameter Real-Time ändern zu können. Die sind sehr heikel.
      Das mit dem Radio ist sicher möglich. Der Chip ist ja schnell und hat WLAN. Und ich vermute, die hatten noch keinen 4MB Flash chip. Ich denke, da müsstest du auch genug buffern können. Wenn Du kein Board mit 4MB hast kann ich dir eins schicken (oder auch nur einen Chip). Den kann man ja bekanntlich wechseln.

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

    Hi I tried implement your code into my existing code but it always ends with message watchdog bites .... Could you please help?

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

      Unfortunately, I cannot do remote debugging.

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

      @@AndreasSpiess I am fully aware you cannot do remote one. I am using ESP32 and unchanged code from here: randomnerdtutorials.com/esp32-esp8266-rgb-led-strip-web-server/ I tried to add you code to each sections but always end with serial message of biting dog. Would be great help if you can spare minute to help. Many thanks!

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

    Where do I get the Ticker.h library.

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

    Very useful. Now my 433mhz controller can be called reliable

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

    It is a good way if the problem is in software but often my nodemcu got frozen! I dont know why. It is running a sketch of wi-fi station and works simulating a belkin device! I have been testing for 2 days and 3 times it crushed. It is indicated by the Digital Output D0 that turn on a led when it goes into a configuration mode! When i push the reset button doesnt work and it keeps in configuration mode! Only when I cut the power supply and then feed it again, it works.. maybe someone have an idea of why happen it? And how can I implement a watch dog throught hardware?

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

      Did you watch the Serial monitor when it crashed? What did it say?

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

      Andreas Spiess no I didnt! I Will run it and keep an eye in serial monitor when it crash, thanks for your videos and all the answers! Keep going on..

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

    dear sir
    i am getting the following error and it resets my device
    ets Jan 8 2013,rst cause:2, boot mode:(3,6)
    load 0x4010f000, len 1384, room 16
    tail 8
    chksum 0x2d
    csum 0x2d
    v60000318
    ~ld
    my program was working fine for 15 days and now i am getting this error
    pls help

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

      Remote diagnostics for these problems is not possible. Maybe the ESP did not get enough voltage for a moment. I suggest adding a big capacitor across your ESP8266 module ( I showed this in another video about powering the ESP8266)

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

    Hello sir, thanks for sharing info about watchdogs, I appreciate that a lot, also I am working on my college project based on esp 8266
    But it automatically resets after every 40-50sec while receiving data from firebase. I would be very thankful if you share your email id for further discussion
    Warm regards

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

      Unfortunately, I cannot do remote debugging. Maybe you add lots of Serial.print statements to find out where it crashes. And add a big capacitor across Vcc and GND as shown in other videos.

  • @danielcavalcante8103
    @danielcavalcante8103 8 ปีที่แล้ว +1

    I and my friends are making a college projet using ESP-07 but we are facing a problem: from time to time (It's not periodical) our ESP stop working , the code does not run anymore and we can't acess the html page. We tried to use the library ticker to make a watchdog timer and we also used the functions ESP.wdtEnable() e ESP.wdtFeed() but nothing of this worked. We are using the usb-ftdi conversor to power the ESP (Maybe the current isn't suficient). The reset only works from hardware .We're trying to use the ESP as an acess point. I would greatly appreciate any help!Thank you Andreas Spiess all your videos are great!
    code: migre.me/trvye

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

      +daniel cavalcante I would try to separate things. First, you have to get your module stable. This can be done with the blink sketch. Do not forget a yield(); command in the loop.
      If teh module crashes inside the blink, the stability of the power supply could be an issue and I would go for a better power supply.
      As soon as the blink sketch runs stable over time you can go on with your web application. Also here, make sure, that a yield() is called every millisecond or so, also in while waiting loops.
      I have no ESP on hand to try your sketch, but I think, you should nor over engineer the problem with watchdogs. Like that, at the end, you just have more sources for problems.
      If everthing runs stable you can go on with the watchdog. The watchdog is only for stable systems.

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

      +Andreas Spiess Thank you for you answer! I tried to do what you said. The blink sketch worked well, but when I tried to run an webserver using the ESP like an access point, it occurred the same problem as before: It worked but sometimes it stopped running and even the Ticker wasn't able to reset it.

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

      +daniel cavalcante can you give me the code? Then I could try it over the weekend.

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

      +Andreas Spiess
      It seems that when I use the Ticker I'm not able to run a server.
      Here is link to the code: goo.gl/GvvBZc
      Thank you for you help!

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

      +Andreas Spiess I didn't understand the usage of the yield() function! I searched for this function on the Arduino site and I found this :
      yield()
      Description
      Passes control to other tasks when called. Ideally yield() should be used in functions that will take awhile to complete.
      For which task is the control given?

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

    Sir @andreas spiess whenever i try to restart the esp using software with commands ESP.reset() or ESP.restart(); most of the time esp got stucked in restarting and don't run any code till i hard reset using button . this is the last thing in the serial all the time
    " ets Jan 8 2013,rst cause:2, boot mode:(1,6)
    ets Jan 8 2013,rst cause:4, boot mode:(1,6)
    wdt reset
    "
    Is there anyway to get rid from it. Help from anyone is appreciated
    @Andreas spiess
    is you any way to fix it ?
    github.com/esp8266/Arduino/issues/1017

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

      wdt resets usually are caused by blocking the processor. You can add delay or yield statements in your code where it crashes.

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

      @@AndreasSpiess sir processor don't run the code after rebooting for the first time using commands after uploading new code. same problem as you discussed is you find anyway to handle it.

  • @TS-00
    @TS-00 4 ปีที่แล้ว

    feed or leave our watchdog unstable? Sounds like training a pig 🐖 to kill on command by withholding 💰 er I mean food.

  • @drjml351
    @drjml351 ปีที่แล้ว

    Great tutorial as usual. I can't compile, I get this error message:
    /Users/joelleon/Downloads/Ticker-main-2/examples/Ticker/Ticker.ino:12:33: error: no matching function for call to 'Ticker::Ticker(void (&)(), int, int)'
    Ticker timer1(printMessage, 0, 1);
    ^
    Compilation error: no matching function for call to 'Ticker::Ticker(void (&)(), int, int)'

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

      This is an old video. Maybe something in the ticker library changed.