Hi everyone
In the project, the photo is taken by the camera and sent to the dropbox.
Is it possible to send the photo to the mail if possible
sketch:
#define BLYNK_PRINT Serial
/* Set this to a bigger number, to enable sending longer messages */
//#define BLYNK_MAX_SENDBYTES 128
#include <Bridge.h>
#include <Process.h>
#include <BlynkSimpleYun.h>
char auth[] = "755c4016d214484480b80c5739068ef7";
byte b=0,c=0,d=0,e=0;
char a;
int LED = 5 ;
#include <DHT.h>
#define DHTPIN 6 // What digital pin we're connected to
#define DHTTYPE DHT22 // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21 // DHT 21, AM2301
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
void sendSensor()
{
float h = dht.readHumidity();
float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V5, h);
Blynk.virtualWrite(V6, t);
}
void setup() {
// put your setup code here, to run once:
Bridge.begin();
Blynk.begin(auth);
dht.begin();
timer.setInterval(1000L, sendSensor);
pinMode(LED, OUTPUT);
digitalWrite(LED, LOW);
Serial.begin(9600);
Serial.print("Hola, para tomar una foto favor de mandar un 1");
}
void loop() {
// put your main code here, to run repeatedly:
Blynk.run();
timer.run();
a=Serial.read();
if(a=='1')
{
digitalWrite(LED, HIGH);
Blynk.email("pufyx1@gmail.com", "Intruso", "Hay alguien inesperado en la casa, revisa la foto en dropbox");
takePicture();
uploadPicture();
a=0;
digitalWrite(LED, LOW);
}
}
void takePicture() {
Process p; // Create a new process
p.begin("fswebcam"); // Run the fswebcam utility, but first...
p.addParameter("/root/app/pic.jpg"); // add a path parameter
p.addParameter("-r 1280x720"); // and a resolution parameter
p.run(); // now run it and and wait for its termination
}
void uploadPicture() {
Process p;
p.begin("python");
p.addParameter("/root/app/dropy.py");
p.run();
}
send photo:
import dropbox
import datetime
suffix = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
filename = “photobooth-” + suffix + “.jpg”
client = dropbox.client.DropboxClient(‘YOURACCESSTOKENGOESHERE’)
f = open(’/mnt/sda1/pic.jpg’, ‘rb’)
response = client.put_file(filename, f)
print “uploaded:”, response
tnx a lot