Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By martinius96
#74888 Hello there. I have a problem with NodeMCU v3 Lolin with stack overflow.
I have buy BMP280 sensor and humidity sensor DHT22.
I have tried serial.print() for each of these sensor's variables.
First time i did it separated and then i mix codes.. All were ok.

Problem was, when i included libraries ESP8266Wifi.h and WifiClientSecure.h
I want to send these datas on my webserver. I have used same syntax for https connection like at another projects. But it didn't work. Code is compiled sucesfully, i uploaded it to board (115200 speed), code working to end of setup and then stack overflow.
I have read something about this and people say something about ESP.getVcc() --> it gives me 65535... Maybe that is problem.

So.. In my project.. I am using BMP280 --> I2C on D1 and D2 pin, for DHT22 i use pin D4.
I uploaded this problematic code to NodeMCU, from which i get that stack overflow with resets....

Code: Select all  #include <ESP8266WiFi.h>
  #include <WiFiClientSecure.h> //KNIZNICA pre HTTPS spojenia
#include "DHT.h"
#define DHTPIN 2     // what digital pin we're connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321
DHT dht(DHTPIN, DHTTYPE);
#include "Adafruit_BMP280.h"         //bmp280 kniznica s upravou na 0x76 adresu
Adafruit_BMP280 bmp; //inicializacia BMP senzora
const char * ssid = "moj-sinet-2929"; //meno wifi siete
const char * password = "xxx"; //Heslo na wifi siet
const char * host = "xxx.xxx.xxx"; //bez https a www
const int httpsPort = 443; //https port zabezpeceny prenos
const char * fingerprint = "‎‎13 9f 87 1d b1 85 be e6 bd 73 c1 8d 04 63 58 99 f0 32 43 92"; //odtlacok HTTPS certifikatu v SHA1 formate
void setup() {         
  bmp.begin();        //start snimaca BMP
      dht.begin();             
  Serial.begin(9600);    //SPUSTENIE SERIOVEJ LINKY --UART-- NA CITACIU RYCHLOST 9600
  while (!Serial) {
    ;                                       
  }

 WiFi.begin(ssid, password); //pripoj sa na wifi siet s heslom
  while (WiFi.status() != WL_CONNECTED) { //pokial sa nepripojime na wifi opakuj pripajanie a spustaj funkcie pre ovladanie v offline rezime
    delay(500);
    Serial.println(".");
  }
  Serial.println("");
  Serial.println("WiFi pripojene"); //uspesne pripojenie na wifi siet
  Serial.println("IP adresa: ");
  Serial.println(WiFi.localIP()); // pridelena IP adresa pre dosku
}

void loop() {                                   
    WiFiClientSecure client;
  if (client.verify(fingerprint, host)) {} else {}
  if (client.connect(host, httpsPort)) {
    String vlhkost = String(dht.readHumidity());
    String tlak = String((bmp.readPressure() / 100) + 103,855);
    String teplota1 = String(bmp.readTemperature());
    String teplota2 = String(dht.readTemperature());
   
    String url = "/prikra/system/nodemcu/zapishodnoty.php?teplota1=" + teplota1 + "&teplota2=" + teplota2 + "&tlak=" + tlak + "&vlhkost=" + vlhkost; //--------------------------------------------------------------------------------DOPLN LINK
    client.print(String("GET ") + url + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "User-Agent: NodeMCU\r\n" + "Connection: close\r\n\r\n");
  } else if (!client.connect(host, httpsPort)) {
    Serial.println("Neuspesne pripojenie pre odoslanie teplot - offline rezim aktivny");
  }
  delay(5000);
  }



This is error (after setup end), it refresh NodeMCU and still make this.. as loop..
Code: Select allWiFi pripojene
IP adresa:
192.168.2.24

Exception (0):
epc1=0x30303030 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

ctx: cont
sp: 3fff0bf0 end: 3fff0e30 offset: 01a0

>>>stack>>>
3fff0d90:  38363937 30303537 30303030 30303030 
3fff0da0:  30303030 30303030 30303030 30303030 
3fff0db0:  30303030 30303030 00303030 40204ed1 
3fff0dc0:  3ffe9870 3ffefc50 3ffefdd8 3ffefe04 
3fff0dd0:  3fffdad0 3ffefc50 3ffefdd8 40204eec 
3fff0de0:  1802a8c0 00ffffff 1402a8c0 40204f38 
3fff0df0:  3fffdad0 3ffefc50 3fff532c 0000005f 
3fff0e00:  0000005b 3fff1e9c 0000000f 00000003 
3fff0e10:  3fffdad0 00000000 3ffefdfc 402055a8 
3fff0e20:  feefeffe feefeffe 3ffefe10 40100718 
<<<stack<<<

I am using Arduino Core 2.3.0. I am using similar sketches with DS18B20 or another sensors and there isn't problem.. Only there.. Can you please help me? Thanks a lot for you help! Martin
User avatar
By eriksl
#74926 Why do you think it's a stack overflow? The ESP8266 has quite a big stack (about 4k).

It looks like just a plain bug, an unaliged access to memory for example.

Besides that I have 0 knowledge from Arduino or NodeMCU. I think your question would better be asked in a specific Arduino or NodeMCU group.
User avatar
By McChubby007
#74930 You have read something about something somewhere. That's not very useful is it? Perhaps you should read about the right things and when you make statements like stack overflow or using getVcc() you can back them up with references. It almost seems to me you are groping in the dark and making wild guesses.

Can you not guess what getVcc() might do, even WITHOUT bothering to either look at the source OR google it, and/or look at the docs. And no, it has nothing to do with the stack.

Have you done any debugging? Do you know what debugging is? Debugging is not asking a question on a forum, it is hard, investigative work that is sometimes tiresome but necessary, done by the person who wrote the code. Programming is not just about copying and cobbling together other's software. Perhaps it is time you learned there's plenty of material on the web.

I'm ranting today because I get fed up with what looks like laziness to me.