Jump to content
SureshBonagiri

DHT11 sensor reading under timer ISR

Recommended Posts

Hi all,

 

I am facing problem while reading DHT values in timer ISR function. I am able to get the data if use i dht.readHumidity() (using dht library) in loop function but not able to get when i use in timer ISR function. Can anyone please help me out.

 

Thanks in Advance.

Share this post


Link to post
Share on other sites

Hi Suresh,

 

Are you calling the dht library from within the ISR? If so, that is not good practice and you should minimize time in the ISR. Call dht after the ISR returns.

 

Hope that helps.

 

Thanks Fmilburn

The main objective of the project is taking dht sensor values in a fixed interview of time (say 2 hrs). So my msp430 will be in low power mode and wake's up in every 2 hours and takes data. So can u please help me out in this. 

 

Thanks in Advance.

Share this post


Link to post
Share on other sites

Try something like:

 

you need a variable that can be set by an isr or in the main loop:

volatile boolean isVar=false;

In the ISR just set a variable to true, all the rest gets taken care of in the main loop:

isrVar=true;

In the main loop check for the variable, execute function, reset variable:

if (isrVar){
  dht.readHumidity();
  isrVar=false;
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×