Yes, I initially tried to hold the relay signal high until my Spark App could do so. And I could not because I did not realise the relay signal needs not only voltage but also some current i.e. 3mA. My resistor was 10K. I need 1K or less but never tried anything that low.
So I followed @mstclair87’s suggestion - the 2N2222 worked a treat. It also allowed me to invert the code to something which seemed more intuitive (to me!) HIGH = ON and LOW = OFF.
But I will try the other way, with a 1K or 470R resister instead of the transistor, just to see if it works, when I get back home Tuesday. [I couldn’t get them to work either.]
I agree the coil resistance is quite low and your estimate of 100R is right - 33mA is being drawn from the 3v3 pin. On Tuesday I will move that to the Vin pin. Interestingly the mini-spec of the relay on eBay said it only drew 15-20mA.
In my hacking around, I’ve discovered that having the relays turned on by default is very useful for debugging. When I see the lights turn on and then off, I know my Core has finished flashing and rebooting. Gosh that’s handy when it’s inside a black box!
I use Spark.publish( progname, __TIME__)as that gives the compile time - so then I know I really am running the latest version. Also, you could flash the LED on the Spark in the setup().
I just got the 8 channel version of this board today. It’s very annoying to have the input reversed. I’ve tried 10k, 1k, and 470 pull up resistors, but they don’t help.
I did get the NPN inverter working but with 8 channels, that’s a lot of transistors. Is there another way to invert all 8 channels?
There is also another similar thread where I suggested a way to try to force the outputs high at power-up (well, tristate-on, really). The problem is there is always time between pinMode(D0,OUTPUT); and digitalWrite(D0,HIGH); so there is always a brief time when the output is low. The untested idea is to directly write the output pin to high before calling pinMode().
I’m in the same situation like @psb777 with the same relay. I see the solution is to use a 2N2222 transistor suggested by @mstclair87.
My question would be. Is there a difference between digitalWrite (D0, HIGH) and digitalWrite (D0, LOW) in terms of battery consumption, if we consider HIGH = OFF and LOW = ON for this relay?
Because in my case most of the time would be digitalWrite (D0, HIGH) = OFF (relay)