Hackers Vs. Mold: Building A Humidistat Fan

Having a mold problem in your home is terrible, especially if you have an allergy to it. It can be toxic, aggravate asthma, and damage your possessions. But let’s be honest, before you even get to those listed issues, having mold where you live feels disgusting.

You can clean it with the regular use of unpleasant chemicals like bleach, although only with limited effectiveness. So I was not particularly happy to discover mold growing on the kitchen wall, and decided to do science at it. Happily, I managed to fix my mold problems with a little bit of hacker ingenuity.

What Level of Humidity Leads to Mold?

I did some research into the underlying causes of the issue. We know mold loves moisture, but the specific root of the problem seems to be a high relative humidity in the surrounding air.

There is a limit to how much water vapor the air can contain at a given temperature. Relative humidity is the percentage of that water vapor limit at the current air temperature. High relative humidity also makes condensation worse, another source of moisture for mold growth. The thing to know is that moisture is our enemy here and the unit of measure that gives us the most reliable information about that is relative humidity.

A study done in Tokyo (PDF warning) seemed to show that the magic number is a bit below 70% relative humidity. Below that, the types of mold being studied grew much less. A previous study (PDF warning) described that the relative humidity required for mold growth was highly dependent on the surface in question; staying below 76% relative humidity prevented mold growth on most surfaces they studied. However, the Japanese study specifically dealt with walls in homes. The United States Environmental Protection Agency recommends below 60%.

Measuring My Home’s (Really High) Relative Humidity

Here in Southeast Asia, humidity below 60% is not really a thing for most of the year. Ever see packaging that says ‘store in a cool, dry place’? Better not to bring those things here.

Anyway, I had taken some quick measurements with a DHT11 combined temperature/humidity sensor while investigating IoT data logging platforms. They showed a range of 52% to 70% outdoors (we’re at the end of rainy season presently), drier in the mornings and more humid at night. In any case, with proper ventilation alone, it looks like 70% relative humidity or lower is achievable.

I repeated the measurement in the problem area of the house, and recorded a consistent 86% relative humidity! That was clearly problematic so I considered solutions. Running an air conditioner all the time was not practical. We’ve seen a couple of projects out there addressing mold problem with dehumidifiers, and those are sold here at around USD $150 for a small one, but it’s yet another appliance in the house. One effect of population density is that houses here are small.

Building a Smart Fan

My solution is a simple one: up the ventilation. The numbers so far suggest moving the humid air out would be sufficient. I was short a fan in the house anyway, and fans are cheap so there was little penalty if I was wrong.

I didn’t really want to leave a fan on all the time though. It may only use 40 watts, but it’s irritating to hear it, and I had a bunch of parts left over from learning to use gracefully silent solid-state relays. So why not add a humidistat to the fan? Humidistats are like thermostats, but they switch based on humidity rather than temperature.

You know those days when everything just comes together? This was one of those days. The fan had no electronics inside, only switches that connected mains power directly to ‘something’ further in the fan.

As much as possible, I avoid using solder for anything that uses mains power. In this case though, the wiring was just soldered to brass conductors already, and moreover, there were perforations in it that exactly fit the wire I had. As a result, all I had to do was put the solid-state relay across the switch for the fastest fan speed, and I had an OK test system:

I used a DHT11 combined temperature/humidity sensor to track humidity, interfaced with a Wemos Mini D1 board running NodeMCU to control the relay. A small mains to 5 volt module powered the control system. I wrote up a quick Lua program to control when the fan should be on:

gpio.mode(2, gpio.OUTPUT)
gpio.mode(1, gpio.OUTPUT)
gpio.write(2, gpio.LOW)
gpio.write(1, gpio.LOW)
pin = 4
x = 'off'
function currentlyon(level)
status, temp, humi, temp_dec, humi_dec = dht.read(pin)
print(string.format("DHT Temperature:%d.%03d;Humidity:%d.%03d\r\n",
math.floor(temp),
temp_dec,
math.floor(humi),
humi_dec
))
print('Currently ON. Temp:'..temp..' ,Humidity:'..humi)
if humi < 66 then
gpio.write(2, gpio.LOW)
x = 'off'
end
end

function currentlyoff(level)
status, temp, humi, temp_dec, humi_dec = dht.read(pin)
print('Currently OFF. Temp:'..temp..' ,Humidity:'..humi)
if humi > 68 then
gpio.write(2, gpio.HIGH)
x = 'on'
end
end

