Here I am at TechShop with an amazing micro controller from Spark.io called "Core". I was planning to use an Arduino to control my saltwater reef aquarium when a friend showed me the Core. This powerful little micro controller is as easy to program as the Arduino (in fact you can cut and paste Arduino "Wiring" code) but has an ARM Cortex M3 processor and a built in wifi radio. You probably have an ARM design processor running your smart phone. The wifi attaches through the cloud and allows you to find and control your Core from anywhere on the internet. If this wasn't enough, they provide an easy pre-made interface to the pins on the Core called "Tinker." Tinker is also customizable and there are other powerful ways to design custom interfaces. Decision made --- I am using the Core!
Step 1: The Core at Techshop
I am going to incorporate lighting control, pumps for various fluids, temperature, pH, ORP, feeding, water level, and Wave and circulation pump control all from the Spark I/O controller. I travel in my job and I will be able to view status and control the tank from another city. I will break this down in stages. This instructable will be limited to lighting control.
I could start by taking an aluminum bar, masking it with tape and painting it -- but remember I'm at TechShop. I will first sandblast the bar, cut out a Kapton tape mask with the laser and powder coat it. How cool is that. TechShop is like an adult playground with all the cool toys you wish you had at home.
Step 2: Lasercut Kapton
I am using LEDs that need a heat sink. I chose an aluminum bar 1/2" x2"x 48" which I purchased from Metals4U in Austin,Tx for about $19 local pickup. I sandblasted the bar at Techshop in prep for powder coating. The LEDs are hexagonal shaped, so I cut out a mask of 1/2" Kapton tape (Ebay for $4, local prices up to $100 -crazy right?) on the laser in the shape of the LEDs. Kapton withstands 100s of degrees of heat. I used a piece of paper to hold the kapton tape and to make a template to place the masks on the bar. I later found you can place the tape directly on the laser. If I did it again I would make the pieces connect in 1 long strip for easier placement and removal. I placed them on the bar in prep for the powder coat
Step 3: Powdercoat
I shot the bar with bike black powder coat from Lowe's. The Austin-Roundrock TechShop is actually connected by a glass door to Lowe's. How convenient is that? Lowe's puts commonly used TechShop materials next to the Techshop door for quick service. I put the bar into the powder coat oven until the powder flowed. I then removed the tape and replaced the bar to finish curing (about 20 min.)
I used hexagonal LEDs made for mounting with screws. I had so many I decided to use a combination heat sink compound and adhesive known as arctic silver alumina I bought for $8.99 from Altex electronics in Austin. It worked great. They are 3 watts, different spectra (6500k, 20,000k, blue,uv) about $15 for 50 on Ebay. I arranged a staggered layout every third position to get even distribution in 2 rows. I soldered + to - pads in series in a string 6 LEDs long.
Step 5: The Core
Now let's power our Core. The website explains how to register and connect your Core. My TechShop group all used PCs so I decided to use a MAC just to show it can be done. Just download the software and follow the instructions to register your Core. There are several ways to do this. I downloaded the Spark app in my iPhone. Go to the app store (or Google Play for Android) and get the app. Follow the directions to install and register the app and connect to your Core on the same wifi as the Core. It will then connect you to Tinker, the default app on the Spark Core. It is layed out just like the pins on your Core. If you get lost, when you do a factory reset it defaults to Tinker.
Step 6: Power
My setup needs 24volts. My intention is to use 2 old computer power supplies in my junk pile. You cannot simply hook them in series. There are instructables to do this. For demo purposes I am using 2 gel cell batteries I had laying around. I connected the + of 1 battery to the - of the other. My 24V comes from the end terminals of each battery as depicted.
Step 7: LED Driver (constant current buck regulator)
LEDs need limited current or they will burn out. You could use a resistor, but this uses more power and may be less reliable than a constant current buck regulator you can buy on Ebay for about $1 to $1.50. I use one that can take up to 30 volts input and provide 700ma constant current. The LEDs are 3-3.6 volts. In series you add the voltage, so 6 LEDs in series could take 21 volts or so. The regulator will manage a small over voltage and provide constant current. My LEDs require 350ma so I hooked 2 chains of 6 in parallel. In theory this should divide the current equally. In practice, if there is a difference in resistance between the 2 legs, more current will flow in the lower resistance. Heat is the real enemy and I have overkill on the heatsink. It would be better to use 1 leg only with a LED regulator (driver) rated at 350 ma.
The two terminals on the left are for power input (24v in my case). The three on the right are for regulated power out to the LED strings. The one in the center is for PWM (pulse width modulation) signal. This will turn on the string if "high" (+5V) or turn off the string if "low" (0V). If you "modulate" or change the on time vs. off and cycle it rapidly you can get the effect of dimming the LED. If it is on 50% of the time and off 50% of the time, you will get half dim intensity. The Spark.IO Core provides this kind of signal on the analog pins and 2 of the digital pins. It is known as PWM or "pulse width modulation." If the speed of the cycle is over 120 Hz (cycles per second), the flicker will not be noticeable.
Step 8: Power relays
You could skip this step altogether if you wanted to turn off the LED strings by setting the PWM to a 0% duty cycle and applying power all the time to the regulator. I decided to do it this way to show you the power of these relays. They can switch line voltage at 120V or even 250V AC at 10 amps or switch a lower voltage like 12V DC. This could be used for Christmas lights, Water pumps or anything else you want switched on and off. I bought a pre-assembled set of 8 relays on Ebay. They were $6.99 at the time made by Sain Smart. They also have solid state relays that can switch faster. I suspect those are zero crossing devices that require an AC signal or pulsing DC signal that crosses 0V before they will switch. These mechanical relays do not require this. They are optically isolated. This means that the high voltages on the output are not electrically connected to the Spark.IO Core. A beam of light internally triggers them. Just hook up the digital signals to the channel inputs of the relays and the +5V and ground and the Core will switch them on and off. A small LED for each channel shows their status. You also hear an audible click when they switch.
Step 9: Relay input side
I used female jumper wires on the relay input side. I only had female to female jumpers and male to male. In the prototype, I used them together. In the final product, I will cut the female-female in half and solder the loose ends.
Connect "in1" on the relay to D0, in2 to D1 etc. (the numbering on the relay begins with 1, the core begins with 0. do whatever you like). Then connect the Core to the relay pins+5 to Vcc and GND to GND pins.
Step 10: Test with Tinker
Open the Spark app on your phone. Make sure you are connected with your Core. You should see the name you gave it at the bottom of your screen. Touch the D0 pin. A menu will pop up to assign it a function. Choose digital write. Do the same for D1 and as many digital pins as you have LED drivers. Touch the A0 pin and assign analog write to it. This will enable PWM. Now touch D0 again. It should switch the in1 channel on the relay. The LED should come on and you should hear a click. Click again to toggle on/off. Do the same for D1. If it works, proceed.
Step 11: Relay output side 24V
Then hook up the +24 directly to the + leg of the LED driver. The ground goes to the relay on channel 1 to the pin without the switch in the diagram. The center switch of the relay goes to the - LED driver terminal.
Step 12: Hooking up the led strings
Now connect the + driver output to the + LED wire and the - driver terminal to the - LED wire. Now connect the center pin to the analog A0 pin of the Spark.IO Core. On the next driver connect the A1 pin to the center pin and so on.
Step 13: Do it!
Now you are ready. Go to the Spark tinker app and touch D0. The logic is seemingly reversed, high is off, low is on. The light should come on. Touch A0. A slider should appear. Drag it and let go. The lights should dim. Do the same for D1. That is all for this instructable. Next would be to supply automatic programming, realtime clock interface, pumps sensors etc. Enjoy!