DS2438-based 1-Wire humidity sensor

In this post I want to share with you how I did the humidity measurement in my bathroom.
Because I already have 1-Wire buses all over my house measuring temperatures (DS18B20), sensing my switches (DS2413) and controlling relays (DS2408), so logical step was to measure the humidity also using the 1-Wire bus.
I used the Google and found out that a solution was available:
http://rants.dyer.com.hk/rpi/humidity_1w.html
Allan, here I want to thank you for your helpful article and support 🙂

I also found similar projects using DS2438 here:
http://www.phanderson.com/rh166/rh166.html
http://archives.sensorsmag.com/articles/0501/34/main.shtml
https://www.mrsoft.fi/humi.htm

As usual I examined all schematics, chosed the Allan’s one and customized it a bit:

As you can see I decided to use a HIH-4000-003 instead of HIH-5030-001.

I designed a very simple PCB:

Using the toner transfer method I created and assembled the board:

I connected all needed wires (GND, 1wire and +5V) and made first tests on my desk.
I had to use OWFS (for the first time! 😉 ), because there was no kernel module for DS2438 at that time.
The DS2438 device was properly discovered on the bus, so I started to read a configuration register and measure some values.
It was working correctly!

Finally I installed the sensor in the target location, in my bathroom:

To be able to measure the real humidity in %RH, I have to obtain these values:
– supply voltage (VDD)
– A/D voltage from the HIH (VAD)
– temperature (DS2438 has built-in temperature sensor)
The formula is in the HIH-4000 series datasheet.

The last problem to solve was to obtain these values from DS2438 on my Raspberry Pi. I have customized Linux environment running on the Pi, so of course I will not run OWFS on it.
Allan Dyer is sharing on his page a perl script which is doing the measurement using the generic rw sysfs file, but according to him, it is very slow (~26 seconds per single measurement).
Obviously this was unacceptable in my application, so I just did what I was planning from the beginning: writing own kernel module for DS2438 🙂
At the time of writing this post, my patches are approved and waiting for next merge window to be upstreamed. If everything goes according to the plan, the module should be available in kernel 4.12.

One way or another, I am currently using this module on my Raspberry Pi. Measuring the voltages and temperature is as easy as reading the sysfs files. Then I am just calculating a real humidity value from the userspace.
I am also setting the IAD configuration bit to 0 (once at system start), because I don’t need the DS2438 to measure current A/D data and shadow it to the EEPROM (it is doing this by default).

Now I am finally able to control the fan in my bathroom basing on the humidity value 🙂
Watching the humidity in the Grafana is also nice thing to have:

Leave a Reply

Your email address will not be published. Required fields are marked *