I have a Python program I've been using for years to monitor my home heating system. At one time or another I've used it under both Linux and Windows. The Phidget hardware consists of a 1018-1 interface board and (6) 1124 temperature sensors.
At the heart of the program it polls all the temperature sensors when the furnace burners turns on/off (event driven from a digital input).
At present I'm trying to move the program from Phidget21 to Phidget22 and have run into an issue with getSensorValue.
Under Phidget21 I would open the InterfaceKit object and leave it open day after day. I could do a getSensorValue from any analog or digital channel and get live data.
However, under Phidget22 doing a getSensorValue while the VoltageRatioInput object is open returns a fixed reading that never changes unless I close and reopen the VoltageRatioInput object.
The documentation for getSensorValue under Phidget22/Python says it returns "The most recent sensor value that the channel has reported." That sounds like I should get live data not a stored value, but apparently it apparently doesn't work that way. Maybe a bug?
I can certainly close and reopen all (6) VoltageRatioInput objects everytime I need to get readings, but that will result in a lot of coding overhead.
I have experimented with getting readings from the temperature sensors using event driven programming and found I can get live readings without closing and reopening the objects. But I don't see how I can do that in my program because it's the furnace burner (digital input) that triggers the event for me, not the temperature sensors.
This isn't well documented yet, but SensorValue and VoltageRatio properties are meant to be mutually exclusive. If you want to use the SensorValue property and/or event, you need to set the SensorType to something other then SENSOR_TYPE_VOLTAGERATIO - you probably want to set it to SENSOR_TYPE_1124. The SensorValue property will now return degrees celcius. If you want to apply the formula yourself, you can use the VoltageRatio property, which returns a value between 0 and 1.
I will need to fix this bug in the library so that the SensorValue property doesn't return bogus data.
Thanks, I think I got it. I shouldn't use getSensorValue without first setting the sensor type to 0x2be8 (11240) in the case of my 1124 temp sensors. I tried that and do indeed get back the temp in degrees Celsius.
I also tried applying a formula to the VoltageRatio itself by working backward from what the Phidget Control Panel reports in Windows. For example, a .373400 Voltage Ratio equals a sensor value of 21.858 degrees Celsius. So, my formula becomes 21.858 = (.373400 * 222.199) - 61.111 or c = (voltageRatio * 222.199) - 61.111 in my program.
The 1124 doc only shows a general formula based on Voltage not VoltageRatio, which is understandable since the reference voltage could be different.