Pages: [1]   Go Down
Author Topic: Advice on hooking up the EFS-10 Humidity Sensor?  (Read 1366 times)
0 Members and 1 Guest are viewing this topic.
Sweden
Offline Offline
Jr. Member
**
Karma: 0
Posts: 84
Arduino System Go!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Hi guys,
my electronics is a little rusty and I am hoping you might be able to get me started in the right direction here.
I am trying to build a simple logger to register the relative humidity in a room at home (indoors). The problem boils down to understanding how to read the impedance of the sensor I believe.

The sensor I have is the EFS-10 Humidity Sensor from Hygrosens. I got it from conrad.de and the datasheet is available here: http://www.produktinfo.conrad.com/datenblaetter/150000-174999/156545-da-01-en-Feuchtesensor_EFS10.pdf.

I not a total rookie and have already built a couple of simple projects, reading resistive sensors, but this one is based on the impedance and I have no clue how to hook it up.

The datasheet says:
Quote
The measurement of impedance should be done with an AC current (without DC-offset). The recommended operating frequency is 1 kHz for a measuring voltage of maximum 1Veff.

Anyone who can help me understand this a little bit better?

Anders
Logged

0
Offline Offline
Shannon Member
****
Karma: 207
Posts: 12200
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So conceptually this is like a thermistor - the resistance varies with the variable to measure - you would use a resistor divider with
the sensor in series with a fixed resistor.

However this device must recieve pure AC (no DC component or it'll be destroyed electrochemically).  This complicates things.

Since the device is relatively high resistance we can power it from two digital pins driven in anti-phase (one is HIGH when the other is LOW).

We switch the pins over every 0.5ms and this is then a 1kHz square wave (pure AC).  between the pins we wire the sensor and a 100k
resistor in series (so that the divider is roughly midrange at 50% humidity at 20C - most common case?).

Since the circuit is high impedance (> 10k) we then need to read the voltage at the midpoint of the divider twice (to allow time for
settling).

code would be something like:
Code:
#define  DRIVE1  ??   // the antiphase drive pins
#define  DRIVE2  ??
#define  SENSE  A0    // analog input

#define  PERIOD_US 1000  // for 1kHz, or use 10000 for 100Hz
#define  HALF_PERIOD_US (PERIOD_US/2)

unsigned long prev_time;

void setup ()
{
  pinMode (DRIVE1, OUTPUT) ;
  pinMode (DRIVE2, OUTPUT) ;
  prev_time = micros () ;
}

byte phase = 0 ;
float voltage ;

void loop ()
{
  .. do any other stuff here if only takes a few 100us ...

  while (micros () - prev_time < HALF_PERIOD_US)  ; wait for next 0.5ms time segment
  {}
  prev_time += 500 ;   // set up for the next loop
  digitalWrite (DRIVE1, phase == 0) ;   // antiphase drive
  digitalWrite (DRIVE2, phase != 0) ;
  int val = analogRead (SENSE) ;
  val = analogRead (SENSE) ;      // second read allows much longer for high impedance reading to settle
  if (phase == 0)
    val = 1023 - val ;  // reverse sense on alternate half cycles
  voltage = 5.0 * val / 1024 ;
  phase = 1 - phase ;
}

You can run the loop slower or faster, the datasheet says 100Hz upto 5kHz will work.
Logged

[ I won't respond to messages, use the forum please ]

Sweden
Offline Offline
Jr. Member
**
Karma: 0
Posts: 84
Arduino System Go!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Thank you very much!

This is exactly the kind of advice I was thinking about.

Some clever tricks in there for me to look closer into, like reading analog twice and just throwing away the first read.

Ideally it would have been great to be able to set some kind of interrupt and throw this routine in there. Don't like the busy loop approach, but that's more advanced I guess.

Thanks again!

Anders
Logged

0
Offline Offline
Shannon Member
****
Karma: 207
Posts: 12200
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well the only tricky bit about interrupt approach is the long time it takes to call analogRead().

By the way the multiple calls to analogRead() is only needed if other analog pins are being read from in the same
sketch - otherwise the analog input multiplexer never changes and the sample/hold capacitor is always connected to
the relevent source.
Logged

[ I won't respond to messages, use the forum please ]

Sweden
Offline Offline
Jr. Member
**
Karma: 0
Posts: 84
Arduino System Go!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Ok,
good point about the interrupt. Not a major issue for me. At this point I am just looking to take a reading, store it and to display it on an LCD with buttons to step back in time to see previous readings. Later on, there might be some serial sending of values to a host, but that is later, if ever.

Also, the thing with the input multiplexer was new to me. Very valuable info! Need to do some more reading and try to find a block diagram over the components. Still only had a vague idea about available timers, prescalers, interrupts and similar things (watchdog?).

Thanks again!

Logged

Sweden
Offline Offline
Jr. Member
**
Karma: 0
Posts: 84
Arduino System Go!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Hey MarkT,
just a note to say thanks for the help!

Using you advice and the code as a starting point, I managed to put something together which works quite nice. It still has some issues at some break points where it is several % off in the reading. Haven't tracked it down yet, but I am convinced it is down to the way I round off the temperature and do look-ups to finally interpolate a value, using a table from the EFS-10 data sheet.

If you are interested, I have documented the result here, including the code. https://github.com/aweijnitz/Hygrometer

Thanks again!

Anders
Logged

Pages: [1]   Go Up
Jump to: