Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

using ADC with HDT11 sensor?

Status
Not open for further replies.

okbro

Member
hi,
is the hdt11 humidity and temperature sensor all digitally interfaced with microcontroller? i thought at first of connecting it to the ADC and reading it via ADC channel but just found out that it should be digitally read via any other digital pin of the microcontroller. I wanted to make sure that this is correct. By the way, how can we use interrupt based programming with hdt11 if for example we wanted to make immediate alert in the system if humidity or temperature reaches some point?

tthanks
 
Yes.
It uses a simple serial data format, with a 0 being a shorter high level and a 1 being a longer high level, each followed by a low level for a fixed time.

Each transmission is triggered by you (your program) holding the data line low for a set time then releasing it; the sensor then starts sending data and you just see if each high level is longer or shorter than 50uS and store a 1 or 0 as appropriate.

See pages 6 & 7 in the datasheet here:

They are rather slow devices, there is no point it requesting data more than once every couple of seconds.

What you do with that depends on what else your program is doing; if it is doing little other than checking the sensor, you probably do not need interrupts - after each complete reading, just compare the sensor value to whatever threshold setting you want, and turn another output on or off depending on the comparison.

Interrupts are normally used to allow different things to happen at the same time, or data to be transferred without the "main loop" of the program being required to do anything. Or for timekeeping and time-critical actions.
 
As already mentioned, there's little need for interrupts for such an occasional sensor reading - 'if' you really wanted to use interrupts you could use a timer interrupt (say every 5 seconds?) to initiate a reading.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top