Use Spark.io Photon to Unlock a Door Over WiFi for Less Than $30!

by keithbrown in Circuits > Arduino

16101 Views, 82 Favorites, 0 Comments

Use Spark.io Photon to Unlock a Door Over WiFi for Less Than $30!

photo 1.JPG
photo 2.JPG
2.2K_resistor-500x500.jpg
41zAJ51iK3L._SL1071_.jpg
61SwfvInF4L._SL1001_.jpg
61vaQSR7H6L._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:

Setup Your Spark.io Photon

photo.PNG

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

Wiring the Circuit

photo 5.JPG
photo 4.JPG
photo 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 the Collector, 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...

Tinkering With "Tinker" and the Photon - Unlocking a Door!

photo 1.PNG
photo 2.PNG
photo 3.PNG
photo 4.PNG
Spark.io Photon Door Unlock over Wifi

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...)

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 the Spark.io Photon. Check out the Documentation to see what your imagination can "unlock."