Hallo,
ich habe ein "NodeMCU ESP8266 ESP-12E WiFi" und als IDE verwende ich Arduino.
Ich Sammel grade meine ersten Erfahrungen damit und für mein Projekt möchte ich per Knopfdruck eine IFTTT aktion Auslösen.
Wenn ich die URL selber im Browser aufrufe klappt das auch, per Knopfdruck auf dem Controller jedoch nicht.
Der Code ist:
Der Serial Monitor zeigt mir an:
und wenn ich den Knopf drücke sagt er mir:
Allerdings triggert das Event nicht. Hat jemand eine Idee?
lg Zuyas
ich habe ein "NodeMCU ESP8266 ESP-12E WiFi" und als IDE verwende ich Arduino.
Ich Sammel grade meine ersten Erfahrungen damit und für mein Projekt möchte ich per Knopfdruck eine IFTTT aktion Auslösen.
Wenn ich die URL selber im Browser aufrufe klappt das auch, per Knopfdruck auf dem Controller jedoch nicht.
Der Code ist:
#include <ESP8266WiFi.h>
const char* ssid = "XXXX";
const char* password = "XXXX";
const char* host = "maker.ifttt.com";
const char* apiKey = "XXXX";
int pin = 0;
volatile int flag = false;
const char* PIN_state = "not pressed";
void PINStatus()
{
PIN_state = "bell pressed";
flag = true;
}
void setup() {
Serial.begin(115200);
Serial.println("door bell integration with IFTTT");
delay(100);
pinMode(pin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(pin), PINStatus, FALLING);
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void loop() {
if(flag)
{
Serial.print("connecting to ");
Serial.println(host);
WiFiClient client;
const int httpPort = 80;
if (!client.connect(host, httpPort))
{
Serial.println("connection failed");
return;
}
String url = "/trigger/door_bell/with/key/";
url += apiKey;
Serial.print("Requesting URL: ");
Serial.println(url);
client.print(String("POST ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Content-Type: application/x-www-form-urlencoded\r\n" +
"Content-Length: 13\r\n\r\n" +
"value1=" + PIN_state + "\r\n");
flag = false;
}
delay(100);
}
const char* ssid = "XXXX";
const char* password = "XXXX";
const char* host = "maker.ifttt.com";
const char* apiKey = "XXXX";
int pin = 0;
volatile int flag = false;
const char* PIN_state = "not pressed";
void PINStatus()
{
PIN_state = "bell pressed";
flag = true;
}
void setup() {
Serial.begin(115200);
Serial.println("door bell integration with IFTTT");
delay(100);
pinMode(pin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(pin), PINStatus, FALLING);
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void loop() {
if(flag)
{
Serial.print("connecting to ");
Serial.println(host);
WiFiClient client;
const int httpPort = 80;
if (!client.connect(host, httpPort))
{
Serial.println("connection failed");
return;
}
String url = "/trigger/door_bell/with/key/";
url += apiKey;
Serial.print("Requesting URL: ");
Serial.println(url);
client.print(String("POST ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Content-Type: application/x-www-form-urlencoded\r\n" +
"Content-Length: 13\r\n\r\n" +
"value1=" + PIN_state + "\r\n");
flag = false;
}
delay(100);
}
um 0x2d
v0fd86a07
~ld
door bell integration with IFTTT
Connecting XXXX
.
IP address:
192.168.0.31
v0fd86a07
~ld
door bell integration with IFTTT
Connecting XXXX
.
IP address:
192.168.0.31
connecting to maker.ifttt.com
Requesting URL: /trigger/door_bell/with/key/XXXX
Requesting URL: /trigger/door_bell/with/key/XXXX
lg Zuyas