Soft WDT reset
>>>stack>>>
ctx: cont
sp: 3ffffdf0 end: 3fffffc0 offset: 01b0
3fffffa0: feefeffe 00000000 3ffeeae0 40206728
3fffffb0: feefeffe feefeffe 3ffe852c 401015c9
<<<stack<<<
Decoded stack:
Decoding stack results
0x40206728: loop_wrapper() at C:\Users\kamil\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\cores\esp8266\core_esp8266_main.cpp line 122
I was trying to fix this issue and find any solution in many forums but unfortunately board prints same message I think the issue is somewhere in code.
// biblioteki
#include <ESP8266WiFi.h>
#include <Wire.h>
#include <Adafruit_BME280.h>
#include <Esp.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_TSL2561_U.h>
Adafruit_TSL2561_Unified tsl = Adafruit_TSL2561_Unified(TSL2561_ADDR_FLOAT, 0x39);
Adafruit_BME280 bme;
// stałe
String apiKey = "XXX";
const char* ssid = "XXX ";
const char* password = "XXX";
const char* server = "api.thingspeak.com";
// definicje pinów
#define DHTPIN 2
#define DHTTYPE DHT22
#define DIR A0
#define WIN 12
#define RAI 0
WiFiClient client;
unsigned int rai = 0;
bool r = 0;
unsigned long timer;
unsigned long delayTime;
/*----------------------------------------------------------------------------*/
void displaySensorDetails(void)
{
sensor_t sensor;
tsl.getSensor(&sensor);
Serial.println("------------------------------------");
Serial.print ("Sensor: "); Serial.println(sensor.name);
Serial.print ("Driver Ver: "); Serial.println(sensor.version);
Serial.print ("Unique ID: "); Serial.println(sensor.sensor_id);
Serial.print ("Max Value: "); Serial.print(sensor.max_value); Serial.println(" lux");
Serial.print ("Min Value: "); Serial.print(sensor.min_value); Serial.println(" lux");
Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println(" lux");
Serial.println("------------------------------------");
Serial.println("");
delay(500);
}
/**************************************************************************/
void configureSensor(void)
{
/* You can also manually set the gain or enable auto-gain support */
// tsl.setGain(TSL2561_GAIN_1X); /* No gain ... use in bright light to avoid sensor saturation */
// tsl.setGain(TSL2561_GAIN_16X); /* 16x gain ... use in low light to boost sensitivity */
tsl.enableAutoRange(true); /* Auto-gain ... switches automatically between 1x and 16x */
/* Changing the integration time gives you better sensor resolution (402ms = 16-bit data) */
//tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_13MS); /* fast but low resolution */
// tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_101MS); /* medium resolution and speed */
tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_402MS); /* 16-bit data but slowest conversions */
Serial.println("------------------------------------");
Serial.print ("Gain: "); Serial.println("Auto");
Serial.print ("Timing: "); Serial.println("13 ms");
Serial.println("------------------------------------");
}
/*----------------------------------------------------------------------------*/
void rn() {
r = 1;
}
void rai_maintenance() {
if (r == 1) {
delay(200);
r = 0;
rai++;
}
}
void setup() {
Serial.begin(9600);
bool status;
delayTime = 1000;
Serial.println("Uruchamianie");
Wire.begin();
pinMode(DIR, INPUT);
pinMode(WIN, INPUT);
pinMode(RAI, INPUT);
attachInterrupt(digitalPinToInterrupt(RAI), rn, CHANGE);
Serial.println("Lonczenie z siecia");
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
if(!tsl.begin())
{
Serial.print("Ooops, no TSL2561 detected ... Check your wiring or I2C ADDR!");
while(1);
}
status = bme.begin();
if (!status) {
Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
Serial.println("Polonczono!");
}
}
void loop() {
rai_maintenance();
if (millis() > timer) {
Serial.println("Pomiar...");
// zmienne na wyniki
int win = 0;
float temp;
float hum;
float pres;
float dir;
double rain;
Serial.println("Pomiar wiatru...");
unsigned long timer2 = millis() + 3000;
bool state = digitalRead(WIN);
bool val;
ESP.wdtDisable();
while (1) {
rai_maintenance();
unsigned long current = millis();
if (current > timer2) {
break;
}
val = digitalRead(WIN);
if (state != val) {
state = val;
delay(5);
win++;
}
}
ESP.wdtFeed();
ESP.wdtEnable(3200);
int value = analogRead(DIR);
rain = rai * 0.2794;
//prędkość wiatru
win = win * 5; //*30/3/2
float wind = 2.75 / 12 * 3.14 * win * 60 / 5280;
wind = wind * 3.5;
wind = wind * 1.609;
if ((value > 752) && (value < 760)) {
dir = 0;
}
if ((value > 396) && (value < 404)) {
dir = 22.5;
}
if ((value > 447) && (value < 455)) {
dir = 45;
}
if ((value > 81) && (value < 89)) {
dir = 67.5;
}
if ((value > 90) && (value < 94)) {
dir = 90;
}
if ((value > 64) && (value < 72)) {
dir = 112.5;
}
if ((value > 181) && (value < 189)) {
dir = 135;
}
if ((value > 122) && (value < 130)) {
dir = 157.5;
}
if ((value > 279) && (value < 287)) {
dir = 180;
}
if ((value > 238) && (value < 236)) {
dir = 202.5;
}
if ((value > 604) && (value < 612)) {
dir = 225;
}
if ((value > 577) && (value < 585)) {
dir = 247.5;
}
if ((value > 900) && (value < 908)) {
dir = 270;
}
if ((value > 790) && (value < 798)) {
dir = 292.5;
}
if ((value > 844) && (value < 852)) {
dir = 315;
}
if ((value > 675) && (value < 883)) {
dir = 337.5;
}
sensors_event_t event;
tsl.getEvent(&event);
float pressure;
float temperature;
float humidity;
pressure = (bme.readPressure()/100);
temperature = bme.readTemperature();
humidity = bme.readHumidity();
// pressure = pres / 99 - 3,88 ;
Serial.println("_______________________________________________________________________________");
Serial.print("Temp: ");Serial.println(temperature);
Serial.print("Humid: ");Serial.println(humidity);
Serial.print("Press: ");Serial.println(pressure);
Serial.print("Wind: ");Serial.println(wind);
Serial.print("Light: ");Serial.println(event.light, 10);
Serial.println("_______________________________________________________________________________");
Serial.println("Wysylam dane...");
if (client.connect(server, 80)) {
String postStr = apiKey;
// 6 pól danych
postStr += "&field1=";
postStr += String(temperature);
postStr += "&field2=";
postStr += String(humidity);
postStr += "&field3=";
postStr += String(pressure);
postStr += "&field4=";
postStr += String(wind);
postStr += "&field5=";
postStr += String(event.light);
postStr += "\r\n\r\n";
client.print("POST /update HTTP/1.1\n");
client.print("Host: api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("X-THINGSPEAKAPIKEY: " + apiKey + "\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(postStr.length());
client.print("\n\n");
client.print(postStr);
}
delay(1000);
client.stop();
Serial.println("Dane wyslane");
timer = millis() + 10000;
}
}