I have a larger program successfully running on the Wio Term. At this point I wanted to verify how much free heap/stack I had left while in it’s steady state.
I’ve been looking in to the various post on checking the difference between the stack and heap for free ram and I can’t get the suggested one to return anything but a negitive number.
If I write a small program it returns 192279, which is kinda what I’d expect.
#include <MemoryFree.h>;
void setup() {
Serial.begin(115200);
while(!Serial); // Wait for Serial to be ready
Serial.println(freeMemory());
}
void loop() {
}
When I try the exact same call with just the WiFi library I get a negitive. -33449
#include "rpcWiFi.h"
#include <MemoryFree.h>;
const char* ssid = "SSID";
const char* password = "SSIDPassword";
void setup() {
Serial.begin(115200);
while(!Serial); // Wait for Serial to be ready
Serial.println(freeMemory());
WiFi.mode(WIFI_STA);
WiFi.disconnect();
Serial.println("Connecting to WiFi..");
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.println("Connecting to WiFi..");
WiFi.begin(ssid, password);
}
Serial.println("Connected to the WiFi network");
Serial.println(freeMemory());
}
void loop() {
}
I find it hard to beleive the WiFi library only would overrun the Heap/Stack and still function. My actual Sketch has more going on ( Wifi, MQTT, NTP, Graphics ) and shows a -129241 . There is no way the sketch is 130K over writing the heap/stack and still functions 100% for days. ( It’s only stopped when I push a new version, never crashed)
If the above doesn’t return a valid value, how best to check the free RAM?