Server Sleepuntil and cutting power to the 3.3v pin on an April Board

I have a project running an imp001 in an April board. Connected to the 3.3v and GND pins are four sensors, two act as emitters and have a “Current Draw: 10mA @ 3.3V” and the other two have “Output Current Capability of receiver: 100mA sink”; they all work together as break beam sensors.

Powering the project are four AA batteries and to conserve power I put the project to sleep for 16 hours a day with a call to the server.sleepuntil command. Everything works fine but even though the imp001 goes into sleep mode I have discovered that the sensors are still are drawing current from the 3.3v and GND pins.

Is there a way that when the imp001 goes to sleep that the power is cutoff to the 3.3v and GND pins, cutting power to the sensors, and connected again when the imp001 wakes up? This could greatly enhance batter power longevity. Right now the batteries are lasting about 10 days because of the 24 hour day draw by the sensors.

I would guess a transistor or mosfet to turn the sensors on and off would do the trick. Turn them on as the first thing when the imp wakes up, turn them off before telling the imp to go to sleep.

At 10mA it should be pretty easy to find a transistor capable of driving them.

What are you using the sensors for? I am going to play around with some soon™, but mine must be on all the time to detect if the beam is broken.

I am using them in a door opening. When the imp is on they are serving as a break beam too.

Any ideas on how to wire the transistor into the scheme of things with the April?

The sensors are literally wired to the 3.3V and GND and Pins 5 and 9 are used to detect if the beams are broken.

In this I use a relay, but instead you can just attach the sensors instead of the relay, and you can then most likely also leave the fly-back diode out.


I received my Transistor (2N3904) from Sparkfun today. I wired the device as you described but replacing the relay with the positive and negative wires from the sensors. When I commit the hardware.write(1) in the device code the voltage drops to 0 and so the sensors never get any power. Bottom line it is not working. Is the 2N3904 capable of doing a power on/off. Any ideas?

How do you have this wired?

The suggestion from MikeyDK is a low side drive: the collector of the transistor gets yanked hard to GND when the base is driven high. This means you put the transistor in the ground lead of the sensor. The positive supply pin of the sensor is tied to 3.3v.

When the transistor is off, no current can flow from 3.3v, through the sensor, to ground and hence the device is essentially off (you should see near 3.3v on both lines going to the sensor). Don’t panic about 3.3v on the negative line - the important this is that the positive pin is the same as, or more positive than, the negative pin.

Hugo and MikeyDK, Thank you for the help so far. I’ve attached a Fritzing schematic (first attempt, sorry if it’s not the best) that shows how I have this wired up, I’ve tried it a few different ways but this is the last iteration. Referring to MikeyDK’s relay example I don’t see a ground coming from the relay where as I have a ground coming from the IR receiver.
I’d appreciate any help wiring this so that the IR sensor and LED go to 0v when sleeping for a minute to conserve battery power.

Here is the device code:

hardware.pin9.write(1) //Turn on sensor
agent.send(“impValues”, pinValues);
hardware.pin9.write(0); // turn off the power to sensor



From what I can see, the LED is the wrong way round (generally, the bigger bit of metal visible inside the LED case is the cathode, ie negative), and you have no current limiting resistor for the LED, which is likely causing the IR sensor to not get the full 3.3v (the LED will be conducting with ~2v if it’s a red one, which as it’s directly across the sensor, will mean the sensor is only getting 2v which may not be enough for operation).

So: add your current limiting resistor (say 1k) in series with the LED, turn it around, and verify that the LED turns on when you write pin9 to 1 and off when you write pin9 to 0. That will validate that the transistor is wired correctly and working fine.

The next issue is that your device code does not appear to be reading the sensor after turning the power on - it’s just sending the value of the pinValues variable without updating it. You may want to have a small delay after turning power on (for the receiver to stabilize), read the data from it, turn the sensor power off, THEN send the data you collected.

There’s no point in powering the sensor for any longer than necessary, and that includes the actual sending of the data. It only needs to be powered on when collecting data.

Got it to work! Thanks for all of your help.