Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

Air humidity alarm with sleep problem (high power consumption)

$
0
0

I decided to build an air humidity alarm so I know when to air (you can also attach a piezo buzzer, which is more recognizable in some situations). I found/use this lib.

Chip: MSP430G2452 (this I had left, I think it's overkill for this task)

High power consumption problem:

LPM0: 673µA
LPM1: 673µA, and 658µA with detached sensor (and LED just to make sure)
LPM2: 36µA
LPM3: 6µA

I'd be happy with LPM2 and below (<100µA) but the problem is that the sensor doesn't work in LPM2 and below anymore. Also, is the high consumption in LPM1 usual?, seems a bit high to me. I tried 1 and 8 MHz and the power consumption drops but the sensor is again not working anymore.

#if defined(__MSP430G2452__) || defined(__MSP430G2553__) || defined(__MSP430G2231__) // LaunchPad specific
#include "Energia.h"
#else // error
#error Platform not supported
#endif

#include "DHT22_430.h"

DHT22 mySensor(P1_2);
boolean flag;

unsigned int h, t;
unsigned char wakeupCounter = 1, frequency = 5;
#define LED P1_3

void setup() {
  TACCTL0 = CCIE;                     
  TACCR0 = 12000; //1 second
  TACTL = MC_1 | TASSEL_1;
  
  pinMode(LED,OUTPUT);
  
  mySensor.begin();
}

void loop() {
  _BIS_SR(LPM1_bits); 
}

#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer0_A0 (void) {
  if(wakeupCounter % frequency == 0) { //check every 10 seconds and sleep deep meanwhile
    flag = mySensor.get();
    h = mySensor.humidityX10();
    //t = mySensor.temperatureX10();

    if (flag) {
      if(h>=485) {
        digitalWrite(LED,HIGH); //on
        delay(5); //this maybe could be optimized without using delay() but since this is only a few ms, I think it's ok for now
        digitalWrite(LED,LOW); //off
        frequency=3;
      } else
        frequency=10;
    }
    wakeupCounter=0;
  }
  wakeupCounter++;
}

Attached Thumbnails

  • image.jpg

Viewing all articles
Browse latest Browse all 2077

Trending Articles