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....
#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..
WiFi 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