Led widget with esp8266, reseting board

@vshymanskyy please add comment to sketch.

@vshymanskyy could you please expand a little on what we should be doing with attachInterrupt whilst trying to use WiFi at the same time. It is currently working for us but it took for ages to set up a ‘simple’ momentary switch to turn a buzzer on and off.

Should we be detaching the interrupt whilst we access WiFi or disabling WiFi when we require the interrupts (or both)?

Hi
I am coming back after quite a few hours of trial and error.

After changing the sketch to download it to a Arduino Mega using a cc3000 wifi board, it works perfectly except if you are using V1 and V2 as virtual port.

Using V1 and V2 did not through the module in a RST mode as with the ESP module but you cannot access the led widget attached to V1 and V2. If I use V0 or V3+ everything work and the led will go on and off.

I hesitated to come back with this information but I hope it can help.

@Costas esp in Arduino IDE is based around FreeRTOS where void loop() is user task, it has priority of 1 which means it’s almost the highest but most likely connectivity is handled by priority 0. Anyway because of the fact that you raise hardware interrupt which is even more important you might interrupt handling WiFi communication: that’s all, therefore you should raise flag as @vshymanskyy mentioned and only later handle event that is connected with raising flag. Optionally you can read about handling hardware interrupts in FreeRTOS

1 Like

Hi
After reading your post I went back experimenting with the ESP and I think you are right. The ESP and Blynk work’s at it should if I don’t introduce an attachInterrup().

I was using the interrupt after checking in GitHub esp8266/Arduino where we see the following: in the difital IO pin description:

“Pin interrupts are supported through attachInterrupt, detachInterrupt functions. Interrupts may be attached to any GPIO pin, except GPIO16. Standard Arduino interrupt types are supported: CHANGE, RISING, FALLING.”

Would it be possible to use the equivalent material interrupt on ESP board without polling continuously for value.

@mauricep we are using RISING and FALLING but the same issues will apply regarding the use of interrupts and WiFi at the same time.

Please post your callback that’s called when interrupt occurs.

I did not use a callback function in the setup(). See the code at the top of this thread.

I did have time today to connect to another MTTQ server using equivalent code in my sketch at the top of this topic and the same esp8266.

The interrupt() is working as it should, never RST the board.

I am now convince that the problem is not using esp8266 while in an interrupt context but in Blynk itself. It is a major problem if we cann’t program interrupt() while using Blynk.

I will still use Blynk but I fell limited by it.

I hope Blynk will read this post and comment about this situation.