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:
Allan, here I want to thank you for your helpful article and support 🙂

I also found similar projects using DS2438 here:

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:


  1. I was wondering if you are running the HIH-4000 at 3.3V ? The spec sheet states 4V minimum. ( calibrated at 5V @ 25C ) I have built the circuit and
    can say it does work, but I’m wondering if I should be running my 1-wire bus at 5V not 3.3…


    1. Hi Tom,
      No, I am running the HIH-4000 at 5V (you can see that in the schematic I provided). Currently the DS2438 is telling me that it has 5.05V.
      The 3.3V is the 1-wire signal line (DQ) connected to the DS2438, and it is working OK in this configuration. In the same way (5V power supply, 3.3V DQ line) I am using DS18B20 thermometers.

  2. I see… so you run the sensors at 5V, but kept the DQ line at 3.3V .. I’m also using DS18B20 temp sensors. I will try powering them and the DS2438 with 5V and keeping the DQ line at 3.3V and see how that works. I’m using the GPIO pin on the Pi to read the 1-wire. I will just use a pull-up to 3.3V on the DQ line and power the sensors with 5V.

    Any chance I can get a copy of your DS2438 kernel module ? Perhaps I can build it for
    my kernel and use that instead of the script. The script takes far too long to read the
    sensor.. .

  3. I was able to pull the source for the Pi I had running ( 4.4.50 ) and merge your 1-wire changes into it. I built it and …
    pi@raspberrypi:~ $ sudo modprobe w1_ds2438
    pi@raspberrypi:~ $ lsmod
    Module Size Used by
    w1_ds2438 3285 0
    cfg80211 438846 0
    rfkill 16728 1 cfg80211
    evdev 11567 1
    snd_bcm2835 20452 0
    snd_pcm 77514 1 snd_bcm2835
    snd_timer 19782 1 snd_pcm
    snd 53840 3 snd_bcm2835,snd_timer,snd_pcm
    bcm2835_gpiomem 3147 0
    bcm2835_wdt 3434 0
    w1_gpio 3008 0
    wire 26063 2 w1_gpio,w1_ds2438
    cn 4754 1 wire
    uio_pdrv_genirq 3202 0
    uio 8416 1 uio_pdrv_genirq
    ipv6 352477 30

    I will give it a try this weekend. The sensor I built with the 2438 is at my office … Thanks
    for your help.

Leave a Reply

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