My imp device is supposed to control the heating remotely. I use a relay to switch 12V and not surprisingly the 9V battery lost 30% charge in less than 24 hours. That’s not great! I’m thinking about getting a power bank for charging mobiles. The one I saw is a 3Ah one. Since the relay is rated at 0.36W consumption, with 5V I get 0.072A current. Does that mean that a 3Ah (or 3000mAh) battery can provide current for about 41 hours (battery Ah/relay current)? If so, how do I calculate the consumption of the Imp? How could I improve the power efficiency of my imp? I don’t mind if the device wakes up every 10-15 minutes for only a few second if it means much less electricity consumed.
imp.setpowersave(true);
if (imp.getpowersave())
{
server.log(“This imp is set to power-save mode”);
}
else
{
server.log(“This imp has disabled power-save mode”);
}
function setLed(ledState) { //server.log("Set LED: " + ledState);
if(ledState == 0) {
stillOn = true;
server.log("pin state "+led.read());
timer0(); //server.log(“timer”);
server.log("pin state "+led.read());
}
else {
stillOn = false;
led.write(0); //server.log(“OFF”)
server.log("pin state "+led.read());
}
}
function timer0(){
if(stillOn) {
led.write(1); //on
imp.wakeup(5,timer1);
}
}
function timer1(){
if(stillOn) {
led.write(0); //off //imp.deepsleepfor(5)
imp.wakeup(5,timer0);
}
}
I second Peter on latching relays, in fact I suggested it to you yesterday It does take two imp pins to drive, but its power consumption is zero except while changing state.
If you are running the imp off 9v battery, where is the relay getting 5v from? Perhaps it isn’t yet, that is the plan. If you are dropping the voltage with a regulator, make sure you use a switching reg to keep power efficient.
When it is on, the relay looks just like a resistor, so the more voltage you drive it with the higher the current, power consumption increases as the square of the drive voltage. Start with the rated drive voltage, don’t go higher, in fact you could experiment with lover voltage drive to get reliable operation. Then measure the current and that tells you how long that battery is going to last from the battery’s rated mAh.
Glad to hear you are moving to latching! Believe me, you will not need a tank of juice for that, it just sips. It takes power for 20msec to set (ON) and then for 20 msec to reset (OFF). Mine also works with 10 msec. Example:
`// pin 9 is relay SET output
rly_set <- hardware.pin9;
rly_set.configure(DIGITAL_OUT);
Definitely a transistor for each pin, plus the resistor and diode. If you were using a MOSFET then the resistor could be left out since the gate current is zero, but a bipolar transistor needs a resistor to set a base current.
Be careful whether you get a single coil or dual coil relay, both types exist and I recommend dual coil. Dual coil means one coil to set the relay and one to reset it, easy to drive with two imp pins and two transistors. The other type has a single coil, and you give a current pulse one way to set and the other way to reset. The still needs two imp pins, but it needs four transistors in an H bridge arrangement and four clamping diodes, so is considerably trickier to drive.
And the “latching relay kit” on eBay has just the right sort of relay with the transistors and resistors and diodes on a neat pcb, and you can drive it from 3.3v or 5v.