UlrichMai / MaiPureSpaController

IoT Controller for Intxx PxxxSPA
MIT License
13 stars 12 forks source link

Stability improvements #3

Open bikemike opened 3 years ago

bikemike commented 3 years ago

Hey, I've got a newer/different model of this SPA (SB-H10) and your method of control seemed the easiest. Unfortunately the new display can't be taken apart without destroying it (from what I can tell) so I have to put my module in the base unit. I have been copying the core of your code and trying to get it working. I'm not sure if you're still using this or have switched to diyscip but I have found a couple things that will probably fix the stability issues with this code.

The first is ICACHE_RAM_ATTR. You must put this on any function that is called directly or indirectly from an interrupt. Without this, the firmware will crash quite frequently.

Another issue is the size of your btnRequest and btnCount arrays. They are too small by one so probably cause some sort of unwanted issue.

impact27 commented 3 years ago

For reference about ICACHE_RAM_ATTR: https://github.com/esp8266/Arduino/blob/master/doc/faq/a02-my-esp-crashes.rst

Interrupt Service Routines

By default, all functions are compiled into flash, which means that the cache may kick in for that code. However, the cache currently can't be used during hardware interrupts. That means that, if you use a hardware ISR, such as attachInterrupt(gpio, myISR, CHANGE) for a GPIO change, the ISR must have the ICACHE_RAM_ATTR attribute declared. Not only that, but the entire function tree called from the ISR must also have the ICACHE_RAM_ATTR declared. Be aware that every function that has this attribute reduces available memory. In addition, it is not possible to execute delay() or yield() from an ISR, or do blocking operations, or operations that disable the interrupts, e.g.: read a DHT. Finally, an ISR has very high restrictions on timing for the executed code, meaning that executed code should not take longer than a very few microseconds. It is considered best practice to set a flag within the ISR, and then from within the loop() check and clear that flag, and execute code.

SchneHa commented 3 years ago

It is not very stable, meaning it reboots several times a day. I have not figured out why. Please let me know if you found something that makes it more stable for you.

=> Try to feed the Watchdog Timer: Insert the following lines: After "void loop() {":

  ESP.wdtFeed();
  ESP.wdtEnable(0);

Maybe WDT must also be disabled in void setup() As last line: ESP.wdtDisable();

Try it out.

SchneHa commented 3 years ago

Hey, I've got a newer/different model of this SPA (SB-H10) and your method of control seemed the easiest. Unfortunately the new display can't be taken apart without destroying it (from what I can tell) so I have to put my module in the base unit.

I have the same model, can you send a few pictures and describe how you opened it and connected the D1 mini? How did you connect the buzzer?

bikemike commented 3 years ago

I have the same model, can you send a few pictures and describe how you opened it and connected the D1 mini? How did you connect the buzzer?

I will put some instructions and pictures up in the next couple of days. I could not open the display so I opened the base unit and soldered wires to the pins at J5.

My project code is here:

https://github.com/bikemike/IntexSpaManager