• MLTP - My Little Temp Project :-)

    From F. W.@3:770/3 to All on Tue Nov 9 10:26:18 2021
    Hi, I have a Raspberry Pico which is without any job. So I decided to do
    a little project without much time.

    The pico should read its temp-sensor and communicate the temp while
    blinking the LED: First Figure, second figure.

    23 degress (Celsius here) should be

    blink blink
    (pause)
    blink blink blink
    (wait 5 min)

    Connected to a USB-Powercable the pico can tell my through camera what temperature is in my caravan. ;-)

    But: How can I calculate the real room-temperature better? The results
    are not very accurate.

    Here is the source (public domain):

    # Thermometer - get room temperature by CPU-Temperature
    # and tell it users by blinking, FW 2021

    import machine, time

    led = machine.Pin(25, machine.Pin.OUT)

    # blink - blink "times" times with duration "duration"
    def blink (times, duration):
    for c in range (0,times):
    led.on()
    time.sleep_ms(duration)
    led.off()
    time.sleep_ms(duration)

    # Greetings: Machine okay
    blink (3, 100)
    time.sleep_ms(1000)

    while 1:

    # Get CPU-Temperature, calculate ° Celsius
    sensor_temp = machine.ADC(4)
    sensor_temp = sensor_temp.read_u16() * (3.3 / (65535))
    sensor_temp = int (27 - (sensor_temp - 0.706)/0.001721)
    zehner = int (sensor_temp / 10)
    einer = sensor_temp - (zehner * 10)
    einer = einer - 4 # room-temp vs. CPU-Temp

    for c in range (0, 2):
    blink (zehner, 250)
    time.sleep_ms (1000)
    blink (einer, 250)
    time.sleep_ms (1000)

    print ("Sensor-Temp: ", sensor_temp - 4, "° C")
    print ("Zehner.....: ", zehner)
    print ("Einer......: ", einer)


    Thank you!

    FW
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From gareth evans@3:770/3 to F. W. on Tue Nov 9 14:40:53 2021
    On 09/11/2021 09:26, F. W. wrote:
    Hi, I have a Raspberry Pico which is without any job. So I decided to do
    a little project without much time.

    The pico should read its temp-sensor and communicate the temp while
    blinking the LED: First Figure, second figure.

    23 degress (Celsius here) should be

    blink blink
    (pause)
    blink blink blink
    (wait 5 min)

    Even better with Morse Code?

    In 1972 from Floor 11 of Keynes Tower at Essex Uni. I
    had a small beacon flashing "HI".

    Long before the days of microprocessors, discounting
    the 4004, but done with reject (Plessey, I think)
    RTL logic chips.
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From A. Dumas@3:770/3 to F. W. on Tue Nov 9 14:53:49 2021
    F. W. <me@home.com> wrote:
    But: How can I calculate the real room-temperature better? The results
    are not very accurate.

    Attach an external sensor. Either way, you'd still have to calibrate it. So that's the only way: measure the temperature in a different, known good way
    and adjust the calculation accordingly.
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From Theo@3:770/3 to F. W. on Tue Nov 9 15:42:59 2021
    F. W. <me@home.com> wrote:
    But: How can I calculate the real room-temperature better? The results
    are not very accurate.

    Often the problem with internal temperature sensors is they're affected by self-heating. If the microcontroller is running in a loop it can consume
    some mA which raises its own temperature above ambient, at least until
    heat-in is equilibrated with extra heat loss due to the raised temperature.

    The solution to that is to go into low power suspend until the package has matched ambient temperature. Then take a measurement as the first thing you do, transmit it, and go back to sleep.

    In your code you could try longer sleep() periods between readings, but
    you'd have to check if that actually causes the device to go into suspend,
    or just spins in a loop. The other approach is to set a timer interrupt for some time hence and then 'Wait For Interrupt' (WFI instruction) which should enter CPU power saving mode. Although you might also need to consider
    whether any peripherals are also taking power.

    As has been mentioned, using an external temperature sensor that's not right next to the MCU or other heat generating components avoids this problem.

    Theo
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From David Higton@3:770/3 to F. W. on Tue Nov 9 17:28:40 2021
    In message <smderr$9a3$1@dont-email.me>
    "F. W." <me@home.com> wrote:

    Hi, I have a Raspberry Pico which is without any job. So I decided to do a little project without much time.

    The pico should read its temp-sensor and communicate the temp while
    blinking the LED: First Figure, second figure.

    23 degress (Celsius here) should be

    blink blink (pause) blink blink blink (wait 5 min)

    Connected to a USB-Powercable the pico can tell my through camera what temperature is in my caravan. ;-)

    But: How can I calculate the real room-temperature better? The results are not very accurate.

    I solved this problem some years ago by buying a Sensirion temperature
    and humidity sensor, which is factory calibrated. It communicates via
    IIC.

    May not be the sort of solution you want, of course! It depends on how
    much accuracy you need.

    David
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)
  • From druck@3:770/3 to F. W. on Tue Nov 9 20:58:49 2021
    On 09/11/2021 09:26, F. W. wrote:
    Hi, I have a Raspberry Pico which is without any job. So I decided to do
    a little project without much time.

    The pico should read its temp-sensor and communicate the temp while
    blinking the LED: First Figure, second figure.

    But: How can I calculate the real room-temperature better? The results
    are not very accurate.

    There are a number of cheap temperature sensors which you can connect
    via Pico's I2C pins, and will be far more accurate than the sensor in
    the chip package, which will be affected by the load on the CPU.

    I use htu21df or si7021 for temperature and humidity, and BME280 for temperature, humidity and pressure.

    Blinking lights are a start, but why not hook up either some 7 segment
    LEDs, or tiny LCD display to the Pico's output pins.

    ---druck
    --- SoupGate-Win32 v1.05
    * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)