Skip to content
Snippets Groups Projects
Commit 3516252b authored by Tobias Rico Meinhardt's avatar Tobias Rico Meinhardt
Browse files

added alexa notification mode

parent a0646134
No related branches found
No related tags found
No related merge requests found
#include <ArduinoJson.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>
#include "AnotherIFTTTWebhook.h"
#include "WiFi_Credentials.h"
#define IFTTT_API_KEY "jF1DREiJnO7lXPWoqcyIGb6OpMe8ANPsXBrGeJ6L41B"
#define IFTTT_API_KEY "c3o0F81wtGS2vXXPbnKM1tBTPY6q50V5oks-uWzBJa7"
#define IFTTT_EVENT_NAME "button_pressed"
#define IFTTT_EVENT2_NAME "button_pressed_survey"
#define IFTTT_EVENT3_NAME "trigger_text_nachricht"
#define USERNAME "Tobias Meinhardt"
HTTPClient http; //Declare an object of class HTTPClient
// Buttons on D3 & D4 & D5
const int button1 = 0;
const int button2 = 2;
const int mode_button = 14;
int cubeMode = 0;
boolean dataSent = false;
void setup () {
......@@ -23,7 +25,6 @@ void setup () {
pinMode(button1, INPUT);
pinMode(button2, INPUT);
pinMode(mode_button, INPUT);
}
......@@ -40,8 +41,9 @@ void loop() {
int mode_buttonVal = digitalRead(mode_button);
if (mode_buttonVal == LOW) {
cubeMode++;
if (cubeMode == 3) {
if (cubeMode == 4) {
cubeMode = 0;
dataSent = false;
}
Serial.println("Modus geändert");
}
......@@ -71,7 +73,8 @@ void loop() {
send_webhook(IFTTT_EVENT_NAME, IFTTT_API_KEY, "Ich muss die Vorlesung verlassen", USERNAME, "");
Serial.println("Sende ich muss gehen");
}
//TODO generate sums for new spreadsheet
if (button1Val == LOW && cubeMode == 2) {
send_webhook(IFTTT_EVENT2_NAME, IFTTT_API_KEY, "JA", USERNAME, "");
Serial.println("Sende JA");
......@@ -81,6 +84,13 @@ void loop() {
send_webhook(IFTTT_EVENT2_NAME, IFTTT_API_KEY, "NEIN", USERNAME, "");
Serial.println("Sende NEIN");
}
// Send notification to alexa over ifttt connected to skill "Text Nachricht" that survey is ready to download
if (cubeMode == 3 && !dataSent) {
dataSent = true;
send_webhook(IFTTT_EVENT3_NAME, IFTTT_API_KEY, "", "", "");
Serial.println("Sende Auswertung fertig");
}
}
}
delay(100);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment