Hey Guys,
Today I had an idea how you can save some power on battery sensors.
I simply connected a transistor before a StepUp converter. So the stepup and the connected sensors only supplied with power when they are needed.
My stepup + DHT11 has power consumption at 90 uA when sleeping. By disabling with the transistor it goes against 0.
Do you think that might help a little?
Best Regards,
n3ro
#include <SPI.h>
#include <MySensor.h>
#include <DHT.h>
#define CHILD_ID_HUM 0
#define CHILD_ID_TEMP 1
#define HUMIDITY_SENSOR_DIGITAL_PIN 4
#define STEPUP_PIN 5 // Transistor connected PIN
unsigned long SLEEP_TIME = 10000; // Sleep time between reads (in milliseconds)
MySensor gw;
DHT dht;
float lastTemp;
float lastHum;
boolean metric = true;
MyMessage msgHum(CHILD_ID_HUM, V_HUM);
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
void setup()
{
gw.begin();
dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN);
// Send the Sketch Version Information to the Gateway
gw.sendSketchInfo("Humidity", "1.0");
// Register all sensors to gw (they will be created as child devices)
gw.present(CHILD_ID_HUM, S_HUM);
gw.present(CHILD_ID_TEMP, S_TEMP);
metric = gw.getConfig().isMetric;
}
void loop()
{
stepup(true);
delay(dht.getMinimumSamplingPeriod());
float temperature = dht.getTemperature();
if (isnan(temperature)) {
Serial.println("Failed reading temperature from DHT");
} else if (temperature != lastTemp) {
lastTemp = temperature;
if (!metric) {
temperature = dht.toFahrenheit(temperature);
}
gw.send(msgTemp.set(temperature, 1));
}
Serial.print("T: ");
Serial.println(temperature);
float humidity = dht.getHumidity();
if (isnan(humidity)) {
Serial.println("Failed reading humidity from DHT");
} else if (humidity != lastHum) {
lastHum = humidity;
gw.send(msgHum.set(humidity, 1));
}
Serial.print("H: ");
Serial.println(humidity);
stepup(false);
gw.sleep(SLEEP_TIME); //sleep a bit
}
void stepup(boolean onoff)
{
pinMode(STEPUP_PIN, OUTPUT); // sets the pin as output
Serial.print("---------- StepUp: ");
if (onoff == true)
{
Serial.println("ON");
digitalWrite(STEPUP_PIN, HIGH); // turn on
}
else
{
Serial.println("OFF");
digitalWrite(STEPUP_PIN, LOW); // turn off
}
}