Help needed with using spark core as a switch to control devices?

Hi Guys,
I just received my Spark hardware a few weeks back and now I claimed it and loaded my first program through wifi successfully. Here is my idea for a simple project. Can someone please guide me through with some tips and help.

I would like to use the spark core as a digital switch to turn a dc motor on and off over wifi. I have a dc motor with separate 12 V 1 A power supply and also have a separate 5V 1.2 A power supply for the Spark. Ideally I would like to activate the motor through the cloud. I am a hardware guy and can wire up the hardware with the spark without any issues. How do I control the Spark through the cloud to control the motor? I do have the Spark core app with tinker on my android phone and I am able to control the Spark from the same.

Any help to push me in the right direction will be appreciated.

Thanks,
Puddle.

1 Like

puddle​rocks, do you need the motor to turn in both directions? If so, you will need an H-Bridge motor driver. Otherwise, you have different options like a FET or power transistor. Pololu has some great motor driver breakouts like this one that can handle a single DC motor (bi-directional) up to 1A. :smile:

HI @puddlerocks

Have you looked at the Tutorial section of the forum yet? There is a lot of good information there.

I would think that you will need some high-current switching electronics or a relay as @peekay123 mentioned in his reply. Then you will need to write a sketch that has a Spark.function() that allows you to control your motor.

There are lots of ways to do the web side of this, but here is a simple way to get started. This example uses a tiny servo, but can adapt the same idea to a DC motor.

1 Like

Don’t forget about the relay shield!

http://docs.spark.io/#/shields/relay-shield

Hi Hypnopompia,
I want only binary operation. Either the motor will be on or off. Direction does not matter. I think a relay sounds like a good idea to me. What do you think? Can I buy the relay shield? The relay shield looks like an expensive option to me. Can I buy a relay for $5 from radioshack and run the motor. Since the motor is a 12V DC / 1A motor, the power requirements are not very high.
Are there other options?

Thanks
Puddle

@puddlerocks, yes you could just build a simple relay circuit using parts from radio shack. You’ll want to make sure you’re not directly controlling the relay from the spark core, as that could damage it.

Check out this tutorial. It’s for an arduino, but should work just fine with the spark core:

puddle​rocks, I still think the Polulu driver ($5) is a good solution since it does not require any extra parts. Hypnopompia’s solution is a good one also. You pick!

1 Like

Thanks @peekay123 and @Hypnopompia. I will look in to both solutions to determine which best suits my application.
One more thing…lets say i replace tge dc motor with a 12 V dc pump, will the approach change?

puddle​rocks, it all depends on the pump’s current requirements. The only thing I would say is a larger relay, perhaps like the one from radio shack, will switch higher currents whereas you will need a different Polulu module for higher currents.

DO remember though that the Spark outputs only 3.3V on its pins so a transistor circuit to drive the relay will need to be adjusted (specifically the resistor going to the base of the transistor) to correctly switch at the lower voltage.

1 Like