"micro:bit" Web Thing unusable after some time (Gateway adaptor issue?)

Issue #192 resolved
connochaetes created an issue

Hi.

I am using a Raspberry Pi 3B with gateway-1.0.0.img from webthings.io. I connected some Meross “Smart WiFi Plugs (Mini)”. In addition I connected a “micro:bit (V1)” via USB in order to switch the plugs on and off. Here 's my MicroBlocks script:

I implemented two simple if … then … rules via the webthings.io web interface (one to switch the plugs on by pressing button A, one to switch the plugs off by pressing button B).

This is working just fine for a few minutes. After a while - I didn’t time it yet - it 's failing:

  • I am no longer able to switch the plugs on and off via the micro:bit.
  • Plugging the micro:bit’s USB connection off and on again shows no effect.
  • The Raspberry Pi is still working fine. The WiFi plugs are still switchable via thewebthings.io web interface - both via intranet and internet. So, I am assuming that this is a MicroBlocks issue and no webthings.io issue.

Any ideas on this are appreciated. Please, feel free to ask for further details.


P. S.: I’m doing some further research at this moment: Are the micro:bit’s LEDs still working while the rest is failing? Does using a newer MicroBlocks version shows any effect? … In order to get results on this, I am waiting right now for the micro:bit to fail again.

Comments (9)

  1. connochaetes reporter

    Here 's an update on this one: After waiting a while…

    • Both used LEDs of the micro:bit are still functional.
    • (Here ‘s an interesting fact.) Switching the WiFi plugs on is working, switching the WiFi plugs off isn’t. (…?)

    I am using MicroBlocks v1.0.8 (Firmware v105).

  2. connochaetes reporter

    As a workaround, I am using two micro:bit boards; both are using only button A. That ‘s not nice. I’m still hoping to find an explanation / a solution.

  3. John Maloney repo owner

    This sounds like a bug in the MicroBlocks Gateway adaptor. @Bernat Romagosa , could you take a look when you get a chance?

  4. John Maloney repo owner

    Sorry for the long delay in following up...

    Did you every solve this problem? I had suspected the MicroBlocks add-on when this was first reported so I didn't look further. However, I've been using that add-on with the Gateway-1.0.0 image to run my heating system for the past year and haven't run into any problems with it.

    Looking at your code, it appears that the "buttonAPressed" and "buttonBPressed" variables stay true for only 50 milliseconds after the button is pressed. Since the Gateway uses polling to get state updates, it could easily miss catching the state change for the brief moment the button is down. It would be better to arrange things so that pressing a button toggles the associated switch state and that state is retained until the next button press. Then, even if the Gateway polls only once every few seconds, it will eventually notice the new state and relay it to your Smart Plug.

    I'm going to mark this as resolved but feel free to add additional comments.

  5. Log in to comment