Compiler gets stuck
Posted: Mon Jun 01, 2015 1:51 pm
Guys, need some assistance. I rewrote a LUA code I was running on a 01 to Arduino. I hit the compiler and it's now getting stuck. It goes 25% or so and it stops. Could someone take a look?
Code: Select all
// A PIR sensor that sends status to web server. Compiled on Arduino IDE 1.6.4 and written for ESP8266 (ESP-01)
// based upon:
// PIR sensor tester by Limor Fried of Adafruit, Andy Reischle (AReResearch)
// and John Park's published work here: http://blog.makezine.com/projects/pir-sensor-arduino-alarm/
#include "ESP8266WiFi.h"
const char* ssid = "M********g"
const char* password = "**********";
const char* SensorID = "MailBox";
int inputPin = 2; // choose the input pin (for PIR sensor)
int pirState = 0; // we start, assuming no motion detected
int val = 0; // variable for reading the pin status
void setup() {
pinMode(inputPin, INPUT); // declare sensor as input
Serial.begin(115200);
//Connect to AP
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void loop(){
val = digitalRead(inputPin); // read input value
if (val == 1) { // check if the input is 1
delay(150);
if (pirState == 0) {
// we have just turned on
Serial.println("Motion detected!");
SendAlarm;
// We only want to print on the output change, not state
pirState = 1;
}
} else {
delay(300);
if (pirState == 1){
// we have just turned off
Serial.println("Motion ended!");
SendClear;
// We only want to print on the output change, not state
pirState = LOW;
}
}
}
// Send alarm to Fred (FRED is the Web Server)
void SendAlarm()
{
WiFiClient client;
String url = ("/alarm.php?SensorID=", "SensorID", "&status=ALARM");
Serial.print("Sending web message to: ");
Serial.println(url);
// This will send the request to the server
if
(client.connect("172.16.0.1", 80))
{
client.println("POST /add.php HTTP/1.1");
client.println("Host: MOMMABUG.HOME");
client.println("Content-Type: application/x-www-form-urlencoded");
client.print("Content-Length: ");
client.println(SensorID(), "&status=ALARM");
client.print();
}
if (client.connected()) {
client.stop():
}
}
// Send clear to Fred
void SendClear()
{
String url = ("/alarm.php?SensorID=", "SensorID", "&status=CLEAR");
WiFiClient client;
Serial.print("Sending web message to: ");
Serial.println(url);
// This will send the request to the server
if
{
client.connect("172.16.0.1", 80)
client.println("POST /add.php HTTP/1.1");
client.println("Host: MOMMABUG.HOME");
client.println("Content-Type: application/x-www-form-urlencoded");
client.print("Content-Length: ");
client.println("SensorID" (), "&status=CLEAR");
client.print();
}
if (client.connected()) {
client.stop():
}
}