Yet another Humidity and Temperature logger

Hi,
just a quick word from me to share my design and code for a setup I built over Christmas to measure relative humidity in our apartment.

Code, images and circuit documentation can be found here: GitHub - aweijnitz/Hygrometer: Basic Arduino sketch to measure relative humidity and temperature using an EFS-10 and an LM135.

Sample data from logging the output (with sub sequent sub sampling) can be viewed here: http://wohnung.se/arduino/hygrometer/data.html

Background
It is common to find apartments without proper ventilation in Germany (where I live). This is not even legal in Sweden (where I come from). Without proper ventilation, you face a whole range of issues with the indoor climate, bad air and particles is just a start, condense and mold is at the other end of the spectrum. This triggered the idea to let my next project be a hygrometer. That and a wish to build a nice balcony greenhouse this year. :slight_smile:

Looking for input on approaches you find a whole lot of questions and discussions in this forum, but not so much solid information, so that's why I decided to post my project here. It far from perfect, but it is at least a working end-to-end circuit and sketch to look at and perhaps get inspired by.

Notes
I believe my algorithm to measure the relative humidity has some issues, but I haven't gotten to a point where I can say what and why. Just notice a few odd things and "jumps" in my data. Ultimately it might be down to the crude approach of using a lookup table and interpolation to come up with the value. Input more than welcome!

Another thing to note is the (unusual?) way the EFS-10 humidity sensor works. You have to drive it with a square wave and then the impedance of the sensor will vary with the relative humidity. Not the most straight forward thing to use, at least if you are a inexperienced like me. Still haven't found any good sources for dealing with such sensors. If you have any pointers, it would be very welcome.

Many thanks to MarkT who provided the crucial pointers and code snippets to get me on the right track!

Cheers!

Anders

Ah!
Forgot.

Next, I hope to rig everything on the Data Logging shield from Adafruit to remove the need to use my laptop as data collector.

Anything I should think about?

Thanks!

Anders

I believe my algorithm to measure the relative humidity has some issues, but I haven't gotten to a point where I can say what and why. Just notice a few odd things and "jumps" in my data. Ultimately it might be down to the crude approach of using a lookup table and interpolation to come up with the value. Input more than welcome!

As the table is 2 dimensional you should interpolate in 2D - so both for temperature and humidity.

something like this

  float a = (realTemperature - rounded temp from table index) / stepsize in table
  float b = idem for hum.
  rH1 = (1-a) * lut[t][h] + (a)* lut[t+1][h];
  rH2 = (1-a) * lut[t][h+1] + (a)* lut[t+1][h+1];
  rH = (1-b) * rH1 + (b)*rH2;

Small things

  byte tmp = (byte) rint(temp);

simpler

  byte tmp = (byte)(temp + 0.5);
byte t = (tmp - (tmp % 5))/5;

simpler

byte t = tmp /5;

integer division truncates

do { } while (lookupTable[tIndex][rIndex] > r && rIndex++ < 8);

can be

while (lookupTable[tIndex][rIndex] > r && rIndex++ < 8);

succes

Hey,
great advice! Thanks!

I too have been thinking about interpolating in 2d, but made it a priority to get all moving parts working together first.

Good points about the small stuff as well. Will work them into the next version, as I implement you 2d suggestion.

Many thanks!

Anders

You're welcome,

Can you tell anything about the sensors used?
And the source of the table of RH? link?

Sure,
the URL to the lookup table is actually in the source code in the sketch, just by the lookup table itself. :slight_smile:
It's from the data sheet for the EFS-10 humidity sensor. Here: http://www.produktinfo.conrad.com/datenblaetter/150000-174999/156545-da-01-en-Feuchtesensor_EFS10.pdf

I got the sensor as a present and really don't know so much about it other than it being sold by Conrad.de. It is the first time I use it and I can't say it was very easy. I am not used to generating AC signals to drive a sensor and then having to work out the impendance of it from the (volt) value you get from analogRead() didn't make it easier. Now add 2d-interpolation to that and everything gets a little too complex for a beginner like myself.

The LM335 is a common and easy-to-use temperaure sensor in a three-pin transistor like package. Didn't give me any trouble at all and pretty much worked the first time I hooked it up.

I am trying to incorporate your suggestions now BTW. Will report back once I have it working, hopefully tonight.

Anders

the URL to the lookup table is actually in the source code in the sketch,

Oops missed that one :wink:

If the 2D interpolation is too hard please let me know so I can give it a try.

you must first check if the measurement is within the matrix (2D interpolation) or at its border (1D interpolation)

This will explain the math in detail - Bilinear interpolation - Wikipedia -
but the essence is in the first two lines and the picture at the top right.

Succes!

Success! :slight_smile:

