Christmas Lights Energy Savings

0 42021 Medium

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

Christmas Lights Energy Savings

Things used in this project


Hardware components

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

Hand tools and fabrication machines


Soldering iron (generic)



It's December 24th, Christmas time is near!


But you won't be celebrating Christmas day here.


You're going to visit your grandmother Ethell.


Surely this Christmas is going to be special.


You run out of the house too eager to stop.


Oh you forgot to turn the Christmas tree lights off!


No need to worry, these lights have your back!


For this is the ultimate holiday hack.



The Automatic Christmas setup allows you to no longer worry about manually turning the tree lights on and off. Upon activation, the lights will turn on for a set amount of time and automatically shut off after. It's easy to forget to turn the Christmas tree lights off which can do a toll on your energy bill through the holiday season.


Below is a graph of the motion sensors ability to read and send movement data to the photon. The photon was mounted to the wall near the lights. When people are in the area, the photon publishes the "itschristmas" event. The graph also shows the intensity of the motion detected. The bars up to ten show motion that was close to the sensor, and shorter bars resemble distant motion.


Motion vs Time

Motion vs Time


If the motion has already been detected recently, it resets the light timer for 20 minutes (adjustable via code). After a designated period of time without motion the lights will turn off. With an approximate range of 10 meters, the PIR sensor should have no problem keeping the lights on with people in the room. Even Santa can't trick this device,








Above are 3 photos showing key elements of this project. The first is the Photon attached to the PIR motion sensor. The sensor was taped to the door so motion would be detected upon entry. The code used by this photon publishes an event called "itschristmas" whenever motion is detected.


The second photo is the photon that is programmed to subscribe to the "itschristmas" event. When triggered the photon will activate a relay, switching the Christmas tree lights on. The relay is powered by the 3V3 output of the photon, and the transistor acts as the switch for the device.


The last photo shows how the device was rigged to work with the Christmas lights. The Christmas light wire was cut and soldered to the ends of the wires attached to the relay. This gave it a full connection to the circuit and enabled the switch to control the lights. Any exposed areas are then covered with electrical tape or an equivalent insulator. The lights are plugged into the wall as normal. The circuit diagram for the relay module should use an SPDT 5V relay (JZC-11F) that comes with the particle maker kit.



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.





Motion Event and Publish


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() {
   if (digitalRead(sensor) == HIGH) 
       Particle.publish("itschristmas", "itschristmas", PUBLIC);

Light Switch Code


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);
    digitalWrite(transistor, LOW);

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


void loop() {


The article was first published in hackster, November 24, 2017


author: Team Easily The Best Group: Nicholas Briere, Mark Spytkowski

All Rights