weatherstation icon indicating copy to clipboard operation
weatherstation copied to clipboard

Need to throttle updates?

Open joreilly opened this issue 9 years ago • 6 comments

I'm using this with Raspberry Pi and Rainbow HAT. If I leave it running the temperature shown steadily increases. It might be case that I need to add heatsink to the processor but wondering if perhaps the code should throttle number of updates it does. Not a big issue in the scheme of things (realise this is just a demo).

joreilly avatar Dec 17 '16 21:12 joreilly

@joreilly I think this is coming from the apa102 RGB LED that are just above the temperature sensor.

You could try to dim them off and see if it affect the temperature.

proppy avatar Dec 18 '16 00:12 proppy

I commented out code to set LEDs but still seeing temperature steadily going up. I also tried passing in my longer delay (1000000 microseconds for example) to mSensorManager.registerListener() but it didn't seem to take effect.

joreilly avatar Dec 18 '16 09:12 joreilly

Pimoroni recently added the following note to the product page

Temperature readings are affected by heat radiated from your Pi’s CPU and the onboard LEDs; calibration can help to correct temperature readings. bstrobl, on the Raspberry Pi forums, suggests to use the formula: corrected temp. = measured temp. - (CPU temp. - measured temp.) / 2. Using a Mini Black HAT Hack3r can also help.

Maybe we could implement that as an helper function in the Rainbow Hat driver

/cc @gguuss

proppy avatar Jan 09 '17 21:01 proppy

Here is something to keep the display from flickering with each change. It also converts to Fahrenheit:

private SensorEventListener mTemperatureListener = new SensorEventListener() {
    @Override
    public void onSensorChanged(SensorEvent event) {
        float newTemperature = event.values[0];
        if (Math.abs(newTemperature - mLastTemperature) > 1) {
            mLastTemperature = event.values[0];
            Log.d(TAG, "sensor changed: " + mLastTemperature);
            if (mDisplayMode == DisplayMode.TEMPERATURE) {
                float fahrenheit = 32 + (mLastTemperature * 9 / 5);
                updateDisplay(fahrenheit);
            }
        }
    }

    @Override
    public void onAccuracyChanged(Sensor sensor, int accuracy) {
        Log.d(TAG, "accuracy changed: " + accuracy);
    }
};

Emeritus-DarranKelinske avatar Jun 29 '17 03:06 Emeritus-DarranKelinske

did anyone try the pimoroni suggestion? what were the results?

Emeritus-DarranKelinske avatar Jun 29 '17 03:06 Emeritus-DarranKelinske

Pimoroni recently added the following note to the product page

Temperature readings are affected by heat radiated from your Pi’s CPU and the onboard LEDs; calibration can help to correct temperature readings. bstrobl, on the Raspberry Pi forums, suggests to use the formula: corrected temp. = measured temp. - (CPU temp. - measured temp.) / 2. Using a Mini Black HAT Hack3r can also help.

Maybe we could implement that as an helper function in the Rainbow Hat driver

/cc @gguuss

You cannot read the CPU temp on Android Things but even if you could this would not work. I have tried to move the Rainbow Hat away from the Android Things board via a 20cm long 2x20 GPIO cable. The temp sensor still measures data from another reality, e.g. 30C+ at normal room temp. This is a design flaw in the Rainbow Hat itself.

msagi avatar Mar 06 '19 23:03 msagi