When you stumble in the dead of night and struggle to find the light switch. Fortunately for you there is one right by the door, but what about the light in your bedroom that you always trip over something to get? You can sleep on the couch or when you turn the light switch on that is right by the door, it illuminates your pathway to the comfort of your bed.
The code for Photon 1 uses a publish function to upload its current status of the kitchen light to the particle console. It reads either intact or broken, where intact means that the kitchen light is on, and broken means that the light is off.
The Photon 2 uses a subscribe function that reads the particle console and changes the state of the bed room light.
Our first Photon setup is comprised of a mini-breadboard, Particle Photon, 220 ohm resistor, photoresistor, LED light and wires. The LED light is connected from DO to GND on the photon. The resistor is connected from A0 to GND and the photoresistor is connected from A0 to A5.
Our second photon setup is made up of a mini-breadboard, relay, photoresistor, particle photon and wiring. The photoresistor is connected from A0 to A5. A grounding wire is connected from A0 to GND. The red and yellow wires shown below are connected to D0 and D5 on the photon, and lead to the relay. The lamp is hooked into the Normally Open (NO) terminal of the relay and finally connected to a wall outlet.
Lamp connected to relay and wall outlet
This graph shows the switch of the 2nd photon vs. time. 100% is light on and 0% is light off.