Good morning

Made by Sid Suri

Make your mornings more pleasant. The device, detects people moving around in the living room to switch on the home audio system. A built in time function, ensures its only triggered in the mornings.

Created: January 29th, 2016



I live in a 3 storied house with 2 other room mates. Our bedrooms are upstairs, while the living room is downstairs. We strive to create a communal environment in spite of our busy lifestyles. Every morning we're rushing through our routines to make it to class on time. Although we'd like to listen to music in the morning, we rarely pause to put on a song from our phones. Playing music also brings the entire home alive in the morning, inducing other to begin their day, instead of lounging in bed. The device detects motion in the living room during mornings, to trigger the music system.


I use a PIR motion sensor, to detect motion and publish an event to the Particle cloud. The device has some preconditions, to make sure it is only activated during morning hours. An IFTTT, recipe is used to link the event, to android play music action. IFTTT can also be used to trigger an action with other music services (Spotify, Bang & olfsen, etc).



Stuff I used:

1. PIR Sensor - HC-SR501

2. 2 LED's - Red, Yellow & appropriate resistors

3. Two way switch

4. Jumper wires

I use a switch to disable the device. A red LED indicates the switch position (ON/OFF), the yellow LED will blink every-time motion is detected.

Initially I tried to write my own code from scratch, but due to the structure of the program and inexperience with setting up variables, I failed to get any output from the motion sensor. Eventually I switched to using Daragh's code at:

This got the LED blinking every time it detected motion, which was a little too often.

I modified this code using the built-in time function within particle. An additional trigOK() function, makes sure it is ok to publish the event. By setting up an additional variable trigT, to record the time of trigger using I also added the IF condition to check that motion had not already been triggered in the past 60 mins. Another IF condition checks that the current time is between 7-11 AM, Time.hour() .

//I modified the main loop to check, that it's ok to play the song

void loop(){

  // if the sensor is calibrated
  if ( calibrated() ){
    if ( trigOK() )
        // get the data from the sensor

      // report it out, if the state has changed
// The bool trigOK returns TRUE if, the time is between 7-11AM &
// the motion was never detected, or detected more than 3600 seconds ago.

bool trigOK() {
  if (Time.hour()>=7 & Time.hour()<=11){
    if (trigT==0) {
    return cantrig;
    } else if (trigT >= ( -3600 )){
    cantrig = FALSE;
    return cantrig;
    } else {
    cantrig = TRUE;
    return cantrig;
  } else {
    cantrig= FALSE;
    return cantrig;

// Within the motion detected function, I added the ability to record trigT

  if (pirState == LOW) {
      // we have just turned on
      trigT =;
      // Update the current state
      pirState = HIGH;
      setLED( pirState );
Click to Expand


I was successfully able to trigger my phone to play Lithium (Nirvana), by walking near the motion sensor. The motion sensor can be placed horizontally or vertically, providing a lot of possibilities in it's placement and encasement design. While the Yellow LED would blink every time, motion was detected, I had trouble getting the Red LED to stay on, I assume this is because it doesn't have enough voltage.

 Ideally the device should trigger a radio channel on the Sonos system in our home. Due to the limitations in the IFTTT action portfolio, I could only play a specific song within my device.

A great deal of programming has to be customized depending on the final source of audio. The Sonos controller for example can only be played via an android device.



Most home audio equipment don't support IFTTT. Ideally I would've loved to link up our Sonos system, or Chromecast Audio to IFTTT, but neither of them have any IFTTT integration at the moment. Also once motion is detected, it takes upto 15 sec, for the device to play the song.

It took me some effort to figure out the correct way to use the time function within particle. Figuring out the structure of the trigT, and trigOK took a while, I literally had to sleep on it.

I tried to write my own version of diagnostic tool to check if the motion sensor was working (LED + Serial monitor), I still don't know why my version did not work. One missing part from my code was the calibration time. Unfortunately I did not save my version, so I can't go back to compare, and learn from the errors.

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

Make your mornings more pleasant. The device, detects people moving around in the living room to switch on the home audio system. A built in time function, ensures its only triggered in the mornings.