Use Spark.io Photon to unlock a door over WiFi for less than $30!

Written by: admin@makezilla

Picture of Use Spark.io Photon to unlock a door over WiFi for less than $30!photo 2.JPG2.2K_resistor-500x500.jpg41zAJ51iK3L._SL1071_.jpg61SwfvInF4L._SL1001_.jpg61vaQSR7H6L._SL1500_.jpg

This instructable is based on the Spark.io Photon, a "postage stamp-sized hackable WiFi module for interacting with physical things." And thanks to its AWESOME mobile UI "Tinker," you won't have to write a line of code!

Its the result of an "Instructables Build Night," with Soha Smart; where I am also a board member and teacher.

We are going to control a 12V Solenoid using one pin from this Arduino based device.

Parts:

Step 1: Setup your Spark.io Photon

Picture of Setup your Spark.io Photon

New Device with Tinker Firmware

If you're just taking your Photon out of the box you're going to need to name your core. The easiest way to do this is on your mobile device (I used an iPhone). I'm not going to go over how do this, since Spark.io documentation is fairly easy to follow.

So, to get up and running go to http://www.spark.io/start/

Restoring Tinker (recommended for this project)

To restore your device to use the "Tinker" firmware please follow the instructions located at http://docs.spark.io/tinker/#tinkering-with-tinker-the-tinker-firmware

Step 2: Wiring the circuit

Picture of Wiring the circuitphoto 4.JPGphoto 3.JPG

Note: You're going want to setup your breadboard with a 12V rail (the side red and blue lines) and a 5V rail. The 12V is to run the solenoid and the 5V will power the Photon

Using a diode?

In the diagram, there is a diode parallel to the device we are powering. Any time you are powering a device with a coil, such as a relay, solenoid, or motor, you need this guy, and don’t leave home without it. What happens is when you stop powering the coil, a reverse voltage, up to several hundred volts, spikes back. This only lasts a few microseconds, but it is enough to kill our transistor. So this diode (only allows current to pass one way) is normally facing the wrong direction and does nothing. But when that voltage spikes comes flowing the opposite direction, the diode allows it to flow back to the coil and not the transistor.

...A transistor (TIP120) too?

Transistors are are 3 lead components that have 2 simple functions, to switch or amplify (this time it's setup as a switch). You basically have an "in" called theCollector, an "out" called the Emitter, and a "controller" called the Base. When you send a HIGH signal to the base (control pin), the transistor switches and allows current to flow from the collector (in) to the emitter (out).

So we connect it so that our solenoid is connected to V+ but not ground (V-). Ground is connected to the transistor’s collector. When our Photon sends a HIGH signal to the transistor’s base, it switches the transistor (connecting the collector and emitter) and completes the circuit for the solenoid.

We are using a 2.2K resistor to limit the current to the correct value to run the transistor.

Is the Solenoid pushy?

  • To setup your solenoid to "Pull" connect the GREEN wire to V+ and the BLUE wire to the transistor's collector.
  • To setup your solenoid to "Push" connect the GREEN wire to the transistor's collector and the BLUE wire to V+
  • Basically, reverse the wires if the solenoid is working in the wrong direction...

Step 3: Tinkering with "Tinker" and the Photon - Unlocking a door!

Picture of Tinkering with "Tinker" and the Photon - Unlocking a door!photo 2.PNGphoto 3.PNGphoto 4.PNG

Assuming that you can connect to your Photon from your mobile app. All that is left is to connect D6 in "Tinker" to write either HIGH or LOW.

Program Tinker:

  1. In "Tinker" tap on D6 and select "digitalWrite."
  2. Tap anywhere on the screen to confirm.
  3. Now tap on the D6 button. You should see the word "HIGH" next to the button indicating that the pin is "on."

Congratulations you just "Opened a door" with your Spark.io Photon!!! (assuming you attached the solenoid to a door's lock, that is...)

Step 4: Going further with your Photon!

Where do you go from here?

You might have noticed that the solenoid only either "pushes" or "pulls" based on how it is wired to the circuit. Creating an H-bridge within the current circuit will allow you to control both directions of the solenoid. Essentially, allowing you to "lock" AND "unlock" the door.

The possibilities are endless!

This instructable was a very simple example of what is possible with theSpark.io Photon. Check out the Documentation to see what your imagination can "unlock."

Leave a Reply