I get an error when I upload the following code to esp. can you help me ?
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
ets Jan 8 2013,rst cause:2, boot mode:(3,4)
load 0x4010f000, len 3664, room 16
tail 0
chksum 0xee
csum 0xee
v39c79d9b
~ld
ISR not in IRAM!
User exception (panic/abort/assert)
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
Abort called
>>>stack>>>
ctx: cont
sp: 3ffffcd0 end: 3fffffc0 offset: 0000
3ffffcd0: feefeffe feefeffe feefeffe 00000100
3ffffce0: 000000fe 00000000 00000000 00000000
3ffffcf0: 00000000 00000000 00000000 00ff0000
3ffffd00: 5ffffe00 5ffffe00 3ffefa34 00000000
3ffffd10: 00000001 00000002 3ffeeafc 4020e98e
3ffffd20: 40100542 4020f9ad ffffffff 4020e9a0
3ffffd30: feefeffe 00000001 3ffeeafc 4020eea9
3ffffd40: 00000000 00000001 3ffeeafc 4020c018
3ffffd50: 00000000 feefeffe feefeffe 3ffeec2c
3ffffd60: 3fffdad0 00000000 3ffeeafc 4020ef58
3ffffd70: 3fffdad0 00000000 3ffeeafc 40201283
3ffffd80: feefeffe feefeffe feefeffe feefeffe
3ffffd90: feefeffe feefeffe feefeffe feefeffe
3ffffda0: feefeffe feefeffe feefeffe feefeffe
3ffffdb0: feefeffe feefeffe feefeffe feefeffe
3ffffdc0: feefeffe feefeffe feefeffe feefeffe
3ffffdd0: feefeffe feefeffe feefeffe feefeffe
3ffffde0: feefeffe feefeffe feefeffe feefeffe
3ffffdf0: feefeffe feefeffe feefeffe feefeffe
3ffffe00: feefeffe feefeffe feefeffe feefeffe
3ffffe10: feefeffe feefeffe feefeffe feefeffe
3ffffe20: feefeffe feefeffe feefeffe feefeffe
3ffffe30: feefeffe feefeffe feefeffe feefeffe
3ffffe40: feefeffe feefeffe feefeffe feefeffe
3ffffe50: feefeffe feefeffe feefeffe feefeffe
3ffffe60: feefeffe feefeffe feefeffe feefeffe
3ffffe70: feefeffe feefeffe feefeffe feefeffe
3ffffe80: feefeffe feefeffe feefeffe feefeffe
3ffffe90: feefeffe feefeffe feefeffe feefeffe
3ffffea0: feefeffe feefeffe feefeffe feefeffe
3ffffeb0: feefeffe feefeffe feefeffe feefeffe
3ffffec0: feefeffe feefeffe feefeffe feefeffe
3ffffed0: feefeffe feefeffe feefeffe feefeffe
3ffffee0: feefeffe feefeffe feefeffe feefeffe
3ffffef0: feefeffe feefeffe feefeffe feefeffe
3fffff00: feefeffe feefeffe feefeffe feefeffe
3fffff10: feefeffe feefeffe feefeffe feefeffe
3fffff20: feefeffe feefeffe feefeffe feefeffe
3fffff30: feefeffe feefeffe feefeffe feefeffe
3fffff40: feefeffe feefeffe feefeffe feefeffe
3fffff50: feefeffe feefeffe feefeffe feefeffe
3fffff60: feefeffe feefeffe feefeffe feefeffe
3fffff70: feefeffe feefeffe feefeffe feefeffe
3fffff80: feefeffe feefeffe feefeffe feefeffe
3fffff90: feefeffe feefeffe feefeffe feefeffe
3fffffa0: feefeffe feefeffe 3ffeebec 4020e53c
3fffffb0: feefeffe feefeffe 3ffe8500 40100e3d
<<<stack<<<
Code
#include <ESP8266WiFi.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h>
#define SENSORPIN 2
#define LEDPIN 0
// Set web server port number to 80
WiFiServer server1(80);
// Variable to store the HTTP request
String header;
// Replace with your unique IFTTT URL resource
const char* resource = "/trigger/YOUR-EVENT-NAME/with/key/YOUR-KEY";
// Maker Webhooks IFTTT
const char* server = "maker.ifttt.com";
volatile bool sensorActivatedFlag = false;
void setup() {
Serial.begin(115200);
pinMode(SENSORPIN, INPUT);
pinMode(LEDPIN, OUTPUT);
attachInterrupt(SENSORPIN, sensorActivated, RISING);
// WiFiManager
// Local intialization. Once its business is done, there is no need to keep it around
WiFiManager wifiManager;
// fetches ssid and pass from eeprom and tries to connect
// if it does not connect it starts an access point with the specified name
// here "AutoConnectAP"
// and goes into a blocking loop awaiting configuration
wifiManager.autoConnect();
// or use this for auto generated name ESP + ChipID
//wifiManager.autoConnect();
// if you get here you have connected to the WiFi
Serial.println("Connected.");
server1.begin();
initWifi();
}
// Establish a Wi-Fi connection with your router
void initWifi() {
WiFiClient client = server1.available(); // Listen for incoming clients
if (client) { // If a new client connects,
Serial.println("New Client."); // print a message out in the serial port
String currentLine = ""; // make a String to hold incoming data from the client
while (client.connected()) { // loop while the client's connected
if (client.available()) { // if there's bytes to read from the client,
char c = client.read(); // read a byte, then
Serial.write(c); // print it out the serial monitor
header += c;
if (c == '\n') { // if the byte is a newline character
// if the current line is blank, you got two newline characters in a row.
// that's the end of the client HTTP request, so send a response:
if (currentLine.length() == 0) {
// HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
// and a content-type so the client knows what's coming, then a blank line:
client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/html");
client.println("Connection: close");
client.println();
// Web Page Heading
client.println("<body><h1>ESP8266 Web Server</h1>");
// The HTTP response ends with another blank line
client.println();
// Break out of the while loop
break;
} else { // if you got a newline, then clear currentLine
currentLine = "";
}
} else if (c != '\r') { // if you got anything else but a carriage return character,
currentLine += c; // add it to the end of the currentLine
}
}
}
// Clear the header variable
header = "";
// Close the connection
client.stop();
Serial.println("Client disconnected.");
Serial.println("");
}
}
void sensorActivated() {
Serial.println("sensorActivated");
int pirSensor = digitalRead(SENSORPIN);
if (pirSensor == HIGH)
{
sensorActivatedFlag = true;
}
return;
}
// Make an HTTP request to the IFTTT web service
void makeIFTTTRequest() {
Serial.print("Connecting to ");
Serial.print(server);
sensorActivatedFlag = false;
WiFiClient client;
int retries = 5;
while (!!!client.connect(server, 80) && (retries-- > 0)) {
Serial.print(".");
}
Serial.println();
if (!!!client.connected()) {
Serial.println("Failed to connect, going back to sleep");
}
Serial.print("Request resource: ");
Serial.println(resource);
client.print(String("GET ") + resource +
" HTTP/1.1\r\n" +
"Host: " + server + "\r\n" +
"Connection: close\r\n\r\n");
int timeout = 5 * 10; // 5 seconds
while (!!!client.available() && (timeout-- > 0)) {
delay(100);
}
if (!!!client.available()) {
Serial.println("No response, going back to sleep");
}
while (client.available()) {
Serial.write(client.read());
}
Serial.println("\nclosing connection");
client.stop();
}
void ledblink() {
digitalWrite(LEDPIN, HIGH);
delay(500);
digitalWrite(LEDPIN, LOW);
delay(500);
digitalWrite(LEDPIN, HIGH);
delay(500);
digitalWrite(LEDPIN, LOW);
delay(500);
digitalWrite(LEDPIN, HIGH);
delay(500);
digitalWrite(LEDPIN, LOW);
}
void loop() {
if (sensorActivatedFlag) {
makeIFTTTRequest();
ledblink();
}
}