Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

Speed and Stability updates #109

Closed
wants to merge 6 commits into from
Closed

Speed and Stability updates #109

wants to merge 6 commits into from

Conversation

debsahu
Copy link
Collaborator

@debsahu debsahu commented Mar 20, 2018

If LEDs>100, stalls ESP8266. So bunch of code cleanup and merge with
existing variables used by other sections. Should be more efficient. As
of now on Arduino ESP 2.4.1, WiFi.setSleepMode(WIFI_NONE_SLEEP); is
required for MQTT function. ESP8266 is anyways connected to constant
power supply, so power consumtion is not immidiate concern now.

  • HTTP OTA
  • Arduino OTA
  • Async MQTT
  • PubSubClient
  • HomeAssistant

If LEDs>100, stalls ESP8266. So bunch of code cleanup and merge with
existing variables used by other sections. Should be more efficient. As
of now on Arduino ESP 2.4.1, WiFi.setSleepMode(WIFI_NONE_SLEEP); is
required for MQTT function. ESP8266 is anyways connected to constant
power supply, so power consumtion is not immidiate concern now.
* HTTP OTA
* Arduino OTA
* Async MQTT
* PubSubClient
* HomeAssistant
@toblum
Copy link
Owner

toblum commented Mar 21, 2018

Thanks again for your contribution. I will have a look at it soon and merge it into master. Just a bit busy at work at the moment.

@debsahu
Copy link
Collaborator Author

debsahu commented Mar 21, 2018

Take your time, no hurry. I did some major cleanup, could you test by running for a longer time (over 2 hrs)? For some reason all my ESP8266 drop WiFi connection, I am using a ASUS router RT-AC68U. Maybe move these over to a backup dlink router to figure out WiFi stability. WiFiManager (dev version) is quite unstable after 2.4.1 as well: esp8266/Arduino#4372 and same is true for PubSubClient.

@debsahu debsahu requested a review from toblum March 22, 2018 20:49
Modified
* Better implementation of tickers (recommended)
Added
* Save State on SPIFFS (alternative to EEPROM) EEPROM has finite write
cycles.
* Added Custom MQTT QOS levels, as AMQTT can handle QOS level 0,1&2 in
both publish and subscribe. Pubsub can only sunscribe in QOS 1&2,
publish at QOS 1 only.
@toblum
Copy link
Owner

toblum commented Mar 23, 2018

Hi @debsahu,

I really like your changes, especially to save the state as JSON. This is something I tried a your ago, but it wouldn't work back then. If it works reliably, we could kick the EEPROM code completely.

I was able to compile the code with only some little issues (had to update to ESP core 2.4.1 and a old version of the ESPTCP client made problems). I flashed it now to my testing lamp (24 LEDs) and it works like a charm.

I will keep it running for some time, to test stability, but it looks good. Unfortunately I don't own really big strips.

But before merging this to master I think I have to update the documentation, because setup is slightly more complex.

Thank you again for this great contribution!

Regards
Tobias

@debsahu
Copy link
Collaborator Author

debsahu commented Mar 23, 2018

Just set the num_leds to 300 for testing, you dont have to drive 300 leds! Adafruit library uses a lot of memory for 300 leds, just wanted to make sure I am not the only one with the issues. When the leds are set to any value below 30 I have no issues.

@toblum
Copy link
Owner

toblum commented Mar 23, 2018

Yes, I already did that on a second ESP that has 60 LEDs connected effectively (but 300 set in the definitions.h). Works for some time now without problems.

@toblum
Copy link
Owner

toblum commented Mar 23, 2018

One issue I noticed:
State is saved correctly as JSON after a timeout. Checked via: http://192.168.0.49/stripstate.json
When I reset the ESP I see in serial output:
"Read cfg: {"mode":1,"strip_mode":48,"brightness":200,"red":255,"green":76,"blue":0} Success!"
Which is also correct, but the ESP shows complete red and not what's saved.

Could you reproduce this?

@debsahu
Copy link
Collaborator Author

debsahu commented Mar 23, 2018

You are right, I don't set them. I just read them, I thought mode will set them correctly. Also for some reason I totally forgot about "speed". I'll update in a few hours.

* Added speed to SPIFFS save
* Should set strip state after succesful read.
@debsahu
Copy link
Collaborator Author

debsahu commented Mar 24, 2018

Update should set state correctly

@debsahu
Copy link
Collaborator Author

debsahu commented Mar 24, 2018

@toblum If you are on Arduino ESP8266 2.4.1, patch WiFiClient.cpp as per esp8266/Arduino#4516 PubSubClient will eventually lead to memory leak after long periods of time. Async MQTT is immune to this for now!

@debsahu
Copy link
Collaborator Author

debsahu commented Mar 24, 2018

Updates should handle #110 as well

@The-Holgi
Copy link

Hello,
i‘have a ledstrip with 226 led‘s.
It works with the webinterface, but with mqtt over fhem it works for a few time (1 to 3 hour) and than the connection lost. Over webinterface it still works.
Regards
Holger

@debsahu
Copy link
Collaborator Author

debsahu commented Mar 26, 2018

Could you try my branch and report back? https://github.com/debsahu/McLighting

There is lot going on during a mqtt callback. Now it's simplified and no strip calls are done

@The-Holgi
Copy link

Hi debsahu,
Thanks for your work.
ESP is flashed with your branch. The Test runs well since 20 minutes.
I´l report tomorrow.
Regards Holger

@debsahu
Copy link
Collaborator Author

debsahu commented Mar 26, 2018

Also, if you are on Arduino ESP8266 2.4.1, patch WiFiClient.cpp as per my link above for proper functioning of pubsubclient. Or else there will be memory leaks.

@The-Holgi
Copy link

Hm, i´m using the 2.4.1.
How can i install the patch?

* SetBrightness fix from REST API callback from Master
* Added twinkleRandom to REST API (missing?)
* MQTT callback
Copy link
Owner

@toblum toblum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@debsahu I had it running with AMQTT for some hours now. It works flawlessly here so far. Great!
I used the Version from your repo.
I will extend the documentation soon and then we could merge it to master.
What do you think?

@debsahu
Copy link
Collaborator Author

debsahu commented Mar 27, 2018

@toblum Go ahead, I have it running on my test system with 300 and 16 leds. Running fine so far.

@debsahu
Copy link
Collaborator Author

debsahu commented Mar 27, 2018

@The-Holgi this is off topic, but edit libraries/ESP8266WiFi/src/WiFiClient.cpp (In windows it is in C:\Users\<USERNAME>\AppData\local\Arduino15\packages\esp8266\hardware\esp8266)

replace line 115 ( if (_client) ) with

 if (_client) { 
         stop(); 
        _client->unref(); 
        _client = nullptr; 
    }

Or use latest git version.

@The-Holgi
Copy link

Hi,
thank you for the tip.
You‘r version (https://github.com/debsahu/McLighting) runs for more than 24 hours without any problems on my wemos d1 mini with 226 led.
Regards Holger

* Added support for NeoAnimationFX (USE_NEOANIMATIONFX)
* Better scaling for speed
@debsahu debsahu closed this Apr 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants