You can save battery power! Instead of providing continuous power to your sensors, use an Arduino (or any microcontroller) to only provide power when you take a reading from a sensor. It is really quite a simple technique known as Power Rail Blocking. Power Rail Blocking involves providing power to a sensor (or other device) via a digital pin. The digital pin is set to HIGH when a sensor reading is taken and then set to LOW for the rest of the time.

A simulation of Rail Power Blocking was made using the amazing and wonderful 123D Circuits: https://123d.circuits.io/circuits/1717500-power-rail-blocking-with-an-arduino/ I can’t praise 123D Circuits enough! 123D Circuits even allows you to enter Arduino programming code.

In the example below, an Arduino is providing a fixed 5V to power a light sensor. The light sensor is made with a wheatstone bridge and a comparator. 2.7k Resistors, a photoresister (LDR) and a 741 Op Amp are used.

Wheatstone Bridge and Comparator Simulation Setup

The Arduino is programmed to read the input from the comparator and if a HIGH input is received (i.e. the photoresister is illuminated) then turn the LED attached to PIN 12 on.

// Use Pin 12 as a LED to Indicate a Reading from the Comparator

int led = 12;

// Use Pin 8 to as input from the Comparator

int comparator_input = 8;

int val = 0; // the setup routine runs once when you press reset:

void setup() {

// initialize the digital pin as an output.

pinMode(led, OUTPUT);

// initialize the digital pin as an output.

pinMode(comparator_input, INPUT);

} // the loop routine runs over and over again forever:

void loop() {

val = digitalRead(comparator_input); // read the input pin from the comparator

if (val == 1)

{

digitalWrite(led, HIGH);

}

else

{

digitalWrite(led, LOW);

}

delay(1000); // wait for a second

}

Running the example as a simulation is 123D Circuits, provides a slider to change the brightness of the photoresister. Two voltmeters are attached — one shows the voltage across the wheatstone bridge and the other the output of the comparator. When no light is received by the photoresistor, the voltage across the wheatstone bridge is 2.42V and the output of the comparator is 0V.

Voltage Readings with a Covered Photoresistor

When the photoresistor is illuminated (i.e. fully bright), the voltage across the wheatstone bridge goes negative, the comparator outputs 5V (HIGH) and the LED is turned on.

Voltage Readings with an Illuminated Photoresistor

In the example above, we are however always providing the wheatstone bridge with 5V. In order to save power, we can use a digital pin to power the wheatstone bridge and only turn on the pin while we take a reading from the comparator. In the Arduino code below, pin 7 is used as the pbrail. In the loop routine , pbrail is turned on for 10ms, the comparator input is read, the LED is either turned on or off depending on the photoresistor illumination and then there is a 1 second delay before the loop is repeated.

// Use Pin 12 as a LED to Indicate a Reading from the Comparator

int led = 12;

// Use Pin 8 to as input from the Comparator

int comparator_input = 8;

// Use Pin 7 as the Power Rail for the Wheatstone Bridge

int pbrail = 7;

int val = 0; // the setup routine runs once when you press reset:

void setup() {

// initialize the digital pins as output.

pinMode(led, OUTPUT);

pinMode(pbrail, OUTPUT);

// initialize the digital pin as an output.

pinMode(comparator_input, INPUT);

} // the loop routine runs over and over again forever:

void loop() {

digitalWrite(pbrail, HIGH);

delay(100);

val = digitalRead(comparator_input); // read the input pin from the comparator

if (val == 1)

{

digitalWrite(led, HIGH);

}

else

{

digitalWrite(led, LOW);

}

digitalWrite(pbrail, LOW);

delay(1000); // wait for a second

}

Running a simulation with the pbrail used to power the wheatstone bridge works as planned, though it is hard to see accurate voltages. …. but you can see them if you want using an oscilloscope, also included in 123D Circuits.

Powering the Wheatstone Bridge with a Digital Pin as a Power Rail

This is my first blog post on electronics! I plan to do many more. Next up maybe Tri-Stating with a Microcontroller. I hope you have enjoyed this post.