function statuscheck()
print('Checking Status')
if x == 'on' then
currentlyon()
elseif x == 'off' then
currentlyoff()
else
print('Invalid state')
end
end

tmr.alarm(1, 20000, tmr.ALARM_AUTO, function() statuscheck() end)

A Simple Hysteresis Example and the Hunting Problem

The humidity required to change the state of the fan depends on whether the fan has last switched from on to off, or from off to on. This is called hysteresis: the state of the system depends on it’s history, and it’s an inelegant but easy way to avoid a common control issue called ‘the hunting problem’.

Hunting problems can be an issue in closed-loop control systems, where the behavior of the controller depends on feedback from a sensor coupled to the process you are measuring. In our situation, if we simply set the target humidity to 70%, then the fan will get to that value and turn on or off frequently due to small fluctuations in humidity. The fan can only be completely on or off, and neither of those states result in the target humidity being reached for long.

As in our case an acceptable humidity is a rather wide range, we set the fan to turn on at anything over 68% humidity, and once on, turn off under 66% humidity. The sensor resolution is 1%, so that’s a 4% range which seemed reasonable to start.

Some quick tests were run by blowing into the sensor, and it all worked as expected. The humidity problem tentatively solved, I put on protective gear and bleached the mold as best I could. Since then, it hasn’t returned.

It Works! Now Make It Better

Some improvements were added afterwards. Initially, the control system just toggles the fan in response to humidity by taking control of the actual switch. This means it doesn’t work well as a normal fan – it can ignore your speed selection depending on humidity! It would be better to interrupt the main power line with the solid-state relay, and have the control system default to the fan being on. Only when a dehumidifier function is selected (a switch), the control system will then connect or disconnect power to the fan as needed.

In the end that was an easy update. I removed the relay from the fan switch, added it as above, and added a toggle switch that connects GPIO D5 on the Wemos Mini D1 to either +3.3 volts or ground. Then I updated the code as below, assembled everything into the fan case, and it just worked:

gpio.mode(2, gpio.OUTPUT)
gpio.mode(1, gpio.OUTPUT)
gpio.write(2, gpio.LOW)
gpio.write(1, gpio.LOW)
gpio.mode(5, gpio.INPUT)
pin = 4
x = 'off'
function currentlyon(level)
status, temp, humi, temp_dec, humi_dec = dht.read(pin)
print(string.format("DHT Temperature:%d.%03d;Humidity:%d.%03d\r\n",
math.floor(temp),
temp_dec,
math.floor(humi),
humi_dec
))
gpio.write(2, gpio.HIGH)
print('Currently ON. Temp:'..temp..' ,Humidity:'..humi)
if humi < 66 then
x = 'off'
end
end

function currentlyoff(level)
status, temp, humi, temp_dec, humi_dec = dht.read(pin)
gpio.write(2, gpio.LOW)
print('Currently OFF. Temp:'..temp..' ,Humidity:'..humi)
if humi > 68 then

x = 'on'
end
end

function statuscheck()
fanmode = gpio.read(5)
print (fanmode)
print('Checking Status')
if x == 'on' and fanmode == 1 then
currentlyon()
elseif x == 'off' and fanmode == 1 then
currentlyoff()
else
print('Humidity mode inactive. Fan always on.')
gpio.write(2, gpio.HIGH)
end
end

tmr.alarm(1, 5000, tmr.ALARM_AUTO, function() statuscheck() end)

As a final note, solid-state relays of this type should normally have heat sinks attached, but I’m using it at a very small fraction of the rated current. It does not heat up perceptibly even after running for a long time. This large relay is overkill, as there are many smaller and cheaper options more suitable for the low currents used by the fan, but I had it on hand… so in it went.

There are many ways I could have tackled my mold problem. The most eloquent turned out to the a little bit of head scratching, and a lot of fun.

