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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...