IoT let the dogs out

Made by Gabriela Rubio

Automatic backyard door opening for early morning barking dogs.

Created: January 29th, 2016


Problem Statement. 

My parents own two gorgeous Schnauzer dogs. They have the same routine every day: first thing in the morning, they both start parking because they want to go to the back yard so they can make their doggy stuff. Although they are so lovely 99% of the time, their barking every morning is annoying. They will bark and try to push the door until somebody opens it for them. 


This project will allow my parents to stay in bed for longer during the morning with no sleep-threatening barking. This project intends to use the dogs' morning routine so they can go out to the backyard by themselves. 


- Photo Resistor

- LED (Red, 5mm)

- 10K-Ohm Resistors (Brown-Black-Orange)

- 1K-Ohm Resistors (Brown-Black-Red)

- Electret (FC-04)

- Emax ES08A Mini RC Servo Motor

- Mini Pushbutton

- Jumper Wires (15x) 



I started this process by creating flow diagrams to understand what I was wanted the solution to do, considering the things the dogs are used to do every morning so no training is required for them. 
After this, attached all the components in the breadboard and I added "//" type of comments in Particle Dev, and filling them out with functions and variables. This turned out to be not the best efficient process, so I got to a point that I had to delete everything and start over again. I unplugged everything from the breadboard and then I started adding and testing every component individually. I believe that doing this was a good thing for my process since I reaffirmed everything was working properly, this is why I added an LED to monitor the functions of every component, although it was not required for the final solution. As shown in the Code, dividing constants & variables, setup, loop and functions was very helpful for me to manage all the information and confirm functionality. 


Flow diagram


Final components attached 

//Photo resistor / photo cell input
int photoCellPin = A0;

//Store the sensor reading
int photoCellReading = 0;

//Threshold for being dark
int threshold = 2800;

int ledPin = D0;

//Pin for microphone
int micPin = A1;

//Reading noise level
int noise_level = 0;

const int sampleWindow = 50;

int servoPin = D2;
Servo myServo;
int pos=5;

int buttonPin = D3;

void setup(){

  //Function that will allow direct communication between usb port, analogue reading

  //Connect the photo cell reading to the cloud to read the value on "cloud variables"
  Particle.variable("light", &photoCellReading, INT);

  Particle.variable("noise", &noise_level, INT);

  pinMode(ledPin, OUTPUT);

  // Attaches the servo on the A7 pin to the servo object


  pinMode(buttonPin, INPUT_PULLUP);


void loop(){

  photoCellReading = analogRead(photoCellPin);
    if(photoCellReading > threshold){
      noise_level = sampleNoise();
      Serial.println ( noise_level );
        myServo.write(5);//Open door
  digitalWrite (ledPin, LOW);
  int buttonState = digitalRead(buttonPin);
  if( buttonState == LOW )

myServo.write(90);//Close door
delay(5000); //Wait for a little bit before reading again

  //Read to give threshold
  //Serial.print("sensor reading is");


int monitorPhotoCell(){

  //Reading from sensor
  photoCellReading = analogRead(photoCellPin);
  if(photoCellReading > threshold){
    digitalWrite (ledPin, HIGH);
  else {
    digitalWrite (ledPin, LOW);}

int sampleNoise(){
  unsigned long startMillis = millis();
  int highest_sample = 0;
  int lowest_sample = 1000;
  while (millis()-startMillis < sampleWindow) {
    int sample = analogRead(micPin);
    sample = map (sample,0,4095,1000,0);
    if (sample > highest_sample){
      highest_sample = sample;
    if(sample < lowest_sample){
      lowest_sample = sample;
  int peakToPeak = highest_sample - lowest_sample;
  return peakToPeak;

int monitorMic(){
  noise_level = sampleNoise();
  Serial.println ( noise_level );
    else{digitalWrite(ledPin, LOW);}
Click to Expand

Final Code



This solution works as follows:

1. It will detect if there is light around, since the dogs are supposed to go to the backyard only during the daytime. 

2. It will detect if the dogs are barking (this part was kind of tricky - I had to play with the sensibility of the microphone so it could differentiate very loud from not very loud noises).

3. The Servo Motor acts as a door latch  and if the microphone hears the barks (or very loud noises) it will rotate 90. 

4. The door will be open, and the dogs will be able to push it so they can go out. A notification will be sent. 

5. I included a button so the latch can be closed again. 

While I was doing this project I realised that probably the microphone was not the most effective idea to detect if the dogs are ready to go out, since there might be other loud noises around. Therefore, if I was to continue to develop this solution, I would probably try this solution and also a limit switch to react to the dogs' push and see which one works best. 

IoT Assignment1
Gabriela Rubio -


During this process I learned that it is more efficient if I try step by step and prove that the individual components are working correctly. Although it did not make sense to me at the beginning of this IoT class, using jumping wires can be very helpful to make changes and, ironically, maintain a "clean" layout in the breadboard. I also learned to divide functions and then call them on the loop segment so I can have a better organisation within the code. 
Share this Project


49-713 Designing for the Internet of Things

· 4 members

This course charts the emergence of the now "connected world" to explore the possibilities for future products and connected spaces.

Focused on

Automatic backyard door opening for early morning barking dogs.