Baby Motion Alert

Made by aghogare

Found in DIoT 2018 1- Home Hack

The Baby Motion Alert will detect when the baby is approaching the edge of the bed (any raised platform) and alert the parents/caretakers via a buzzer. The parents will then be able to rush to the room before the baby gets dangerously close to the edge.

0

Intention:

My sister is in a state of constant worry and restlessness when looking after her 1-year old baby. She is usually alone at home with the baby and needs to take care of other chores around the house when the baby is sleeping. However, she finds herself rushing back to the room to check on the baby every few minutes to see if she is awake and crawling too close to the edge of the bed. The Baby Motion Alert will inform her when the baby has moved and is at a certain distance from the edge. 

Goal:

 A motion sensory will be placed at the desired distance from the edge. It will detect the motion of the baby and alert the parents or caretakers with a notification on their phones or via a buzzer placed strategically in the house. The parents will then be able to rush to the room before the baby gets dangerously close to the edge.  

0

Parts

-PIR Motion Sensor

-Piezo buzzer  

-Button to reset buzzer 

-LED (for visual cue)

-Particle Photon

-Breadboard

-Resistors as needed

-Wires as needed  


0

Process:

I started with referring to projects involving motion detection, alarm systems, proximity detection etc on hackster and other resources. I needed to achieve two things:

a. Detect motion and provide a visual cue for the same

b. Ring a buzzer to alert the user about the motion detected

Hence, I started with figuring out about how the sensor works and needs to be connected. I initially connected the sensor and LED only. The circuit was pretty straightforward and I could make the LED light up by running the code. The next step was to connect the buzzer. Once the buzzer was brought into the circuit, making it work was considerably easy. The problem was with making it stop. Once the buzzer was triggered it was important to switch it off once the user was alerted. I introduced the "triggered" variable and put in  a condition in my code to only ring the buzzer when "triggered = true". This completed my circuit and my code.

Once everything was set up and I run the code a few times, I realized, that the buzzer was going off even when there was no motion around the sensor. After some research and on the recommendation of my Professor, I added a line of code that allowed the sensor to be calibrated for a minute before detecting motion. I also adjusted the time sensitivity and motion sensitivity on the PIR sensor to get better readings. To ensure that the program was running correctly, I also added the serial command which told me whether the PIR value was 0 (no motion detected) or 1 (motion detected). After these few changes the sensor seemed to working better, however, it was still quite sensitive to external interference. 

0
int PIRsensor = D0;              // choose the input pin (for PIR sensor)
int buzzPin = D3;
int button = D4;                // button ouput
int ledPin = D5;                //led OUTPUT
int pirState = LOW;             // we start, assuming no motion detected
int val = 0;
int triggered = false;                   // variable for reading the pin status
int calibrateTime = 60000;      // wait for the thingy to calibrate

void setup()
{
  Serial.begin( 9600 );
  pinMode( buzzPin, OUTPUT );    //declare buzzer as output
  pinMode(ledPin, OUTPUT);       //declare led as output
  pinMode(PIRsensor, INPUT);     // declare sensor as input
  pinMode(button, INPUT_PULLUP);
}
void loop()
{
  // if the sensor is calibrated
  if ( calibrated() )
  {
  // get the data from the sensor
    readTheSensor();
    // report it out, if the state has changed
    reportTheData();
  }
}

void readTheSensor() {
  val = digitalRead(PIRsensor);
  Serial.print( "PIR IS " );
  Serial.println( val );
}

bool calibrated() {
  return (millis() > calibrateTime );
}

void reportTheData() {
  // if the sensor reads high
  // or there is now motion
  if (val == HIGH)
  {
     if (pirState == LOW)
     {
       triggered = true;
       Particle.publish("designingiot/s15/motion");
       pirState = HIGH;
      setLED( pirState );
     }

   }

int buttonValue = digitalRead(button);
   if( buttonValue == LOW ){
     triggered = false;
}

   if (  triggered == true ) {
     tone(buzzPin, 400);
     delay(300);
     noTone(buzzPin);
     delay(300);
     tone(buzzPin, 300);
     delay(300);
   }

   else {
     if (pirState == HIGH) {
      // we have just turned of
      // Update the current state
      pirState = LOW;
      setLED( pirState );
    }
  }
}
void setLED( int state )
{
  digitalWrite( ledPin, state );
}
Click to Expand
0
Sensor + LED
Img e0424 1
0

The image above shows circuit connections with the sensor and the LED. The buzzer was added in the next step as shown in the image below.

0
0

The above video shows the buzzer going off after the sensor detects motion. In the next step a push button was added to start or stop the buzzer.

0
0

Reflections:

The project, although simple to begin with, required a lot of iterations  to make the sensor work correctly. What I assumed would be a straightforward program, became increasingly difficult with the addition of each element. The most interesting part was to make the sensor, LED, buzzer and push button work in relation with each other. The conditions needed to be precise to ensure that the LED and buzzer give the correct output.  It was interesting to relay the data via two outputs- one visual and one sound. The sensor was tricky to work with and needed quite a few adjustments to achieve accuracy.

In this project, the buzzer kept buzzing once it was triggered and would not stop unless the button was pushed. On releasing the button, the buzzer would go off again due to the first input.  To take this a step further, more functionality could be added if the buzzer could switch off on its own after a set duration. It would then be able to alert the user when motion has been detected again after some time.


x
Share this Project

Courses

49713 Designing for the Internet of Things

· 25 members

A hands-on introductory course exploring the Internet of Things and connected product experiences.


About

The Baby Motion Alert will detect when the baby is approaching the edge of the bed (any raised platform) and alert the parents/caretakers via a buzzer. The parents will then be able to rush to the room before the baby gets dangerously close to the edge.

Created

January 25th, 2018