peplow labs

One winter on the balcony: RP2040 temperature logger, results

· 5 min read · #rp2040 #micropython #measurement

Moved from the old blog in October 2026.

Last April I wrote about the new board for the balcony logger. It went outside in October and ran the whole winter without a reset. Here is what it measured from 1 December 2025 to 28 February 2026, and one thing I did wrong.

Setup

  • The board (Pico + DS3231) is inside, on the window sill. Only the sensor is outside.
  • SHT40 on a small breakout, 2.5 m of 4-wire cable through the window seal. Yes, I2C over 2.5 m is not what I2C was made for. At 20 kHz clock with 4.7 kΩ pull-ups it works. In the whole winter there were 3 readings with a CRC error, the code just reads again.
  • The balcony is on the 4th floor in Grochów, facing west-south-west. This is important later.
  • One sample every 5 minutes, 8 bytes each, one file per day on the Pico’s flash. 90 days is about 207 kB, the flash has 1.4 MB free.

The reading part, MicroPython:

from machine import I2C, Pin
import struct
import time

i2c = I2C(0, sda=Pin(4), scl=Pin(5), freq=20_000)
SHT40 = 0x44

def crc8(data):
    crc = 0xFF
    for b in data:
        crc ^= b
        for _ in range(8):
            crc = ((crc << 1) ^ 0x31) & 0xFF if crc & 0x80 else (crc << 1) & 0xFF
    return crc

def read_sht40(tries=3):
    for _ in range(tries):
        i2c.writeto(SHT40, b"\xfd")      # high repeatability, max 8.3 ms
        time.sleep_ms(10)
        d = i2c.readfrom(SHT40, 6)
        if crc8(d[0:2]) == d[2] and crc8(d[3:5]) == d[5]:
            t = -45 + 175 * (d[0] << 8 | d[1]) / 65535
            rh = -6 + 125 * (d[3] << 8 | d[4]) / 65535
            return t, min(100.0, max(0.0, rh))
    raise OSError("sht40: crc")

def log(ts, t, rh):
    name = "/log/%04d%02d%02d.bin" % time.localtime(ts)[:3]
    with open(name, "ab") as f:
        f.write(struct.pack("<Ihh", ts, round(t * 100), round(rh * 100)))

The DS3231 sets the Pico’s clock at boot, so after a power cut the timestamps are still right. It happened twice this winter (once a fuse, once me).

The mistake: sun

The first weeks of data looked strange. On some days in December the maximum was around +10 °C, or even 14.7 °C on 25 December, always between 14:00 and 16:30, while the rest of the day was around zero. A warm Christmas would be nice, but no.

The sensor was hanging in free air, protected from rain by a small plastic cap. In winter the sun is low, and from about 14:00 it shines directly onto the balcony. The sensor heated in the sun and measured itself, not the air.

Two sunny days, bare sensor vs. sensor in the shield

6 January with the bare sensor: +10.4 °C at 15:25 for a moment. 13 January in the shield: a normal smooth curve. Different days and different weather, but the shape is the point.

Proper weather stations put the sensor in a radiation shield: a stack of white plates with air gaps, so air goes through but the sun doesn’t reach the sensor. The DIY version is well known: plastic saucers for flower pots. I bought eight white ones, 18 cm, at Castorama, drilled the centres, and stacked them on an M5 threaded rod with 15 mm spacers. Total 41 zł and one evening. Installed on 9 January.

After that the afternoon peaks disappeared. On sunny days the shield still adds about half a degree at the worst moment. That is acceptable for a balcony.

What I can’t fix now: the maximum temperatures from 1 December to 8 January are not real on 8 sunny days. In the table below I give both numbers.

The winter

Daily min, max and mean temperature, December to February

Daily minimum to maximum as the band, daily mean as the line. The spikes before the dashed line are the sun, not the weather.

Month Min Max (raw) Max (without sun) Mean Days below 0 all day
Dec 2025 −8.2 °C, 31 Dec 03:35 14.7 °C 6.9 °C −1.4 °C 11
Jan 2026 −17.2 °C, 17 Jan 02:35 10.9 °C 4.6 °C −4.3 °C 17
Feb 2026 −8.8 °C, 2 Feb 02:55 8.4 °C 8.4 °C +1.4 °C 4

“Without sun” means I removed the samples between 14:00 and 16:30 on the days where the bare sensor obviously had sun. It’s a crude correction, but better than a Christmas with 14.7 °C.

The cold spell in the middle of January is the main event. Four nights in a row below −15 °C (15–18 January), and in total 107 hours below −10 °C during the winter. The coldest moment: −17.2 °C at 02:35 on 17 January.

Compared to the official station at the airport, my nights were a bit warmer, typically 1–2 °C. That is expected: 4th floor, a heated building directly behind the sensor, city around. My balcony is not a weather station, it’s my balcony, and that’s what I wanted to measure. For example, to know when the plants have to come in.

What next

  • The humidity data I didn’t look at yet. The SHT40 says 95–100 % RH on many nights, which is probably true in fog, but I want to check if the sensor recovers properly after condensation.
  • The silkscreen error from the board post is still there. I got used to it.
  • I want a second sensor inside the shield, a cheap DS18B20, to see how much two different sensors agree in the same place. That will be a short post, I think.

Questions or corrections: marek@peplow-labs.info. There are no comments here, but I read the mail.