It works, but at low resolution...
This commit is contained in:
69
src/main.cpp
69
src/main.cpp
@@ -7,20 +7,28 @@
|
|||||||
* BE SURE TO SET "TOOLS > CORE DEBUG LEVEL = INFO"
|
* BE SURE TO SET "TOOLS > CORE DEBUG LEVEL = INFO"
|
||||||
* to turn on debug messages
|
* 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 <eloquent_esp32cam.h>
|
#include <eloquent_esp32cam.h>
|
||||||
#include <eloquent_esp32cam/motion/detection.h>
|
#include <eloquent_esp32cam/motion/detection.h>
|
||||||
|
#include <eloquent_esp32cam/extra/esp32/telegram.h>
|
||||||
|
|
||||||
using eloq::camera;
|
using eloq::camera;
|
||||||
|
using eloq::wifi;
|
||||||
|
using eloq::telegram;
|
||||||
using eloq::motion::detection;
|
using eloq::motion::detection;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void setup() {
|
void setup() {
|
||||||
delay(3000);
|
delay(3000);
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
Serial.println("___MOTION DETECTION + SWITCH RESOLUTION___");
|
Serial.println("___MOTION DETECTION + Resolution Swtch + Send to Telegram__");
|
||||||
|
|
||||||
// camera settings
|
// camera settings
|
||||||
// replace with your own model!
|
// replace with your own model!
|
||||||
@@ -41,6 +49,19 @@ void setup() {
|
|||||||
Serial.println(camera.exception.toString());
|
Serial.println(camera.exception.toString());
|
||||||
|
|
||||||
Serial.println("Camera OK");
|
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...");
|
Serial.println("Awaiting for motion...");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,6 +90,7 @@ void loop() {
|
|||||||
camera.getSizeInBytes()
|
camera.getSizeInBytes()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
Serial.println("Taking photo of motion at higher resolution");
|
Serial.println("Taking photo of motion at higher resolution");
|
||||||
|
|
||||||
camera.resolution.at(FRAMESIZE_UXGA, []() {
|
camera.resolution.at(FRAMESIZE_UXGA, []() {
|
||||||
@@ -79,16 +101,45 @@ void loop() {
|
|||||||
camera.resolution.benchmark.millis()
|
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(
|
Serial.printf(
|
||||||
"Frame size is now %d bytes\n",
|
"Frame size is now %d bytes\n",
|
||||||
camera.getSizeInBytes()
|
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");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user