William FederowicMatt Gore
Published © GPL3+

Energy Saving Outdoor Lights

Will allow for you to have your lights on when you come home at night, but not waste energy and run up the power bill while unneeded.

BeginnerWork in progress2 hours971
Energy Saving Outdoor Lights

Things used in this project

Hardware components

Photon
Particle Photon
×1
Relay (generic)
The relay we used was a JZC-11F relay. It is the generic relay that comes with the maker kit from Particle.
×1
General Purpose Transistor NPN
General Purpose Transistor NPN
The specific number of the transistor we used was S9013. It also is a general purpose transistor that comes with the maker kit from Particle.
×1
LED (generic)
LED (generic)
The LED bulb used was actually an LED light bulb so we could run the light our 12 volt battery. The tungsten filament was too much resistance for the small current.
×1
House light fixture
×1

Software apps and online services

Particle
The standard Particle app that allows you to control your photon, etc, via your phone. Includes Tinker.

Hand tools and fabrication machines

Pocket Knife

Story

Read more

Schematics

Transistor amplifier circuit

This circuit was used to power the relay. The transistor stepped up the voltage so the particle could power it.

Code

Relay controlling photon code

C/C++
This code was flashed to our photon controlling the relay and publishing the data to the cloud.
int relayon = D0;

int onsensor = A0;

int onValue;

int offValue;

int lightThreshold;

void setup() 
{

pinMode(relayon, OUTPUT);

Particle.function("checklight", checklight);

Particle.function("flipswitch", flipswitch);

onValue = 1100;

offValue = 20;

lightThreshold = (onValue + offValue)/2;

}



int checklight(String command)
{
    if (command == "checkstatus");
    {
        if (analogRead(onsensor) > lightThreshold)
        {
            Particle.publish("on");
            delay(5000);
        }    
        
        else
        {
            Particle.publish("off");
            delay(5000);
        }
    }
}

int flipswitch(String command)
{
    if(command == "changelight");
    {
       if(analogRead(onsensor)< lightThreshold)
       {
           digitalWrite(relayon,HIGH);
           
           Particle.publish("turnon");
       }
       else
       {
           digitalWrite(relayon,LOW);
           
           Particle.publish("turnoff");
       }
    }
}

Subscribing photon

C/C++
This is the code we flashed to the photon inside the house with the LED. It is subscribed to our first photon and publishes to If This Then That.
int relayon = D0;

int onsensor = A0;

int onValue;

int offValue;

int lightThreshold;

void setup() 
{

pinMode(relayon, OUTPUT);

Particle.function("checklight", checklight);

Particle.function("flipswitch", flipswitch);

onValue = 1100;

offValue = 20;

lightThreshold = (onValue + offValue)/2;

}



int checklight(String command)
{
    if (command == "checkstatus");
    {
        if (analogRead(onsensor) > lightThreshold)
        {
            Particle.publish("on");
            delay(5000);
        }    
        
        else
        {
            Particle.publish("off");
            delay(5000);
        }
    }
}

int flipswitch(String command)
{
    if(command == "changelight");
    {
       if(analogRead(onsensor)< lightThreshold)
       {
           digitalWrite(relayon,HIGH);
           
           Particle.publish("turnon");
       }
       else
       {
           digitalWrite(relayon,LOW);
           
           Particle.publish("turnoff");
       }
    }
}

Credits

William Federowic

William Federowic

1 project • 1 follower
MEGR 3171 student at UNCC. My hackster page is for our project for the semester.
Matt Gore

Matt Gore

1 project • 1 follower

Comments