Using Arduino UNO
Fog reduces visibility, sometimes down to a few feet. That’s why fog horns are so important. In this article, Jeff embarks on a project that makes use of humidity sensors to detect fog, and automatically plays an audio response when fog is detected. Aside from the sensors, his project also makes use of Arduino hardware and software.
By Jeff Bachiochi
Pea soup. Not one of my favorite dishes. I just can’t see green soup. All that said, as a consistency descriptor, “pea soup” is spot on for describing fog. You don’t have to live in San Francisco to appreciate the alien qualities of the scene in Figure 1. This phenomenon is commonplace to those who reside in London, Seattle, on any lake or in any valley. All we need is the right combination of temperature and humidity, and the clouds of heaven will visit us here on Earth.
Fog consists of visible water droplets suspended in the air at or near the Earth’s surface. This moisture is often generated locally from a nearby body of water, and forms when the difference between air temperature and dew point is less than about 4°F. The dew point is the temperature at which the water vapor in air (at constant barometric pressure) condenses into liquid water on tiny particles in the air, at the same rate at which it evaporates—forming fog. A change in temperature affects the relative humidity. As the dew point goes up, so does the relative humidity, creating a smaller differential between actual temperature and dew point temperature until fog forms.
The maximum amount of water vapor that can be held in a given volume of air (saturation) varies greatly by temperature. Cold air can hold less mass of water per unit volume than hot air. Relative humidity is the percentage of water found relative to the maximum possible, at a particular temperature.
Most of us have experienced the relationship between temperature and relative humidity firsthand. When the air temperature is high, our bodies use the evaporation of sweat to cool down. The cooling effect is directly related to how fast the perspiration evaporates. The rate of evaporation depends on how much moisture is already in the air and how much moisture the air can hold. If the air is already saturated with moisture (high humidity) perspiration will not evaporate, and we remain hot and uncomfortable. Discomfort can also exist when the humidity is low. The drier air can cause our skin to crack and tends to dry out the airways.
Measuring Relative Humidity
A hygrometer is an instrument used for measuring the humidity and water vapor content of the atmosphere, the soil and confined spaces. An instrument that measures humidity usually relies on the detection of some other quantity—such as temperature, pressure, mass or a mechanical or electrical change in a substance as moisture is absorbed. Today we use the electrical change of capacitance or resistance to calculate humidity.
Humidity measurement is among the more difficult problems in basic meteorology. Most hygrometers sense relative humidity rather than the absolute amount of water present. Because relative humidity is a function of both temperature and absolute moisture content, a small temperature change will translate into a change in relative humidity.
Some materials’ properties allow humidity levels to be determined based on a change in their capacitance, resistance, thermal conductivity or mass. Many humidity sensors include a temperature sensor, which allows them to approach 2-3% accuracy in a changing temperature environment. Table 1 shows several common humidity sensors. Many of them are available on some tiny PCB modules for easy interfacing.
I’ve used both the Honeywell HIH-5031 (with a Texas Instruments TMP102 temperature sensor) and a Silicon Labs Si7021 for measuring humidity in this project. The The Honeywell sensor has analog output, whereas the TI temperature sensor and Silicon Labs humidity/temperature sensor both use I2C to communicate. If you feel uneasy writing a function to perform the process, Arduino libraries are available for many sensors. This is an advantage for newbies, because you can get a program working with a library and often a sample program to get you started. Then you can go back and write the function yourself as a learning experience.
I don’t want to base the project totally on humidity, so I have added an ultrasonic distance measuring device to the project. Because fog forms as the air becomes supersaturated with water, this should mean that the humidity has reached 100% and water droplets in the air should begin to look solid. I’m hoping ultrasonics will be reflected by the droplets and cause a normal non-returned ping to be received. The combination of these two sensors exceeding some predetermined limits will satisfy my conditions to determine the presence of “fog.”
Avast, Ye Landlubber!
In a previous article (March 2011, Circuit Cellar 248), I presented the Microchip Technology (formerly Supertex) SR10, an inductorless switching power supply controller intended for operation directly from a rectified 120/240 VAC line. This was presented in support of creating a 5 V supply for a lighthouse fixture designed using LEDs. This month’s project will build upon that 5 V light, and will add audio to protect and guide boaters who find themsleves out on a lake under foggy conditions.
I’m centering this project around the Arduino UNO. While I built the prototype interface (Figure 2) using the Arduino MEGA, it only uses the pins native to the UNO. The sensors/modules that are interfaced in this project are shown in Table 2.
Because the UNO has only a single hardware serial port, I set up two additional software serial ports—one to talk with the DRPlayer and one to the optional LCD (output only). The main port and optional LCD don’t have to be used in the final project, but there is code written to display progress on each of these devices for seeing debugging information. . …
Read the full article in the October 339 issue of Circuit Cellar
Don’t miss out on upcoming issues of Circuit Cellar. Subscribe today!
Circuit Cellar's editorial team comprises professional engineers, technical editors, and digital media specialists. You can reach the Editorial Department at firstname.lastname@example.org, @circuitcellar, and facebook.com/circuitcellar