setWatch on ESP8266 is not stable ?! #6049
Replies: 1 comment
-
Posted at 2018-09-20 by @allObjects @maman, I'm not surprised... because a 8266 is just one processor and a very significant part of its processing capacity is Wifi stack ASSIGNED... and if it does not get it... it flunks. 8266 timing has hard stops: every x ms the Wifi stack expects the full processor being available to just do Wifi work. If processor is tied up with something else... Wifi / all 8266 crashes. What though seems fishy to me is the sequence you get without even doing something... so I can think of bad connections, iffy power supply, etc. (assuming setWatchI() actually works on 8266). Even though 8266 is very popular and many things can be done with it, it is not though to do other things than serve Wifi through AT commands. Period. Get a Pico and combine it with your 8266 - or better: get a Espruino-Wifi, and you are best off, because the embedded dedicated (slave) 8266 does Wifi very well and you free what ever to do on the JS side. Posted at 2018-09-20 by hungryforcodes So I just flashed a LoLin ESP8266 board, with 1v99, and tried to replicate your problem. SetWatch performed as expected when connected to Vin or GND. It detected the state change when I touched the pins. I used your code example. I have worked with setWatch alot on the ESP8266, and its pretty stable. As an example, after I tried to replicate your problem, I wired up a rotary encoder and used the "encoder" module to test. It uses setWatch under the hood. Here is my code (just a copy paste from the "encoder" module page).
As you can see I got a couple of errors (probably my pin choices), and a warning about FIFO_FULL, but this didn't affect performance in anyway. I was spinning the encoder as fast as I can. So thats about 22 events in 2-3 seconds, which is not bad. I literally span the encoder as fast as I could and everything was fine. The FIFO_FULL warning only came after a restart of the module. It could perform for hundreds of turns after without problems.
So this suggests to me Espruino is fine. And that as @allObjects suggested your problem is electrical. Please note, that not all ESP8266 boards are the same or of the same quality. For example both the ESP-201s, and the AT-WITTYs were notoriously difficult to deal with from flash memory corruption to extremely flakey power. Other boards (WeMos D1 Mini comes to mind), operate pretty flawlessly. Anyways check your setup again I'd suggest. Posted at 2018-09-20 by @allObjects @hungryforcodes, thank you for validation. Sad to hear about thinks like Posted at 2018-09-20 by hungryforcodes @allObjects Well I was doing the work in production quantity, so we're talking about 100s of boards from different sources, which I did deliberately. One of the reasons was to exactly test reliability of different mantufacturers and find out which ones could be used effectively for productization. I thought the data I gathered was extremely valuable, at the time. But yes time is important! :P Posted at 2018-09-20 by @allObjects @hungryforcodes, ...was only talking from prospect of having fun with Espruino... doing business is a totally different ball game: no brain time can fix money set in sand. Like running code on not pre-validated data and then being scratching the head about surprising results. With great numbers of IoT devices in the field all over the place and failing (intermittently) there, fixing an issue is not just producing a few more to drop the non-passing with them in the factory. What burn-in tests of the final product do you have? ...and how long are they running? Does the burn-in test run additional code - on top of the intended application code - to do stress test beyond the regular stress limits? What is the test result gathering / presentation and degree of automation of the test(s)? Posted at 2018-09-20 by maman @hungryforcodes, @allObjects, thanks for the reply. I use ESP-07 from Ai. Now, I am developing lamp controller that can be remotely controlled by MQTT protocol. However, I want to use the previously mechanical switch to control the lamp, locally, in case the network failed. I connected directly the mechanical switch to pin D5 of esp8266 tied-up with 10K resistor to VCC. It seems that the problem is the mechanical switch. I have tested the code below :
And the result is there are many callback function was called, and the ESp8266 was crashed. then I put a small capacitor on the switch terminal, and add debounce at 100, then it is run well. Posted at 2018-09-20 by hungryforcodes @maman Thats great! I'm happy you got the problem resolved. It can be very annoying to have mysterious, unexpected issues like this. @allObjects Yes, it was part of a wireless lighting product I was developing. In the end I couldn't get the costs down enough and abandoned it. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2018-09-20 by maman
I use D5 and D4 of ESP8266 to detect pin status using setWatch.
setWatch(function updateDIN1() {
// ...
}, D5, {repeat:true, edge:'both', debounce:100});
If I connect D5 to normally GND, then the ESP8266 will detect many interrupt, and
ESP8266 can not continue to run the other script program.
However, If I connect D5 to VCC via pull-up resistor, then when I change the D5 to GND, then
I will get many interrupt, and ESP8266 to busy accepting interrupt from the setWatch..
Is there anyone have this kind of problem ?
Regards,
Maman
Beta Was this translation helpful? Give feedback.
All reactions