def readTemp(dev, th, ch, vref):
    """Returns a temperature value from a thermistor connected to a Labjack U3
    device.
    'dev' is an open MyU3 Labjack device object.
    'th' is a Thermistor object, appropriate for the connected thermistor.
    'ch' is the U3 Analog channel number (0 - 15).
    'vref' is the voltage of the voltage source used in the thermistor divider
        circuit.
    If the channel is open or shorted, the value None is returned.
    """
    # read the voltage across the thermistor
    v = dev.getAvg(ch)
    
    # Return None if the channel is open or shorted, otherwise calculate and
    # return the temperature value.
    if v < 0.02 * vref or v > 0.98 * vref:
        return None
    else:
        return th.TfromV(v, vref)