Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Nicholas BriereMark Spytkowski
Published

Christmas Lights Energy Savings

Ever worry about leaving your Christmas tree on all day while your away? Avoid costly energy bills with this photon setup.

IntermediateFull instructions provided2 hours661
Christmas Lights Energy Savings

Things used in this project

Hardware components

Photon
Particle Photon
×2
1N4007 – High Voltage, High Current Rated Diode
1N4007 – High Voltage, High Current Rated Diode
×1
LED (generic)
LED (generic)
×1
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
Resistor 221 ohm
Resistor 221 ohm
×1
General Purpose Transistor NPN
General Purpose Transistor NPN
×1
Jumper wires (generic)
Jumper wires (generic)
×8
Relay (generic)
×1

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Motion Sensor and Photon Diagram

The photon is attached to the PIR sensor, resistor and LED.

Relay and Photon Setup

The photon attaches to the relay via the 3v3 pin giving it power, and switches on and off remotely from the D2 pin. The relay shown in the diagram is the best fit for the actual relay used (JZC-11F could not be found). Can be fully built with parts from the photon maker kit. Best if assembled as seen in the photos above.

Code

Motion Event and Publish

Arduino
This code tells the photon that the PIR motion sensor is attached to the pin D0. Activity found in the pin from the after a 1 second (1000ms) delay will publish the event called "itschristmas".
int sensor = D0;

void setup() {

}

void loop() {
  delay(1000);
   if (digitalRead(sensor) == HIGH) 
   {
       Particle.publish("itschristmas", "itschristmas", PUBLIC);
   }
}

Light Switch Code

Arduino
After detecting the "itschristmas" event, this code allows the photon to tell the transistor to activate the relay switch. The delay keeps the lights on for a specified amount of time.
int transistor = D2;

void anything(const char *event, const char *data)
{
    
    digitalWrite(transistor, HIGH);
    delay(1200000);
    digitalWrite(transistor, LOW);

}
    
void setup() {
    pinMode(transistor, OUTPUT);
    digitalWrite(transistor, LOW);
    Particle.subscribe("itschristmas", anything);

}

void loop() {

} 

Credits

Nicholas Briere

Nicholas Briere

1 project • 0 followers
Mechanical Engineering BS Student
Mark Spytkowski

Mark Spytkowski

1 project • 0 followers

Comments