29 thoughts on “Hackers Vs. Mold: Building A Humidistat Fan

  1. Pretty clever fix! Another approach might have been to use two DHT11s on longer wires; one indoors and one outdoors, to make sure the fan doesn’t turn on when the humidity outdoors is higher than the one indoors. Using a single sensor and measuring the rate of change when the fan is turned on (if the humidity increases, shut it off and wait a few hours) could also work, especially with a RTC to have it turn on in the morning since you mentioned the humidity is generally lower at that time of day.

    1. Thanks! I thought along those lines too, but the humidity in the problem area was always higher than outdoors so it didn’t need to be that smart. Certainly less true now, it’s been running autonomously for a few weeks and the mold hasn’t returned!

      I do eventually want to build what you’re describing but for temperature and with a window fan. I need to build a sort of fume extractor for the workshop anyway, and this way it can also automatically turn on whenever the temperature outdoors is a given amount cooler than indoors.

      Its primary use would be as a fume extractor so the fan would have to push air out of the room, but perhaps still useful for some temperature regulation. The differential is quite noticeable after rain or in the late afternoon.

      1. The humidity is only half the equation… the temperature matters too… hot air can hold more water, so the range for relative humidity is relative to the temperature… (dew point seeks to alleviate some of this problem for weather forecasters).

        It means that when it’s 32F outside, and 70F inside, the humidity outside can be 100% and it will be the same amount of moisture in the air as the inside at 27%.

        I have to humidify my house in the winter (because it gets cold and dry here) I run a simple formula (outside_temp_f/2+20=inside_target_humidity_%) to keep my house at the right level… to humid and moisture will condense on the windows and that’s bad for mold near the windows… not humid enough and everyone starts to get nose bleeds, dust gets into the air and allergies get bad…

        I don’t know how much impact the temperature differential has in your instance… but since you’ve got the wifi chip already in play, pull the temp and humidity outside from a weather website, and see if you can make your math accommodate if the level of moisture outside is actually higher or lower than inside…

  2. It looks like there may be a water leak in that corner. Perhaps a leaking water pipe or a roof leak. You can get a wood moisture detector on ebay for around $6 – $7 and test that area. Compare the reading to another section that has no mold.

    If the area is damp, then mold will also be growing on the inside of the wall. This produces spores that can be very toxic that spread throughout the house. If there is a leak, you need to find it and fix it before the mold makes you sick. Once you start feeling symptoms, it is too late. The damage is already done and it is permanent. I have been fighting the toxins from ordinary mold spores for the last two decades, and they have destroyed my life. Don’t let it happen to you.

  3. The sensor resolution is claimed to be 1%. It’s an ultra cheap sensor though and I think in practice that you are not going to get anywhere close to that.

    Where is your humidity coming from exactly if it is created by the inside of where you live and is higher than the outside? This feels like it might very slightly help at best and more likely not actually resolve the issue.

    1. for the numbers given (70% outside, no temperature so I assume 20C, and 86% inside, with no temperature given so I assume 20C) a 850 cubic meter home (maybe large for asia, probably small in the US) would only need about 2.3 liters of water evaporated in the air to make up the difference…

      average human sweats about 0.5-15L per day (15 being the extreme high end lots of exercise, etc, 1 being normal) so two people in the house would produce enough humidity to cause problems.

      Of course % humidity without a temperature is fairly meaningless when comparing inside and outside… if it’s hot out, the air can hold more water, and if it’s cold it can hold less…
      I’ve had instances this week even where it’s 100% humidity outside, and I’m running a humidifier inside to keep the house comfortable. Because it was 0C outside and 21C inside.

  4. “Having a mold problem in your home is terrible, especially if you have an allergy to it. It can be toxic, aggravate asthma, and damage your possessions. But let’s be honest, before you even get to those listed issues, having mold where you live feels disgusting.”

    Wish some mold problems could be fixed as easily with a fan. Much denero involved in some cases. Heat is another way to dry out some places.

    1. In most cases, simply moving air around is not really a viable method to deal with mold. Despite what the author may claim. You have to actually address the root of the problem (moisture) as well as the fact that some materials (wood, drywall, paint, etc) are basically petri dishes for mold to grow on.

  5. Seems to me a dehumidifier would be better to reduce the water in the whole area – I do that on a small boat in the winter – and yes if you have some sort of leak in the area the problem will just be hidden – have some friends that had that problem and were slow to fix the leaks and had severe mold problems until they fixed some of the leaks and added a dehumidifier (he was too lazy to fix all the leaks – but the dehumidifier stopped the mold issue) – – I had a couple of drips from a hatch and fixed them when I first noticed the leaks – but it took over a week to dry things out even with a dehumidifier –

  6. ” I put on protective gear and bleached the mold as best I could. Since then, it hasn’t returned.”

    The mold is still in there, just not on the surface. The visible mold is just the “flowers” of the fungus, which extends its roots through the wall structure and while you made its life difficult on that particular surface, it’s probably still growing inside the wall, on the other side, in the ceiling etc.

      1. It’s a concrete, load bearing wall. In fact, everything is made out of concrete or steel – the ceiling, some of the furniture, and so forth. It’s just the way things are built here. Very solid, at least.

        The house doesn’t flood, although down the street 25cm of water in the living room is an unfortunately common event.

        Anyway I get what you’re saying but given that knocking it all down or moving aren’t options, I’m happy with the current solution :)

  7. A dehumidifier in winter on a boat, great. A dehumidifier in summer, dumb. A dehumidifier is an air conditioner that reheats the air instead of passing it outside and adds it’s waste heat too.

    Best in this case get a fan that is quiet and effective and run it seasonally. Air humidity stratifies in still air. Unoccupied rooms need ventilation too. That fan is typical of the crap that passes for a fan, soon to end up at the curb. Their lubrication is timed to fail in few seasons. No reason for a fan not pass on for generations. Secondly is the “safety” grille, it wastes a great deal of the velocity of the mover of air. Many of these Eastern sourced fans are not much more than noise makers. Remember most important psychological motivator of choice, Noi$e $ells! The closely spaced wires or fins of plastic work just like the wind machine that was used in radio and sampled in movie sound effects or used still in an orchestral setting for works like Vaughn Williams 7th.

  8. If mold/mildew get into drywall, some code enforcers require that to be removed. Modern drywall has mitecides not in older drywall. If air is dry enough, the drywall may dry enough such that the fungii blooms do not occur, so no spore explosions occur… no allergies triggered. Humidity from human occuoation travels through drywall to cold exterior ckadding (in most older uninsulated homes) which condenses and drips onto rotting sill plates, undermining the wall studs. A painted on vapor barrier is a good idea, short of new drywall, after insulating and adding a vapor barrier. In some humid warm places such as Florida, greater humidity is on the outside, so vapor barriers go under the exterior cladding… backwards of most of N America. He may be in such an area. Fans help to evaporate localized concentrations of humidity so it can escape via more available routes and diffuse. Bathroom exhaust fans do more than remove odors. I often sell clients on timer switches for these sometimes noisey fans. They can timer it or turn it on for ~ 20 – 60 minutes AFTER a shower so the noise occurs after they leave the house for work. HIS Fan idea is a V nice start to remedy the problem! In a temporary rental it is enough. Vapor barrier paint is made by only 2 US companies. Workdwide – dunno. But it would be next for cost-effectiveness, although 50% more than normal paint.

    Uh, yes… ALL of Russia. They are United.

  9. Grab your tin foil hats as I am about to say “Mold can kill you”.

    Also below in TL;DR “you can’t kill molds”.

    OK, we have all been around mold (mould) and I presume that most of the people reading this now are not dead so I perhaps need to qualify that statement.

    There are several categories of molds.

    Common harmless molds include species like –

    Acremonium strictum, Alternaria alternata, Aspergillus ustus, Cladosporium cladosporioides 1, Cladosporium cladosporioides 2, Cladosporium herbarum, Epicoccum nigrum, Mucor amphibiorum, Penicillium chrysogenum, Rhizopus stolonifer

    These molds need a little light, some moisture by way of humidity and oxygen from the air.

    They’re harmless molds because it’s chemically damned difficult to create toxins from three things that are essential to human life. Although harmless these mold spores can create irritation, allergic reactions and aggravation of conditions such as asthma, emphysema, bronchitis, COPD. Generally respiratory irritations.

    Less common toxic molds (called biotoxins) include species such as –

    Aspergillus flavus, Aspergillus fumigatus, Aspergillus niger, Aspergillus ochraceus, Aspergillus penicillioides, Aspergillus restrictus, Aspergillus sclerotiorum, Aspergillus sydowii, Aspergillus unguis, Aspergillus versicolor, Aureobasidium pullulans, Chaetomium globosum, Cladosporium sphaerospermum, Eurotium amstelodami, Paecilomyces variotii, Penicillium brevicompactum, Penicillium corylophilum, Penicillium crustosum, Penicillium purpurogenum, Penicliium spinulosum, Penicillium variabile, Scopulariopsis brevicaulis/fusca, Scopulariopsis chartarum, Stachybotrys chartarum, Trichoderma viride, Wallemia sebi
    This list includes molds that are –
    1) toxicogenic
    2) mutagenic
    3) carcinogenic
    4) pathogenic
    5) neurotoxic

    ie they kill your nervous system and brain and cause cancer.

    These biotoxins need a source of chemical resources to create these toxins and those chemical resources are extracted from wet or damp building materials like drywall (gyprock), the wood in wall and ceiling cavities and other cavities that have potential for water ingress such as bath and spa hob cavities.

    Genera such as Aspergillus can grow in your lungs in a non-invasive form, causing conditions such as aspergillosis. It can also become invasive in the blood system and cause lesions on the brain.

    A collection of several of these toxic molds can also cause an illness often called mold illness or biotoxin illness or more correctly Chronic Inflammatory Response Syndrome from a Water Damaged Building (CIRS-WDB) often abbreviated to CIRS.

    CIRS is multi system invasive, respiratory, neurological, digestive, endocrine etc.
    The symptoms of CIRS are –
    Memory problems, brain fog, trouble with focus and executive function, Fatigue, weakness, post-exercise malaise and fatigue, Muscle cramping, aches and pains, joint pain without inflammatory arthritis, persistent nerve pain, “ice pick” pain, Numbness and tingling, Headache, Light sensitivity, red eyes, and/or blurred vision, Sinus problems, cough, shortness of breath, air hunger, asthma-like symptoms, Tremors, Vertigo, Persistent nerve pain, Abdominal pain, nausea, diarrhea, appetite changes, Metallic taste, Weight gain despite sufficient effort (weight loss resistance), Night sweats or other problems with temperature regulation, Excessive thirst, Increased urination, Static “shocks”

    24% of the genetic permutations of the human DNA will genetically predispose that individual to an inability to remove these toxins from their body causing the CIRS. People who are not genetically predisposed will also experience symptoms with high exposure rates.

    When these biotoxins are broken down in an attempt to “kill the mold” or naturally when conditions become less favorable to their existence then form even more harmful toxins called mycotoxins and afloxins. Mycotoxins are simply chemicals and cannot be “killed”. Mold itself does not die, it just goes dormant until conditions are more favorable.

    To distinguish between these mold categories (harmless or toxic) a test called an Environmental Relative Moldiness Indicator (ERMI) can be done. If someone is experiencing a selection of the symptoms above then a less expensive test called a HERTSMI-2 test can be conducted to identify the presence of the molds that are more likely to cause these symptoms. Ultimately ERMI is the better test but is more expensive.

    To find out more about CIRS, google for Dr Ritchie Shoemaker who is the worlds original and leading researcher into this condition.

    TL;DR

    You can’t “kill” mold. You can only break it down and if it’s a toxic mold then it will break down into more airborne toxins called mycotoxins.

    You can only make conditions less favorable so that the existing mold goes dormant and no new mold spores are created. In the case of toxic molds, the mycotoxins created will never go dormant as they are only chemicals and do not have a dormant state.

    Bleach treatment is a fantasy. Houses have lots of light colored surfaces and darker molds are more visible on these surfaces. Bleach whitens the mold so that it is less visible but does not effect the mold in any other way. Vinegar is better for treating common harmless molds. There are also quality *NON-BLEACH* commercial products available.

    Toxic molds cannot be treated. It has to be removed. This has to be done by professionals and is drastic. All drywall in the house is completely ripped out for example.

    A short documentary –
    https://www.youtube.com/watch?v=VI0_azQv6N8&t=184s

  10. The humidity alone is irrelevant, it’s all about the ‘Dew Point’ (the temperature at which the water vapors start condensing into water droplets). If the wall’s temperature is less than the Dew Point of the air in your room, then you’ll have water vapor condensation on the wall, so you’ll have mold.

  11. Follow up — The fan ran for 16 months straight before failing. The electronics were fine, but the fan’s motor had died. Making an external box to handle the fan state would have been a better approach so I could just swap fans.

    For example, a normal power bar with one of the plugs controlled by the humidistat via a smaller SSR.

    The mould did not return since the fan was installed.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.