Fixed IFTTT connection issue, thanks for the tip!
twingall1 opened this issue · 0 comments
twingall1 commented
followed your link and found some code which fixed the IFTTT section of the code so it now works for me; sends both email and phone notifications.
Thanks for the tip
here is the latter part of the .ino code with my edit:
.....
cpm = (60000 * counts) / (millis() - startCountTime) ;
counts = 0 ;
startCountTime = millis() ;
lastCountTime += PERIOD_LOG * 1000;
display.clear();
displayString("Radioactivity", 64, 0);
displayInt(cpm, 64, 30);
if (cpm >= 200) {
if (active) {
active = 0 ;
display.clear();
displayString("¡¡ALARM!!", 64, 0);
displayInt(cpm, 64, 30);
//////////////////////////////////////////////////////////////////
//begin edit---
//Send email
int HTTP_PORT = 80;
String HTTP_METHOD = "POST"; // or "GET"
char HOST_NAME[] = "maker.ifttt.com"; // hostname of web server:
String PATH_NAME = "/trigger/radiationHigh/json/with/key/kBhwl8us_6dBBeL"; //(not a real API key; add your own here, after key/ ... change 'radiationHigh' to whatever is your 'event' name in IFTTT
if(client.connect(HOST_NAME, HTTP_PORT)) {
Serial.println("Connected to server");
} else {
Serial.println("connection failed");
}
// send HTTP request header
client.println(HTTP_METHOD + " " + PATH_NAME + " HTTP/1.1");
client.println("Host: " + String(HOST_NAME));
client.println("Connection: close");
client.println(); // end HTTP request header
//comment out the following 3 lines...
//#ifdef IFTT
// IFTTT(cpm);
//#endif
//end edit---
//////////////////////////////////////////////////////////////////
} ;
}
else if (cpm < 100)
{
active = 1 ;
} ;
#ifdef CONS
Serial.print("cpm: "); Serial.println(cpm);