Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

vlicovali

Member Since 26 Apr 2013
Offline Last Active Apr 28 2013 01:53 AM
-----

Posts I've Made

In Topic: Honeywell HIH-4030 Humidity Sensor

26 April 2013 - 04:06 PM

This is code for the Honeywell HIH-4030 humidity sensor (SparkFun SKU: SEN-09569).

Please note that the sensor is supposed to be used with 5v input, but it works just fine with 3.3v input because the output is linear.

The code below is tailored to 3.3v input.
 

    /// <summary>    /// Honeywell HIH-4030 humidity sensor (SEN-09569).     /// Please note that the sensor is supposed to be used with 5v input,     /// but it works just fine with 3.3v input because the output is linear.    /// The code below is tailored to 3.3v input.    /// </summary>    public class HIH4030 : IDisposable    {        private AnalogInput _sensor;        private bool _disposed;        protected virtual void Dispose(bool disposing)        {            // Check if Dipose has already been called.            if (!_disposed)            {                if (disposing)                {                    _sensor.Dispose();                    _disposed = true;                }            }        }        ~HIH4030()        {            Dispose(false);        }        public void Dispose()        {            Dispose(true);            GC.SuppressFinalize(this); // tell the GC not to finalize.        }        public HIH4030(Cpu.Pin analogPin)        {            _sensor = new AnalogInput(analogPin);            _sensor.SetRange(0, 3300);        }        /// <summary>        /// Calculates the relative humidity with temperature compensation.        /// </summary>        /// <param name="temp">Current temperature in Celsius.</param>        /// <returns>Returns the relative humidity as a percentage.</returns>        public double RelativeHumidity(float temp)        {            // Get the humidity sensor reading.            int sensorReading = _sensor.Read();            // Calculate the humidity sensor voltage.            double sensorVoltage = (((double)sensorReading / 3300) * 3.3);            // Define the voltage the sensor returns at 0% humidity.            double zeroVoltage = 0.528;            /* It has been observed that some sensors are consistently              * inaccurate and off by a certain voltage than what they              * should be.  Use this variable to compensate for what the              * voltage should be if needed. */            double calibrationVoltage = 0.00;            /* Determine the maxium voltage of the sensor with                 temperature compensation. */            double maxVoltage = (2.1582 - (0.004426 * temp));            /* Determine the temperature compensated relative humidity                 as a percentage. */            double rh = ((sensorVoltage + calibrationVoltage - zeroVoltage) / maxVoltage) * 100;                        return rh;        }            }

Hi, can you explain me, based on the spec sheet how you calculate the constants inf formulas? i have a hih-5030 but i can't understand how determinate the values for this sensor...

 

Regards

Virgilio


home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.