These are chat archives for esp8266/Arduino

8th
Jun 2018
Bert Melis
@bertmelis
Jun 08 2018 19:23
is there a way to get the total heap size? or is it always the same (80kB - 4k stack)?
Earle F. Philhower, III
@earlephilhower
Jun 08 2018 19:24
ESP.getFreeHeap() gives the available space. Expect about 40KB on an empty sketch to start.
Bert Melis
@bertmelis
Jun 08 2018 19:25
I know, but in terms of % used, do I just divide freeHeap by 40K?
Earle F. Philhower, III
@earlephilhower
Jun 08 2018 19:26
How accurate you want? Could assume 40kb, or just keep a copy of the initial free heap and divide current value to get exact.
Bert Melis
@bertmelis
Jun 08 2018 19:27
float percentFreeHeap = ESP.getFreeHeap() / 760.0; Doesn't need to be accurte. I don't want to work cutting edge.
760 = 80kB - 4kB (stack) / 100 (for percent)
Earle F. Philhower, III
@earlephilhower
Jun 08 2018 19:28
Actually, the 4k stack is now stored in the SYS stack so you could just divide by 800.
And given the error bars assuming 80kb to start, an integer division would be fine, too.
Bert Melis
@bertmelis
Jun 08 2018 19:30
got it :wink: Thanks for the insight.
got it running. I've got 46% free heap, running mqtt and a webserver/websockets. that's plenty to connect "real" stuff to the esp.