I did some reading and some thinking to understand it on my own and came up with a slightly modified implementation from your code hint, but basically it is the same (2d interpolation).

Did a test run, including a big ventilation of the apartment (opening all windows) and kept a manual log from my reference setup (analog hygrometer and digital themometer) and it looks really good! The setup keeps within +/- 0.4C from the reference thermometer and a few % from what the analog hygrometer shows.

The new graphs are available on the same URL as before: http://wohnung.se/arduino/hygrometer/data.html

With the old approach, I would get strange bumps in the reading while ventilating and in the settling period following that. I guess because I would jump between temperature rows in the lookup table as the temperature dropped and rose again.

Thanks again for your patience and helpful advice!

Anders

.... and there I jinxed it sigh

Went back to upload the latest version of the data file (have it running) and then I see a sudden jump of almost 10% relative humidity!
Checkout the jump at 12:34 http://wohnung.se/arduino/hygrometer/data.html

This is 35min after I closed all windows and everything should be stable really.

Need to take a look at the debug printouts to see what is going on.

Regardless, it works a lot better than before.

Anders

on the other hand the analog hygrometer agrees on the new value.

confused

Good to hear the 2D interpolation is working. As I said it is not much more difficult than 1D interpolation if you get the idea.

Please post your new code, as the bump still appears it should be in the code somehow.
This can be (1) in the math/code itself or (2) in the table.

Could it be that water is condensing in the rH meter?
Or that the air was not moving?
When you opened the windows there was definitely more flow..

thinking...

Thanks for coming back on it!

I think the whole thing works and I made a silly mistake while reading the results. I also learned something new about our indoor climate perhaps.

First:
I think the apparatus works. My reference, the analog meter, showed the same value and has continued to do so. That means my circuit and the analog meter either both work or have the same kind of strange issue (not likely).

Second: (my reading mistake)
I said 12:34, because that is what I read on the graph and at 12:34 everything was static and quiet. HOWEVER I didn't think about the time zone when writing my script to convert the timestamps to JSON data. The timestamp is CET and 12:34 is in reality 13:34.
At 13:34 my wife came home after having run 15km in the Munich Winterlauf Series.

Needless to say the door to the stairwells was open for a while and she was wet and still perspired after having run in the wet weather.
We then closed the door and no windows where opened for a couple of hours. Two hours later (15:39 CET) we vented the flat again and the humidity dropped again.

I have time zone corrected the conversion tool and uploaded the latest data as illustration.
Same place: http://wohnung.se/arduino/hygrometer/data.html

Thanks again for all the help and friendly support!

Anders

Please post your new code,

I pushed the latest code to github: GitHub - aweijnitz/Hygrometer: Basic Arduino sketch to measure relative humidity and temperature using an EFS-10 and an LM135.

Good to hear it works well,
BTW I quickly checked the table from the PDF and it matches the values in your code .

Fun that you can detect the humidity created by people so well.

:slight_smile:

Thanks!

Edge cases next and then the data logging shield.

Your support has been fantastic! Thanks again.

Anders

now you have humidity and temp you can calc the dewpoint.

// dewPoint function NOAA
// reference: http://wahiduddin.net/calc/density_algorithms.htm 
double dewPoint(double celsius, double humidity)
{
        double A0= 373.15/(273.15 + celsius);
        double SUM = -7.90298 * (A0-1);
        SUM += 5.02808 * log10(A0);
        SUM += -1.3816e-7 * (pow(10, (11.344*(1-1/A0)))-1) ;
        SUM += 8.1328e-3 * (pow(10,(-3.49149*(A0-1)))-1) ;
        SUM += log10(1013.246);
        double VP = pow(10, SUM-3) * humidity;
        double T = log(VP/0.61078);   // temp var
        return (241.88 * T) / (17.558-T);
}

From - Arduino Playground - DHT11Lib -

The EFS-10 does look a little complicated to use.

I ended up on this thread because I had just come across a humidity sensor and was considering making a humidity/temperature monitor. The one I found was Honeywell HIH-4000-0019 (datasheet) which has a simple 3-pin arrangement of Vcc, GND and analog output which is linearly related to relative humidity. (I found it on sale on eBay). I notice that temperature compensation is a simple quadratic, rather than requiring 2D interpolation.

robtillaart:
now you have humidity and temp you can calc the dewpoint.

Wow! Thanks! That might prove useful actually, both in terms of tracking mold conditions and in the balcony greenhouse I hope to build in a month or two.

dewpoint is important indoor, not only for mold but also for water in electronics :frowning:

on that DHT11 page there is also a faster dewpint function '

I'll hear from you when your greenhouse is ready and you want to use RFID reader etc to identify the veggies :wink: