Alexis Santiago Allende
Published © GPL3+

Blynk App with Linkit7688 Duo and Webcam

How to make a functional application with Blynk and the Linkit Smart 7688 Duo board, with utility for home automation.

IntermediateFull instructions provided6 hours3,148
Blynk App with Linkit7688 Duo and Webcam

Things used in this project

Hardware components

DHT22 Temperature Sensor
DHT22 Temperature Sensor
×1
Breadboard (generic)
Breadboard (generic)
×1
LED (generic)
LED (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
RobotGeek Relay
RobotGeek Relay
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1
Buzzer
Buzzer
×1
Resistor 330 ohm
Resistor 330 ohm
×4
Resistor 10k ohm
Resistor 10k ohm
×1
Camera (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE
Blynk
Blynk

Story

Read more

Schematics

My circuit

My elegant circuit

Code

Blynk Bridge DHT22

Arduino
My code
#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

Python
Code for send photo to dropbox, using dropbox api
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

Credits

Alexis Santiago Allende

Alexis Santiago Allende

0 projects • 73 followers
Im a person who since young feel a passion for electronics, I also like to cook pizza and travel. Now Im working on the internet of things

Comments