diff --git a/src/main.cpp b/src/main.cpp index 106a06c..bfed333 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,20 +7,28 @@ * BE SURE TO SET "TOOLS > CORE DEBUG LEVEL = INFO" * to turn on debug messages */ +// WiFi credentials +#define WIFI_SSID "JoNelsDarlings" +#define WIFI_PASS "Paris2016" + +// replace with your bot token and chat id +#define TELEGRAM_TOKEN "5347428973:AAFPQOaSaWBhGmLok0nTN91-cTSwaVDZlSE" +#define TELEGRAM_CHAT2 "5076961591" // NELS +#define TELEGRAM_CHAT1 "5070349790" // JOE + #include #include +#include using eloq::camera; +using eloq::wifi; +using eloq::telegram; using eloq::motion::detection; - -/** - * - */ void setup() { delay(3000); Serial.begin(115200); - Serial.println("___MOTION DETECTION + SWITCH RESOLUTION___"); + Serial.println("___MOTION DETECTION + Resolution Swtch + Send to Telegram__"); // camera settings // replace with your own model! @@ -41,6 +49,19 @@ void setup() { Serial.println(camera.exception.toString()); Serial.println("Camera OK"); + + // connect to WiFi + while (!wifi.connect().isOk()) + Serial.println(wifi.exception.toString()); + + Serial.println("Wifi OK"); + + // connect to Telegram API + while (!telegram.begin().isOk()) + Serial.println(telegram.exception.toString()); + + Serial.println("Telegram OK"); + Serial.println("Awaiting for motion..."); } @@ -69,6 +90,7 @@ void loop() { camera.getSizeInBytes() ); + /* Serial.println("Taking photo of motion at higher resolution"); camera.resolution.at(FRAMESIZE_UXGA, []() { @@ -79,16 +101,45 @@ void loop() { camera.resolution.benchmark.millis() ); - camera.capture(); - + */ + + // capture new frame + Serial.println("Capturing Frame"); + if (!camera.capture().isOk()) { + Serial.println(camera.exception.toString()); + return; + } + Serial.printf( "Frame size is now %d bytes\n", camera.getSizeInBytes() ); - // save to SD... - }); + // send text to telegram + /* Serial.println("Sending Text to Telegram"); + String text="TEST"; + if (telegram.to(TELEGRAM_CHAT).send(text).isOk()){ + Serial.println("Message sent to Telegram!"); + }else{ + Serial.println(telegram.exception.toString()); + } */ + + // Send to telegram + Serial.println("Sending Image to Telegram"); + if (telegram.to(TELEGRAM_CHAT1).send(camera.frame).isOk()){ + Serial.println("Photo sent to Telegram"); + } else { + Serial.println(telegram.exception.toString()); + } + if (telegram.to(TELEGRAM_CHAT2).send(camera.frame).isOk()){ + Serial.println("Photo sent to Telegram"); + } else { + Serial.println(telegram.exception.toString()); + } + +/* }); + Serial.println("Resolution switched back to VGA"); + */ - Serial.println("Resolution switched back to VGA"); } } \ No newline at end of file