1125 Humidity Sensor Formula

Comments & issues
Post Reply
DIYDyno
Phidgetsian
Posts: 6
Joined: Sat May 05, 2018 10:40 pm
Contact:

1125 Humidity Sensor Formula

Post by DIYDyno »

I would really appreciate some help making an 1125 Humidity sensor read correctly.

The voltage ratio output from the sensor going through my code matches the values shown in control panel.

I am using Voltage ratio and getting a value of 0.446
If I set the sensor type to 1125 it shows 44.8%

According to the weather the humidity is in the 70%'s

When I run my code with the formula shown in the user guide I get a value of -23. (which is different than the manager shows).

Code: Select all

textBox1.Text = ((humidity_voltage_ratio.VoltageRatio*38.12)-40.2).ToString() + "%";

The way it looks to me now, I guess that at least one thing may not be correct:

1. The value coming from the sensor may be wrong.
2. The formula in the user guide is wrong?
That one is confusing because it shows a formula for voltage, not voltage ratio.

Note the docs also say to set sensorType to 1125_HUMIDITY, but that raises an error.

https://www.phidgets.com/?tier=3&catid= ... &prodid=96


This is my code.


Code: Select all

namespace Phidgets_Basic
{
    public partial class Form1 : Form
    {

        VoltageRatioInput humidity_voltage_ratio;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            humidity_voltage_ratio = new VoltageRatioInput();
            humidity_voltage_ratio.DeviceSerialNumber = 496925;
            humidity_voltage_ratio.HubPort = 0;
            humidity_voltage_ratio.IsHubPortDevice = true;
            humidity_voltage_ratio.Channel = 0;
            //humidity_voltage_ratio.SensorType = humidity_voltage_ratio;
            humidity_voltage_ratio.Attach += humidty_voltage_ratio_attach;
            humidity_voltage_ratio.VoltageRatioChange += humidty_voltage_ratio_change;
            humidity_voltage_ratio.SensorChange += humidty_voltage_ratio_sensor_change;
            humidity_voltage_ratio.Error += humidty_voltage_error;
            //humidity_voltage.Detach += humidty_voltage_detach;

            try
            {
                humidity_voltage_ratio.Open();
                         }
            catch (PhidgetException ex)
            {
                MessageBox.Show("Error: " + ex.Description);
            }
        }

                //Attach voltage sensor for humidity
        void humidty_voltage_ratio_attach(object sender, Phidget22.Events.AttachEventArgs e)
        {
            {
                try
                {
                    VoltageRatioInput attachedDevice = (VoltageRatioInput)sender;
                }
                catch (PhidgetException ex) { textBox1.Text = ("Error initializing device: " + ex.Message); }
            }
        }

        void humidty_voltage_ratio_change(object sender, Phidget22.Events.VoltageRatioInputVoltageRatioChangeEventArgs e)
        {
            textBox1.Text = ((humidity_voltage_ratio.VoltageRatio*38.12)- 40.2) .ToString() + "%";
        }


        private void humidty_voltage_ratio_sensor_change(object sender, VoltageRatioInputSensorChangeEventArgs e)
        {
           // textBox1.Text = e.SensorValue.ToString() + " " + e.SensorUnit.Symbol;
        }

        void humidty_voltage_error(object sender, Phidget22.Events.ErrorEventArgs e)
        {
            textBox1.Text = (e.Description);
            //errorBox.addMessage(e.Description);
        }
    }
}
User avatar
mparadis
Site Admin
Posts: 959
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: 1125 Humidity Sensor Formula

Post by mparadis »

You're right, the equations in the User Guide are incorrect (the were expecting a 0-5V value instead of a 0 to 1 value). They've been fixed now to match the equations from SensorType in the library.

The reason there's an error when setting SensorType is because the enums are named differently in C# and Java. You'll want to use PN_1125_Humidity instead. Apologies for this, we're in the process of trying to improve our documentation for analog sensors like the 1125 so there's a lot of wrinkles to iron out still.
DIYDyno
Phidgetsian
Posts: 6
Joined: Sat May 05, 2018 10:40 pm
Contact:

Re: 1125 Humidity Sensor Formula

Post by DIYDyno »

Thanks for the quick reply but I still seem to have 3 issues:


1. I tried, but did not find PN_1125_Humidity as an option for sensor type, in fact, I could not find any option that worked for sensor type.

I am using the 05/08/2018 dll.

2. I tried the new formula, but the return does not match the control panel, it is lower by about 20.

3. The value shown in the control panel is about 40 when the humidity is actually about 80.
User avatar
mparadis
Site Admin
Posts: 959
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: 1125 Humidity Sensor Formula

Post by mparadis »

1. The full line you need is

Code: Select all

humidity_voltage_ratio.SensorType = VoltageRatioSensorType.PN_1125_Humidity;
This is because PN_1125_Humidity belongs to the "VoltageRatioSensorType" enum, as described in the C# API.

2. I just tried the new formula and found it to be the same as the control panel value. Is the equation you're using (VoltageRatio * 190.6) - 40.2?

3. Are you measuring indoor humidity? Furnaces and air conditioners can have a large impact on indoor humidity. Either way, for accurate results you may need to calibrate this humidity sensor using known humidity values, and use those to make your own equation for your specific device. We have a guide on how to build calibration equations here.
DIYDyno
Phidgetsian
Posts: 6
Joined: Sat May 05, 2018 10:40 pm
Contact:

Re: 1125 Humidity Sensor Formula

Post by DIYDyno »

Thanks, now I am at least getting a matching value to the control panel.
I guess the "VoltageRatioSensorType" code isn't required.


Anyhow, I tried to do this:

Code: Select all

humidity_voltage_ratio.VoltageRatioSensorType =  
But I get this:

VoltageRatioInput does not contain a definition for VoltageRatioSensorType
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests