Connect Wi-Fi socket & plug to App

Hi there,

I am new in the Spark world, and as mechanical engineer I am afraid that I do not have enough formation in electronics. However, I am really excited about all these stuff ! It’s seems magic to me.

So my idea is to create a mobile application to control the lights and sockets in my house. I am pretty sure that there are already many topics about these in the community. Unfortunately, most of them, they only broach code. So, I will need more information concerning the electronic part.

For the moment I deal to switch off & on a light with a Spark core + spark relay (not a big deal, I agree…). Even if this is basically what I need, I will like to meter my consumption as well (and send to the App). How can I do that ? What electronic part I need to buy ?

Thank you for your help in advance !

You get the idea! Relays will be required to on and off power to your appliance.

As for monitoring, you probably need to monitor just the current since the voltage level doesn’t fluctuate too much.

You have 2 options for this:

1.) Non invasive current sensor

2.) Invasive current
sensor

4 Likes

Hi kennethlimcp !
This is really useful ! I think I will better choose the invasive current sensor as long that I would like to do it compact. Thanks !

1 Like

Hello again !
I learnt that that I will need a PWM for fading a LED bulb. Do you know if there is something already done ( I did a quick research in sparkfun but I didn’t find nothing…) so I can just connect to the Spark core ?

I look the SPARK socket block diagram and I saw that the LED is dime with TRIAC. Is it a kind of PWM ? What about the zero cross detection, what’s dois it do?

Thanks in advance.

Traics are devices which are essentially AC switches. “Dimming” is achieved by cutting off a portion of the AC sin wave depending on how “Dim” you want it. Ie, if you cut off 50% of the wave then the light will be “Half” as bright.

The zero cross has something to do with the fact that the triac cannot turn “ON” until the voltage has returned to 0 (ie, when the AC sine wave goes from positive to negative or negative to positive). It can turn “OFF” at any time however.

Does that make sense?

When you mean half of AC wave, you mean to have half of voltage as long as the amplitude of signal is the voltage. Am I right ? Anyway, I thought we use to variate the current and not the voltage for dim the light with conventional bulbs. Then, I learnt that this is not use for LED bulbs. For LEDs bulbs we should variate the frequency of current , so pulse it (PWM). LEDs works well with the max of voltage and current, so we should not “cut” the voltage.

All these are supposition I did :confused:

Back in “the day” some dimmers worked by varying the resistance on the line. This effectively limited the current. More modern dimmers vary the average voltage using a triac to cut part of the wave out. If I remember correctly this was actually one of the reasons LEDs couldn’t be dimmed early on, they didn’t like either method of dimming.

If you are interested in reading materials I suggest you take a look at:

It looks like I might have had it backwards. They can turn “off” at the zero crossing but “on” anytime

1 Like

Hi,

So if I understand well, I just need to buy a Triacs and connect it between the Spark Core and my bulb, so I am able to dime now ?

Does this work ?

Thanks in advance.

@AmaiaUSC, this might be a good reading material as well: https://github.com/spark/socket

1 Like

Thanks for the reading ! But I confess, I am lost. I was looking the “High Voltage Schematic” of Spark Socket and I still dont know what I need to buy. So I went to Arduino site and found this:

http://arduino.cc/en/Tutorial/Dimmer

So I can dimme my dimmable LED bulb just with code ?

Thanks,

@AmaiaUSC, that example uses a simple led and works great!

But yours is an array of LED bulb with circuitry and the common application is to hook up to the main of 110/220V. This is a different scenario in terms of dimming.

Can you post the link of the LED bulb you are using or attempting to interface? We can take a look and suggest a solution! :smiley:

1 Like

It sounds like he wants to build his own Spark-powered Triac for dimming AC circuits (110/220V). I imagine the triac he posted would work but if he wants to control anything of an reasonable size he would need a larger triac and I would want to optoisolate it to keep the spark far away from mains voltage.

1 Like

Hi guys !

Thank you for your availability !
@harrisonhjones you should said “she”, I am a girl :wink:

So I just connected a Philips HUE dimmable LED bulb tu my Spark relay shield so far… I use my phone with Tinker to switch ON / OFF the light.

As I said, the aim of my project is to remote control my lights, meter my consumption (with invasive current sensor) and dimme the light.

1 Like

Sorry for the mistake. Wasn’t trying to assume anything; I just think using the singular “they” is strange and he/she is awkward.

I’m glad the LED on/off worked well.

There are libraries to read both invasive and non-invasive current sensors for AC. I haven’t done any calculations but I am worried that the time required by the core to maintain the cloud connection might make accurate current calculations impossible but again, that’s just a hunch. I imagine it might take a secondary processor (probably something tiny) that offloads the current calculations from the core.

Hi,

I didn’t realize that I could find this problem of the core to maintain the cloud connection. I think the best thing is to buy the composant and see :slight_smile: I’m going to make a list about all the stuff I need to buy (shipping cost & taxes).

I will like to power the relay (9 V DC) and the core directly from the outlet power. So I was looking for a compact power converter. But I am afraid that I’ll need two actually : 230 AC -> 3.3 DC (core) and 230 AC -> 9 DC (Relay). Am I correct ? Do you already know this kind of stuff?

Thanks!

You can go from 9VDC to 5/3.3VDC using a voltage regulator (7805 for example). Seeing as the Core takes either 3.3VDC or 5VDC, you can choose which is more convenient for your other attached ‘things’.

1 Like

Hey Amala,

As @Moors7 said: you can purchase, fairly cheaply, a power supply that goes from 230VAC to 9VDC. From there you can regulate down from 9VDC to 5VDC.

What relay are you using? You might want to try to find a AC relay with a coil voltage (control voltage) or 5 or even 3.3V that way you only need the onboard regulator on the core!

1 Like

Hi again,

I was actually thinking to use a AC relay, something like JS1-5V-F, the one used in the Spark Relay Shield.

Where can I buy the voltage regulater Moors7 talks about ?

Thank you guys!

You can get those pretty much everywhere. They’re commonly used in many items, and a simply Google search should lead to to your most convenient supplier. Sparkfun and Adafruit should have them or sure.

1 Like