From 41073800cb68d6d48f740e49bfec490a06965b43 Mon Sep 17 00:00:00 2001 From: Charly-sketch Date: Tue, 24 Mar 2026 09:15:58 +0100 Subject: [PATCH 01/25] chore(wsen-pads): remove test script --- lib/wsen-pads/examples/test.py | 292 --------------------------------- 1 file changed, 292 deletions(-) delete mode 100644 lib/wsen-pads/examples/test.py diff --git a/lib/wsen-pads/examples/test.py b/lib/wsen-pads/examples/test.py deleted file mode 100644 index be356bac..00000000 --- a/lib/wsen-pads/examples/test.py +++ /dev/null @@ -1,292 +0,0 @@ -from time import sleep - -from machine import I2C, Pin -from wsen_pads import WSEN_PADS -from wsen_pads.const import ( - ODR_1_HZ, - ODR_10_HZ, - REG_CTRL_1, - REG_CTRL_2, - REG_INT_SOURCE, - REG_STATUS, -) - - -def print_header(title): - print() - print("=" * 60) - print(title) - print("=" * 60) - - -def print_pass(name): - print("[PASS] {}".format(name)) - - -def print_fail(name, err=None): - if err is None: - print("[FAIL] {}".format(name)) - else: - print("[FAIL] {} -> {}".format(name, err)) - - -def dump_registers(sensor): - ctrl1 = sensor._read_reg(REG_CTRL_1) - ctrl2 = sensor._read_reg(REG_CTRL_2) - int_source = sensor._read_reg(REG_INT_SOURCE) - - print("CTRL_1 = 0x{:02X}".format(ctrl1)) - print("CTRL_2 = 0x{:02X}".format(ctrl2)) - print("data_ready() =", sensor.data_ready()) - print("INT_SOURCE = 0x{:02X}".format(int_source)) - - -def test_i2c_scan(i2c): - print_header("1) I2C scan") - devices = i2c.scan() - print("I2C devices found:", [hex(x) for x in devices]) - - if 0x5C in devices or 0x5D in devices: - print_pass("WSEN-PADS address found") - return True - else: - print_fail("WSEN-PADS address not found") - return False - - -def test_device_id(sensor): - print_header("2) Device ID") - dev_id = sensor.device_id() - print("Device ID:", hex(dev_id)) - - if dev_id == 0xB3: - print_pass("Device ID matches 0xB3") - return True - else: - print_fail("Device ID matches 0xB3", hex(dev_id)) - return False - - -def test_default_registers(sensor): - print_header("3) Default driver configuration") - dump_registers(sensor) - - ctrl1 = sensor._read_reg(REG_CTRL_1) - ctrl2 = sensor._read_reg(REG_CTRL_2) - - # BDU should be enabled by the driver - bdu_ok = bool(ctrl1 & 0x02) - - # IF_ADD_INC should be enabled by the driver - if_add_inc_ok = bool(ctrl2 & 0x10) - - if bdu_ok: - print_pass("BDU enabled") - else: - print_fail("BDU enabled") - - if if_add_inc_ok: - print_pass("IF_ADD_INC enabled") - else: - print_fail("IF_ADD_INC enabled") - - return bdu_ok and if_add_inc_ok - - -def test_soft_reset(sensor): - print_header("4) Soft reset") - try: - sensor.soft_reset() - sleep(0.05) - dump_registers(sensor) - - if sensor.device_id() == 0xB3: - print_pass("Soft reset") - return True - else: - print_fail("Soft reset", "device ID mismatch after reset") - return False - except Exception as err: - print_fail("Soft reset", err) - return False - - -def test_reboot(sensor): - print_header("5) Reboot") - try: - sensor.reboot() - sleep(1) - dump_registers(sensor) - - if sensor.device_id() == 0xB3: - print_pass("Reboot") - return True - else: - print_fail("Reboot", "device ID mismatch after reboot") - return False - except Exception as err: - print_fail("Reboot", err) - return False - - -def test_one_shot(sensor): - print_header("6) One-shot read") - - try: - pressure_hpa, temperature_c = sensor.read_one_shot() - - raw_p = sensor.pressure_raw() - raw_t = sensor.temperature_raw() - - print("Raw pressure :", raw_p) - print("Raw temperature :", raw_t) - print("Pressure : {:.2f} hPa".format(pressure_hpa)) - print("Temperature : {:.2f} °C".format(temperature_c)) - print("data_ready() :", sensor.data_ready()) - - # Basic sanity checks - MIN_PRESSURE = 260.0 - MAX_PRESSURE = 1260.0 - MIN_TEMPERATURE = -40.0 - MAX_TEMPERATURE = 85.0 - pressure_ok = MIN_PRESSURE <= pressure_hpa <= MAX_PRESSURE - temperature_ok = MIN_TEMPERATURE <= temperature_c <= MAX_TEMPERATURE - raw_ok = not (raw_p == 0 and raw_t == 0) - - if raw_ok: - print_pass("Raw data is not all zero") - else: - print_fail("Raw data is not all zero") - - if pressure_ok: - print_pass("Pressure is in a valid range") - else: - print_fail("Pressure is in a valid range", pressure_hpa) - - if temperature_ok: - print_pass("Temperature is in a valid range") - else: - print_fail("Temperature is in a valid range", temperature_c) - - return raw_ok and pressure_ok and temperature_ok - - except Exception as err: - print_fail("One-shot read", err) - return False - - -def test_continuous_mode(sensor, odr, label, wait_s=2): - print_header("7) Continuous mode - {}".format(label)) - - try: - sensor.set_continuous(odr=odr) - print("Waiting {} second(s) for fresh samples...".format(wait_s)) - sleep(wait_s) - - ok = True - - for i in range(5): - pressure_hpa = sensor.pressure_hpa() - temperature_c = sensor.temperature() - raw_p = sensor.pressure_raw() - raw_t = sensor.temperature_raw() - print( - "#{:d} P={:.2f} hPa T={:.2f} °C rawP={} rawT={} ready={}".format( - i + 1, - pressure_hpa, - temperature_c, - raw_p, - raw_t, - sensor.data_ready(), - ) - ) - - if raw_p == 0 and raw_t == 0: - ok = False - - sleep(0.5) - - sensor.power_off() - - if ok: - print_pass("Continuous mode - {}".format(label)) - else: - print_fail("Continuous mode - {}".format(label), "raw data stayed at zero") - - return ok - - except Exception as err: - print_fail("Continuous mode - {}".format(label), err) - return False - - -def test_status_flags(sensor): - print_header("8) STATUS helpers") - - try: - sensor.set_continuous(odr=ODR_1_HZ) - sleep(1.5) - - p_avail = sensor.pressure_ready() - t_avail = sensor.temperature_ready() - ready = sensor.data_ready() - - print("pressure_ready() =", p_avail) - print("temperature_ready() =", t_avail) - print("data_ready() =", ready) - - sensor.power_off() - - if p_avail or t_avail or ready: - print_pass("STATUS helper methods") - return True - else: - print_fail("STATUS helper methods") - return False - - except Exception as err: - print_fail("STATUS helper methods", err) - return False - - -def main(): - print_header("WSEN-PADS full driver test") - - i2c = I2C(1) - - if not test_i2c_scan(i2c): - print() - print("Stop: sensor not found on I2C bus.") - return - - try: - sensor = WSEN_PADS(i2c) - except Exception as err: - print_fail("Driver init", err) - return - - results = [] - - results.append(test_device_id(sensor)) - results.append(test_default_registers(sensor)) - results.append(test_soft_reset(sensor)) - results.append(test_reboot(sensor)) - results.append(test_one_shot(sensor)) - results.append(test_continuous_mode(sensor, ODR_1_HZ, "1 Hz", wait_s=2)) - results.append(test_continuous_mode(sensor, ODR_10_HZ, "10 Hz", wait_s=1)) - results.append(test_status_flags(sensor)) - - print_header("Final result") - - passed = sum(1 for x in results if x) - total = len(results) - - print("Passed: {}/{}".format(passed, total)) - - if passed == total: - print("All tests passed.") - else: - print("Some tests failed.") - - -main() From 19b86baf37c19d1a9d452fe511e1745eefe8cd5d Mon Sep 17 00:00:00 2001 From: Charly-sketch Date: Tue, 24 Mar 2026 09:22:27 +0100 Subject: [PATCH 02/25] style(wsen-pads): remove unused Pin import --- lib/wsen-pads/examples/altitude.py | 2 +- lib/wsen-pads/examples/basic_reader.py | 2 +- lib/wsen-pads/examples/continuous_reader.py | 2 +- lib/wsen-pads/examples/one_shot_reader.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/wsen-pads/examples/altitude.py b/lib/wsen-pads/examples/altitude.py index c60b72ea..23d428ed 100644 --- a/lib/wsen-pads/examples/altitude.py +++ b/lib/wsen-pads/examples/altitude.py @@ -1,6 +1,6 @@ from time import sleep -from machine import I2C, Pin +from machine import I2C from wsen_pads import WSEN_PADS SEA_LEVEL_PRESSURE = 1013.25 # depends on your location, you can adjust it for better altitude estimation diff --git a/lib/wsen-pads/examples/basic_reader.py b/lib/wsen-pads/examples/basic_reader.py index faef4864..2203c6d7 100644 --- a/lib/wsen-pads/examples/basic_reader.py +++ b/lib/wsen-pads/examples/basic_reader.py @@ -1,6 +1,6 @@ from time import sleep -from machine import I2C, Pin +from machine import I2C from wsen_pads import WSEN_PADS # Update the I2C bus number and pins to match your board diff --git a/lib/wsen-pads/examples/continuous_reader.py b/lib/wsen-pads/examples/continuous_reader.py index b97285be..d0704187 100644 --- a/lib/wsen-pads/examples/continuous_reader.py +++ b/lib/wsen-pads/examples/continuous_reader.py @@ -1,6 +1,6 @@ from time import sleep -from machine import I2C, Pin +from machine import I2C from wsen_pads import WSEN_PADS from wsen_pads.const import ODR_10_HZ diff --git a/lib/wsen-pads/examples/one_shot_reader.py b/lib/wsen-pads/examples/one_shot_reader.py index 63951c50..20835714 100644 --- a/lib/wsen-pads/examples/one_shot_reader.py +++ b/lib/wsen-pads/examples/one_shot_reader.py @@ -1,6 +1,6 @@ from time import sleep -from machine import I2C, Pin +from machine import I2C from wsen_pads import WSEN_PADS i2c = I2C(1) From 2ccf1da26f0c6e893b460dce87c180431e8fe832 Mon Sep 17 00:00:00 2001 From: Charly-sketch Date: Tue, 24 Mar 2026 09:53:27 +0100 Subject: [PATCH 03/25] feat(wsen-pads): add pressure_trend example --- lib/wsen-pads/examples/pressure_trend.py | 42 ++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 lib/wsen-pads/examples/pressure_trend.py diff --git a/lib/wsen-pads/examples/pressure_trend.py b/lib/wsen-pads/examples/pressure_trend.py new file mode 100644 index 00000000..d6d1fa4a --- /dev/null +++ b/lib/wsen-pads/examples/pressure_trend.py @@ -0,0 +1,42 @@ +from time import sleep +from machine import I2C +from wsen_pads import WSEN_PADS +from wsen_pads.const import ODR_10_HZ + +i2c = I2C(1) +sensor = WSEN_PADS(i2c) + +sensor.set_continuous(odr=ODR_10_HZ) + +pressure_history = [] +MAX_VALUES = 10 +THRESHOLD = 0.12 # sensitivity (hPa) ~ 1 meter altitude change + +def get_trend(values): + if len(values) < 2: + return "N/A" + + diff = values[-1] - values[0] + + if abs(diff) < THRESHOLD: + return "stable" + elif diff > 0: + return "falling" # pressure rising means lower altitude + else: + return "rising" + +while True: + pressure = sensor.pressure_hpa() + + # store value + pressure_history.append(pressure) + + # keep only last 10 values + if len(pressure_history) > MAX_VALUES: + pressure_history.pop(0) + + trend = get_trend(pressure_history) + + print("P:", pressure, "hPa Trend:", trend) + + sleep(10) From 1d31ac1e5e75e49b2da1af222424206f9a85c946 Mon Sep 17 00:00:00 2001 From: Charly-sketch Date: Tue, 24 Mar 2026 10:10:59 +0100 Subject: [PATCH 04/25] feat(wsen-pads): add floor_detector example --- lib/wsen-pads/examples/floor_detector.py | 48 ++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 lib/wsen-pads/examples/floor_detector.py diff --git a/lib/wsen-pads/examples/floor_detector.py b/lib/wsen-pads/examples/floor_detector.py new file mode 100644 index 00000000..b822aa44 --- /dev/null +++ b/lib/wsen-pads/examples/floor_detector.py @@ -0,0 +1,48 @@ +"""Measure altitude at startup as baseline, then loop and detect floor changes (each ~3m altitude difference = 1 floor). Print "Floor +1", "Floor -1", etc.""" + +from time import sleep + +from machine import I2C +from wsen_pads import WSEN_PADS +from wsen_pads.const import ODR_10_HZ + +i2c = I2C(1) +sensor = WSEN_PADS(i2c) +sensor.set_continuous(odr=ODR_10_HZ) + +SAMPLES_FOR_BASELINE = 20 +SAMPLES_PER_MEASURE = 10 +SEA_LEVEL_HPA = 1013.25 +METERS_PER_FLOOR = 0.1 #3.0 + +baseline_pressure_list = [] + +print("Measuring baseline pressure...") +for _ in range(SAMPLES_FOR_BASELINE): + pressure = sensor.pressure_hpa() + baseline_pressure_list.append(pressure) + + sleep(0.5) + +baseline_pressure = sum(baseline_pressure_list) / len(baseline_pressure_list) +print("Baseline pressure:", baseline_pressure, "hPa") + +while True: + pressure_samples = [] + + print("Measuring...") + for _ in range(SAMPLES_PER_MEASURE): + pressure = sensor.pressure_hpa() + pressure_samples.append(pressure) + + sleep(0.5) + + avg_pressure = sum(pressure_samples) / len(pressure_samples) + + # Calculate altitude difference from baseline using barometric formula + altitude_diff = 44330 * (1 - (avg_pressure / baseline_pressure) ** (1/5.255)) + + floor_change = round(altitude_diff / METERS_PER_FLOOR) + + print("Avg Pressure:", avg_pressure, "hPa Altitude Diff:", altitude_diff, "m Floor Change:", floor_change) + \ No newline at end of file From 1b17040cd277e3703b9f25e1cc6e601c6576cc18 Mon Sep 17 00:00:00 2001 From: Charly-sketch Date: Tue, 24 Mar 2026 10:19:53 +0100 Subject: [PATCH 05/25] refactor(wsen-pads): improve pressure_trend example - Compare avererage pressure to average pressure to detect trend --- lib/wsen-pads/examples/pressure_trend.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/wsen-pads/examples/pressure_trend.py b/lib/wsen-pads/examples/pressure_trend.py index d6d1fa4a..028fa170 100644 --- a/lib/wsen-pads/examples/pressure_trend.py +++ b/lib/wsen-pads/examples/pressure_trend.py @@ -1,3 +1,5 @@ +"""Read pressure every 10s, keep the last 10 values in a list, print whether pressure is rising, falling, or stable (useful for simple weather prediction)""" + from time import sleep from machine import I2C from wsen_pads import WSEN_PADS @@ -10,20 +12,24 @@ pressure_history = [] MAX_VALUES = 10 -THRESHOLD = 0.12 # sensitivity (hPa) ~ 1 meter altitude change +THRESHOLD = 0.5 # sensitivity (hPa) def get_trend(values): if len(values) < 2: return "N/A" - diff = values[-1] - values[0] + half = len(values) // 2 + first_half_avg = sum(values[:half]) / len(values[:half]) + second_half_avg = sum(values[half:]) / len(values[half:]) + + diff = second_half_avg - first_half_avg if abs(diff) < THRESHOLD: return "stable" elif diff > 0: - return "falling" # pressure rising means lower altitude - else: return "rising" + else: + return "falling" while True: pressure = sensor.pressure_hpa() @@ -37,6 +43,6 @@ def get_trend(values): trend = get_trend(pressure_history) - print("P:", pressure, "hPa Trend:", trend) + print("P:", pressure, "hPa, Pressure is", trend) sleep(10) From 4982d5cd6edc463d578aa70f5c82ad69bc5a3646 Mon Sep 17 00:00:00 2001 From: Charly-sketch Date: Tue, 24 Mar 2026 10:50:11 +0100 Subject: [PATCH 06/25] feat(wsen-pads): add threshold_alert example --- lib/wsen-pads/examples/treshold_alert.py | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 lib/wsen-pads/examples/treshold_alert.py diff --git a/lib/wsen-pads/examples/treshold_alert.py b/lib/wsen-pads/examples/treshold_alert.py new file mode 100644 index 00000000..cbfe2a28 --- /dev/null +++ b/lib/wsen-pads/examples/treshold_alert.py @@ -0,0 +1,34 @@ +"""Monitor pressure continuously and print an alert when pressure drops below a configurable threshold (e.g. storm detection).""" + +from time import sleep +from machine import I2C +from wsen_pads import WSEN_PADS +from wsen_pads.const import ODR_10_HZ + +PRESSURE_ALERT_HPA = 1021.8 # Alert threshold +READ_INTERVAL_S = 1 # Time between printed readings + +i2c = I2C(1) +sensor = WSEN_PADS(i2c) + +sensor.set_continuous(odr=ODR_10_HZ) + +print("Pressure monitor started") +print("Alert threshold:", PRESSURE_ALERT_HPA, "hPa") + +alert_active = False + +while True: + pressure = sensor.pressure_hpa() + + # Threshold detection + if pressure < PRESSURE_ALERT_HPA: + if not alert_active: + print("ALERT: pressure dropped below", PRESSURE_ALERT_HPA, "hPa") + alert_active = True + else: + if alert_active: + print("INFO: pressure back above", PRESSURE_ALERT_HPA, "hPa") + alert_active = False + + sleep(READ_INTERVAL_S) From 7073684bb52564182d7bfc8729bf99f5b17fe4ba Mon Sep 17 00:00:00 2001 From: Charly-sketch Date: Tue, 24 Mar 2026 11:02:39 +0100 Subject: [PATCH 07/25] feat(wsen-pads): add temp_pressure_display example --- .../examples/temp_pressure_display.py | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 lib/wsen-pads/examples/temp_pressure_display.py diff --git a/lib/wsen-pads/examples/temp_pressure_display.py b/lib/wsen-pads/examples/temp_pressure_display.py new file mode 100644 index 00000000..a496aec2 --- /dev/null +++ b/lib/wsen-pads/examples/temp_pressure_display.py @@ -0,0 +1,43 @@ +""" +Read temperature and pressure, format a nice display with units and a simple bar graph using # characters to visualize pressure (e.g. 1013.2 hPa [##########-----]) +""" +from machine import I2C +from time import sleep + +from wsen_pads import WSEN_PADS + +TEMP_MIN = 15.0 +TEMP_MAX = 30.0 +PRESS_MIN = 1020.0 +PRESS_MAX = 1023.0 + + +i2c = I2C(1) +sensor = WSEN_PADS(i2c) + +def bar_graph(value, vmin, vmax, width=20): + # Clamp value + if value < vmin: + value = vmin + elif value > vmax: + value = vmax + + ratio = (value - vmin) / (vmax - vmin) + filled = int(ratio * width) + + return "[" + "#" * filled + "-" * (width - filled) + "]" + +while True: + temp = sensor.temperature() + pressure = sensor.pressure_hpa() + + temp_bar = bar_graph(temp, TEMP_MIN, TEMP_MAX) + press_bar = bar_graph(pressure, PRESS_MIN, PRESS_MAX) + + line = "T:{:5.1f}°C {} | P:{:6.1f}hPa {}".format( + temp, temp_bar, pressure, press_bar + ) + + print("\r" + line, end="") + + sleep(1) From bc8f85855ac8f1c3179e8ad406f7052752c7142a Mon Sep 17 00:00:00 2001 From: Charly-sketch Date: Tue, 24 Mar 2026 11:10:30 +0100 Subject: [PATCH 08/25] feat(wsen-pads): add altitude_calibration example --- .../examples/altitude_calibration.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 lib/wsen-pads/examples/altitude_calibration.py diff --git a/lib/wsen-pads/examples/altitude_calibration.py b/lib/wsen-pads/examples/altitude_calibration.py new file mode 100644 index 00000000..16d76dbb --- /dev/null +++ b/lib/wsen-pads/examples/altitude_calibration.py @@ -0,0 +1,33 @@ +from machine import I2C +from time import sleep + +from wsen_pads import WSEN_PADS + +# Set your known altitude (in meters) for calibration +KNOWN_ALTITUDE = 12 # Example: your location altitude + +i2c = I2C(1) +sensor = WSEN_PADS(i2c) + + +pressure = sensor.pressure_hpa() + +# Compute sea-level pressure based on known altitude +# Formula derived from barometric equation +sea_level_pressure = pressure / (1 - (KNOWN_ALTITUDE / 44330.0)) ** 5.255 + +print("Calibration:") +print(" Measured pressure: {:.1f} hPa".format(pressure)) +print(" Known altitude: {:.1f} m".format(KNOWN_ALTITUDE)) +print(" Sea-level pressure: {:.1f} hPa".format(sea_level_pressure)) +print("-" * 50) + +while True: + pressure = sensor.pressure_hpa() + + # Compute altitude using calibrated sea-level pressure + altitude = 44330.0 * (1 - (pressure / sea_level_pressure) ** (1 / 5.255)) + + print("Altitude: {:6.1f} m | Pressure: {:6.1f} hPa".format(altitude, pressure)) + + sleep(1) From 8364a9058797bc83c2f740d0888fc9f291bf31ee Mon Sep 17 00:00:00 2001 From: Charly-sketch Date: Tue, 24 Mar 2026 11:12:22 +0100 Subject: [PATCH 09/25] style(wsen-pads): fix linter errors in examples --- lib/wsen-pads/examples/altitude_calibration.py | 2 +- lib/wsen-pads/examples/floor_detector.py | 1 - lib/wsen-pads/examples/pressure_trend.py | 1 + lib/wsen-pads/examples/temp_pressure_display.py | 2 +- lib/wsen-pads/examples/treshold_alert.py | 1 + 5 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/wsen-pads/examples/altitude_calibration.py b/lib/wsen-pads/examples/altitude_calibration.py index 16d76dbb..0e3b85d8 100644 --- a/lib/wsen-pads/examples/altitude_calibration.py +++ b/lib/wsen-pads/examples/altitude_calibration.py @@ -1,6 +1,6 @@ -from machine import I2C from time import sleep +from machine import I2C from wsen_pads import WSEN_PADS # Set your known altitude (in meters) for calibration diff --git a/lib/wsen-pads/examples/floor_detector.py b/lib/wsen-pads/examples/floor_detector.py index b822aa44..a6b97ba7 100644 --- a/lib/wsen-pads/examples/floor_detector.py +++ b/lib/wsen-pads/examples/floor_detector.py @@ -45,4 +45,3 @@ floor_change = round(altitude_diff / METERS_PER_FLOOR) print("Avg Pressure:", avg_pressure, "hPa Altitude Diff:", altitude_diff, "m Floor Change:", floor_change) - \ No newline at end of file diff --git a/lib/wsen-pads/examples/pressure_trend.py b/lib/wsen-pads/examples/pressure_trend.py index 028fa170..01e06695 100644 --- a/lib/wsen-pads/examples/pressure_trend.py +++ b/lib/wsen-pads/examples/pressure_trend.py @@ -1,6 +1,7 @@ """Read pressure every 10s, keep the last 10 values in a list, print whether pressure is rising, falling, or stable (useful for simple weather prediction)""" from time import sleep + from machine import I2C from wsen_pads import WSEN_PADS from wsen_pads.const import ODR_10_HZ diff --git a/lib/wsen-pads/examples/temp_pressure_display.py b/lib/wsen-pads/examples/temp_pressure_display.py index a496aec2..da8649ac 100644 --- a/lib/wsen-pads/examples/temp_pressure_display.py +++ b/lib/wsen-pads/examples/temp_pressure_display.py @@ -1,9 +1,9 @@ """ Read temperature and pressure, format a nice display with units and a simple bar graph using # characters to visualize pressure (e.g. 1013.2 hPa [##########-----]) """ -from machine import I2C from time import sleep +from machine import I2C from wsen_pads import WSEN_PADS TEMP_MIN = 15.0 diff --git a/lib/wsen-pads/examples/treshold_alert.py b/lib/wsen-pads/examples/treshold_alert.py index cbfe2a28..843f15be 100644 --- a/lib/wsen-pads/examples/treshold_alert.py +++ b/lib/wsen-pads/examples/treshold_alert.py @@ -1,6 +1,7 @@ """Monitor pressure continuously and print an alert when pressure drops below a configurable threshold (e.g. storm detection).""" from time import sleep + from machine import I2C from wsen_pads import WSEN_PADS from wsen_pads.const import ODR_10_HZ From 08b9938e8635e7291a85ee6c8e128043a455a5dc Mon Sep 17 00:00:00 2001 From: Charly-sketch Date: Tue, 24 Mar 2026 11:16:07 +0100 Subject: [PATCH 10/25] docs(wsen-pads): add new examples --- lib/wsen-pads/README.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/wsen-pads/README.md b/lib/wsen-pads/README.md index 0ca4c067..f2dc0cfe 100644 --- a/lib/wsen-pads/README.md +++ b/lib/wsen-pads/README.md @@ -443,14 +443,17 @@ This computes a corrected gain and offset so that the measured temperature bette Examples are available in the `examples` directory. -| Example | Description | -| ------------- | ----------------------------------- | -| `basic_reader.py` | Basic pressure and temperature read | -| `continuous_reader.py` | Continuous measurement example | -| `one_shot_reader.py` | One-shot measurement example | -| `altitude.py` | Altitude estimation from pressure | -| `test.py` | Driver test script | - +| Example | Description | +| -------------------------- | --------------------------------------------------------------------------- | +| `basic_reader.py` | Basic pressure and temperature read | +| `continuous_reader.py` | Continuous measurement example | +| `one_shot_reader.py` | One-shot measurement example | +| `altitude.py` | Altitude estimation from pressure | +| `altitude_calibration.py` | Calibrate sea-level pressure from known altitude and compute corrected altitude | +| `floor_detector.py` | Detect floor changes based on altitude variations | +| `pressure_trend.py` | Track pressure changes over time to detect trends | +| `temp_pressure_display.py` | Display formatted temperature and pressure with ASCII bar graphs | +| `treshold_alert.py` | Monitor pressure and trigger an alert when a threshold is crossed | --- From ae5b552aca52b7af4d23ebc98beb3de817357593 Mon Sep 17 00:00:00 2001 From: Charly-sketch Date: Tue, 24 Mar 2026 11:50:58 +0100 Subject: [PATCH 11/25] feat(wsen-pads): add weather_station example - Add a example that reccord weather condition and save them in a CVS file. --- lib/wsen-pads/examples/weather_station.py | 32 +++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 lib/wsen-pads/examples/weather_station.py diff --git a/lib/wsen-pads/examples/weather_station.py b/lib/wsen-pads/examples/weather_station.py new file mode 100644 index 00000000..971b3533 --- /dev/null +++ b/lib/wsen-pads/examples/weather_station.py @@ -0,0 +1,32 @@ +"""Loop that reads pressure + temperature every 5s, computes altitude, prints a formatted summary, and logs each measurement to a CSV file on the DAPLink flash using daplink_flash (set_filename, write_line). The file can then be read back from USB mass storage.""" + +from time import sleep, sleep_ms + +from daplink_flash import DaplinkFlash +from machine import I2C +from wsen_pads import WSEN_PADS +from wsen_pads.const import ODR_10_HZ + +i2c = I2C(1) + +sensor = WSEN_PADS(i2c) +flash = DaplinkFlash(i2c) + +sensor.set_continuous(odr=ODR_10_HZ) + +# Set filename and erase +flash.set_filename("weather_station", "CSV") +flash.clear_flash() +sleep_ms(500) +print("Flash erased.") + +flash.write_line("temperature;pressure") + +while True: + pressure = sensor.pressure_hpa() + temperature = sensor.temperature() + + print("P:", pressure, "hPa T:", temperature, "°C") + flash.write_line(f"{temperature};{pressure}") + + sleep(0.1) From df711748d718d793c78a005d5751a9b0a957663a Mon Sep 17 00:00:00 2001 From: Charly-sketch Date: Tue, 24 Mar 2026 11:52:23 +0100 Subject: [PATCH 12/25] docs(wsen-pads): add weather_station example to README --- lib/wsen-pads/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/wsen-pads/README.md b/lib/wsen-pads/README.md index f2dc0cfe..e2d83628 100644 --- a/lib/wsen-pads/README.md +++ b/lib/wsen-pads/README.md @@ -454,6 +454,7 @@ Examples are available in the `examples` directory. | `pressure_trend.py` | Track pressure changes over time to detect trends | | `temp_pressure_display.py` | Display formatted temperature and pressure with ASCII bar graphs | | `treshold_alert.py` | Monitor pressure and trigger an alert when a threshold is crossed | +| `weather_station.py` | Monitor weather condition and register them in a CSV file on the board | --- From c2422890e94a8abf357e9e5cea936e69518e2238 Mon Sep 17 00:00:00 2001 From: Charly-sketch Date: Tue, 24 Mar 2026 13:52:21 +0100 Subject: [PATCH 13/25] style(wsen-pads): remove unused constant in floor_detector --- lib/wsen-pads/examples/floor_detector.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/wsen-pads/examples/floor_detector.py b/lib/wsen-pads/examples/floor_detector.py index a6b97ba7..749d97aa 100644 --- a/lib/wsen-pads/examples/floor_detector.py +++ b/lib/wsen-pads/examples/floor_detector.py @@ -12,8 +12,7 @@ SAMPLES_FOR_BASELINE = 20 SAMPLES_PER_MEASURE = 10 -SEA_LEVEL_HPA = 1013.25 -METERS_PER_FLOOR = 0.1 #3.0 +METERS_PER_FLOOR = 0.3 baseline_pressure_list = [] From 44022e3aa846010c7a08fcbb8171d1efd10f64b9 Mon Sep 17 00:00:00 2001 From: Charly-sketch Date: Tue, 24 Mar 2026 13:56:44 +0100 Subject: [PATCH 14/25] refactor(wsen-pads): use a single read in temp_pressure_display --- lib/wsen-pads/examples/temp_pressure_display.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/wsen-pads/examples/temp_pressure_display.py b/lib/wsen-pads/examples/temp_pressure_display.py index da8649ac..8f5dbf77 100644 --- a/lib/wsen-pads/examples/temp_pressure_display.py +++ b/lib/wsen-pads/examples/temp_pressure_display.py @@ -28,9 +28,7 @@ def bar_graph(value, vmin, vmax, width=20): return "[" + "#" * filled + "-" * (width - filled) + "]" while True: - temp = sensor.temperature() - pressure = sensor.pressure_hpa() - + pressure, temp = sensor.read() temp_bar = bar_graph(temp, TEMP_MIN, TEMP_MAX) press_bar = bar_graph(pressure, PRESS_MIN, PRESS_MAX) From 8dd7c79312aa5f82fef15ea898814a0db108cb9a Mon Sep 17 00:00:00 2001 From: Charly-sketch Date: Tue, 24 Mar 2026 13:58:31 +0100 Subject: [PATCH 15/25] fix(wsen-pads): rename threshold_alert typo --- lib/wsen-pads/examples/{treshold_alert.py => threshold_alert.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename lib/wsen-pads/examples/{treshold_alert.py => threshold_alert.py} (100%) diff --git a/lib/wsen-pads/examples/treshold_alert.py b/lib/wsen-pads/examples/threshold_alert.py similarity index 100% rename from lib/wsen-pads/examples/treshold_alert.py rename to lib/wsen-pads/examples/threshold_alert.py From 6ebc61cdd12e8f0ddb7989ffd618374df3592461 Mon Sep 17 00:00:00 2001 From: Charly-sketch Date: Tue, 24 Mar 2026 14:01:55 +0100 Subject: [PATCH 16/25] fix(wsen-pads): fix weather_station example - Sleeping time put to 5s - Shorter CSV file name --- lib/wsen-pads/examples/weather_station.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/wsen-pads/examples/weather_station.py b/lib/wsen-pads/examples/weather_station.py index 971b3533..cf95410b 100644 --- a/lib/wsen-pads/examples/weather_station.py +++ b/lib/wsen-pads/examples/weather_station.py @@ -15,7 +15,7 @@ sensor.set_continuous(odr=ODR_10_HZ) # Set filename and erase -flash.set_filename("weather_station", "CSV") +flash.set_filename("WSTATION", "CSV") flash.clear_flash() sleep_ms(500) print("Flash erased.") @@ -29,4 +29,4 @@ print("P:", pressure, "hPa T:", temperature, "°C") flash.write_line(f"{temperature};{pressure}") - sleep(0.1) + sleep(5) From f83b080517938aa398a16e3c57edc7fbb1b4708a Mon Sep 17 00:00:00 2001 From: Charly-sketch Date: Tue, 24 Mar 2026 14:09:30 +0100 Subject: [PATCH 17/25] style(wsen-pads): fix weather_station example formatting --- lib/wsen-pads/examples/weather_station.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/wsen-pads/examples/weather_station.py b/lib/wsen-pads/examples/weather_station.py index cf95410b..538d06b5 100644 --- a/lib/wsen-pads/examples/weather_station.py +++ b/lib/wsen-pads/examples/weather_station.py @@ -27,6 +27,6 @@ temperature = sensor.temperature() print("P:", pressure, "hPa T:", temperature, "°C") - flash.write_line(f"{temperature};{pressure}") + flash.write_line(f"{temperature:.1f};{pressure:.1f}") sleep(5) From fcf76299ea55755ed1b3dd6c0dc03f783060fd53 Mon Sep 17 00:00:00 2001 From: Charly-sketch Date: Tue, 24 Mar 2026 14:17:49 +0100 Subject: [PATCH 18/25] test(wsen-pads): add coverage for init errors and status helpers Add missing test scenarios to improve robustness and cover critical driver behaviors: Initialization & identification: - Add test for device absence on I2C bus (WSENPADSDeviceNotFound) - Add test for invalid DEVICE_ID (WSENPADSInvalidDevice) - Add test for boot timeout when BOOT_ON never clears (WSENPADSTimeout) Continuous mode validation: - Add tests ensuring set_continuous() rejects invalid ODR values - Add tests rejecting low-noise mode at unsupported ODR (100 Hz, 200 Hz) Status helpers: - Add tests for pressure_ready(), temperature_ready(), and data_ready() - Validate behavior for all STATUS combinations (none, pressure only, temperature only, both) Reset / reboot behavior: - Add tests ensuring soft_reset() and reboot() reapply default configuration (BDU enabled, power-down mode, auto-increment enabled, low-noise disabled) Calibration: - Add test ensuring calibrate_temperature() rejects identical measured points These tests improve coverage of error paths, state transitions, and public helper methods, ensuring better reliability of the driver in both mock and hardware contexts. --- tests/scenarios/wsen_pads.yaml | 239 +++++++++++++++++++++++++++++++++ 1 file changed, 239 insertions(+) diff --git a/tests/scenarios/wsen_pads.yaml b/tests/scenarios/wsen_pads.yaml index cf7b214d..b408a27e 100644 --- a/tests/scenarios/wsen_pads.yaml +++ b/tests/scenarios/wsen_pads.yaml @@ -121,3 +121,242 @@ tests: prompt: "Ces valeurs sont-elles cohérentes (pression ~1013 hPa, température ambiante) ?" expect_true: true mode: [hardware] + + # --------------------------------------------------------------------------- + # Init / identification + # --------------------------------------------------------------------------- + + - name: "Device absent raises exception" + action: script + script: | + from wsen_pads import WSEN_PADS + from wsen_pads.exceptions import WSENPADSDeviceNotFound + + try: + i2c.scan = lambda: [] + WSEN_PADS(i2c, address=0x5D) + result = False + except WSENPADSDeviceNotFound: + result = True + except Exception: + result = False + expect_true: true + mode: [mock] + + - name: "Invalid DEVICE_ID raises exception" + action: script + script: | + from wsen_pads import WSEN_PADS + from wsen_pads.exceptions import WSENPADSInvalidDevice + + original = i2c._registers[0x0F] + i2c._registers[0x0F] = bytes([0x00]) + + try: + WSEN_PADS(i2c, address=0x5D) + result = False + except WSENPADSInvalidDevice: + result = True + except Exception: + result = False + + i2c._registers[0x0F] = original + expect_true: true + mode: [mock] + + - name: "Boot timeout raises exception at init" + action: script + script: | + from wsen_pads import WSEN_PADS + from wsen_pads.exceptions import WSENPADSTimeout + + original = i2c._registers[0x24] + i2c._registers[0x24] = bytes([0x80]) # INT_SOURCE_BOOT_ON + + try: + WSEN_PADS(i2c, address=0x5D) + result = False + except WSENPADSTimeout: + result = True + except Exception: + result = False + + i2c._registers[0x24] = original + expect_true: true + mode: [mock] + + # --------------------------------------------------------------------------- + # Continuous mode validation + # --------------------------------------------------------------------------- + + - name: "set_continuous rejects invalid ODR" + action: script + script: | + try: + dev.set_continuous(odr=99) + result = False + except ValueError: + result = True + except Exception: + result = False + expect_true: true + mode: [mock] + + - name: "set_continuous rejects low-noise at 100 Hz" + action: script + script: | + try: + dev.set_continuous(odr=0x06, low_noise=True) + result = False + except ValueError: + result = True + except Exception: + result = False + expect_true: true + mode: [mock] + + - name: "set_continuous rejects low-noise at 200 Hz" + action: script + script: | + try: + dev.set_continuous(odr=0x07, low_noise=True) + result = False + except ValueError: + result = True + except Exception: + result = False + expect_true: true + mode: [mock] + + # --------------------------------------------------------------------------- + # Status helpers + # --------------------------------------------------------------------------- + + - name: "pressure_ready false when status empty" + action: script + script: | + i2c._registers[0x27] = bytes([0x00]) + result = dev.pressure_ready() + i2c._registers[0x27] = bytes([0x03]) + expect_false: true + mode: [mock] + + - name: "temperature_ready false when status empty" + action: script + script: | + i2c._registers[0x27] = bytes([0x00]) + result = dev.temperature_ready() + i2c._registers[0x27] = bytes([0x03]) + expect_false: true + mode: [mock] + + - name: "data_ready false when status empty" + action: script + script: | + i2c._registers[0x27] = bytes([0x00]) + result = dev.data_ready() + i2c._registers[0x27] = bytes([0x03]) + expect_false: true + mode: [mock] + + - name: "pressure_ready true when only pressure available" + action: script + script: | + i2c._registers[0x27] = bytes([0x01]) # STATUS_P_DA + result = dev.pressure_ready() + i2c._registers[0x27] = bytes([0x03]) + expect_true: true + mode: [mock] + + - name: "temperature_ready true when only temperature available" + action: script + script: | + i2c._registers[0x27] = bytes([0x02]) # STATUS_T_DA + result = dev.temperature_ready() + i2c._registers[0x27] = bytes([0x03]) + expect_true: true + mode: [mock] + + - name: "data_ready false when only pressure available" + action: script + script: | + i2c._registers[0x27] = bytes([0x01]) # STATUS_P_DA + result = dev.data_ready() + i2c._registers[0x27] = bytes([0x03]) + expect_false: true + mode: [mock] + + - name: "data_ready false when only temperature available" + action: script + script: | + i2c._registers[0x27] = bytes([0x02]) # STATUS_T_DA + result = dev.data_ready() + i2c._registers[0x27] = bytes([0x03]) + expect_false: true + mode: [mock] + + - name: "data_ready true when pressure and temperature available" + action: script + script: | + i2c._registers[0x27] = bytes([0x03]) # STATUS_P_DA | STATUS_T_DA + result = dev.data_ready() + expect_true: true + mode: [mock] + + # --------------------------------------------------------------------------- + # Reset / reboot + # --------------------------------------------------------------------------- + + - name: "soft_reset reapplies default configuration" + action: script + script: | + dev.set_continuous(odr=0x03, low_noise=True, low_pass=True, low_pass_strong=True) + dev.soft_reset() + + ctrl1 = i2c._registers[0x10][0] + ctrl2 = i2c._registers[0x11][0] + + bdu_ok = (ctrl1 & 0x02) == 0x02 + odr_power_down = (ctrl1 & 0x70) == 0x00 + auto_inc_ok = (ctrl2 & 0x10) == 0x10 + low_noise_off = (ctrl2 & 0x02) == 0x00 + + result = bdu_ok and odr_power_down and auto_inc_ok and low_noise_off + expect_true: true + mode: [mock] + + - name: "reboot reapplies default configuration" + action: script + script: | + dev.set_continuous(odr=0x03, low_noise=False, low_pass=True, low_pass_strong=True) + i2c._registers[0x24] = bytes([0x00]) # boot already finished + dev.reboot() + + ctrl1 = i2c._registers[0x10][0] + ctrl2 = i2c._registers[0x11][0] + + bdu_ok = (ctrl1 & 0x02) == 0x02 + odr_power_down = (ctrl1 & 0x70) == 0x00 + auto_inc_ok = (ctrl2 & 0x10) == 0x10 + low_noise_off = (ctrl2 & 0x02) == 0x00 + + result = bdu_ok and odr_power_down and auto_inc_ok and low_noise_off + expect_true: true + mode: [mock] + + # --------------------------------------------------------------------------- + # Calibration + # --------------------------------------------------------------------------- + + - name: "Temperature calibration rejects identical measured points" + action: script + script: | + try: + dev.calibrate_temperature(20.0, 25.0, 30.0, 25.0) + result = False + except ValueError: + result = True + except Exception: + result = False + expect_true: true + mode: [mock] From be7caf507a83798a05bb582b93c6db8259918b97 Mon Sep 17 00:00:00 2001 From: Charly-sketch Date: Tue, 24 Mar 2026 14:18:35 +0100 Subject: [PATCH 19/25] docs(wsen-pads): fix README typo --- lib/wsen-pads/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/wsen-pads/README.md b/lib/wsen-pads/README.md index e2d83628..a9dac7c6 100644 --- a/lib/wsen-pads/README.md +++ b/lib/wsen-pads/README.md @@ -453,7 +453,7 @@ Examples are available in the `examples` directory. | `floor_detector.py` | Detect floor changes based on altitude variations | | `pressure_trend.py` | Track pressure changes over time to detect trends | | `temp_pressure_display.py` | Display formatted temperature and pressure with ASCII bar graphs | -| `treshold_alert.py` | Monitor pressure and trigger an alert when a threshold is crossed | +| `threshold_alert.py` | Monitor pressure and trigger an alert when a threshold is crossed | | `weather_station.py` | Monitor weather condition and register them in a CSV file on the board | --- From da452d8087d7ed2a260c32ecdc7f842d3c398d91 Mon Sep 17 00:00:00 2001 From: Charly-sketch Date: Tue, 24 Mar 2026 14:33:25 +0100 Subject: [PATCH 20/25] chore: gitignore node modules --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 0b3a29d0..3671a887 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ __pycache__ *.egg-info */dist/ *.org -*.1 \ No newline at end of file +*.1 +node_modules/ From 1278ac15c4915ae80b5931404e688b95a8cc7c32 Mon Sep 17 00:00:00 2001 From: Charly-sketch Date: Tue, 24 Mar 2026 15:04:12 +0100 Subject: [PATCH 21/25] chore: gitignore up to date --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 3671a887..fb133f3a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ __pycache__ */dist/ *.org *.1 +78e43b91-b6a2-4e0a-99c2-3f6f74828063_ExportBlock-935e0d48-7286-4b74-aa60-ccd18217ac01 node_modules/ +CLAUDE.md From 2de4b1ba664eed9c9d32c888bb69b209324de532 Mon Sep 17 00:00:00 2001 From: Charly-sketch Date: Tue, 24 Mar 2026 15:19:25 +0100 Subject: [PATCH 22/25] style(wsen-pads): fix lint errors --- lib/wsen-pads/examples/temp_pressure_display.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/wsen-pads/examples/temp_pressure_display.py b/lib/wsen-pads/examples/temp_pressure_display.py index 8f5dbf77..5eb4a57f 100644 --- a/lib/wsen-pads/examples/temp_pressure_display.py +++ b/lib/wsen-pads/examples/temp_pressure_display.py @@ -28,7 +28,7 @@ def bar_graph(value, vmin, vmax, width=20): return "[" + "#" * filled + "-" * (width - filled) + "]" while True: - pressure, temp = sensor.read() + pressure, temp = sensor.read() temp_bar = bar_graph(temp, TEMP_MIN, TEMP_MAX) press_bar = bar_graph(pressure, PRESS_MIN, PRESS_MAX) From a68d764b9324550195191fef1b31b0dd2552445d Mon Sep 17 00:00:00 2001 From: Charly-sketch Date: Tue, 24 Mar 2026 16:20:19 +0100 Subject: [PATCH 23/25] fix(wsen-pads): fix constant temp_pressure_display --- lib/wsen-pads/examples/temp_pressure_display.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/wsen-pads/examples/temp_pressure_display.py b/lib/wsen-pads/examples/temp_pressure_display.py index 5eb4a57f..bb558bea 100644 --- a/lib/wsen-pads/examples/temp_pressure_display.py +++ b/lib/wsen-pads/examples/temp_pressure_display.py @@ -8,8 +8,8 @@ TEMP_MIN = 15.0 TEMP_MAX = 30.0 -PRESS_MIN = 1020.0 -PRESS_MAX = 1023.0 +PRESS_MIN = 960.0 +PRESS_MAX = 1060.0 i2c = I2C(1) From 1e649533ca6386997b6abb13f3bcef4a7ad0f5d2 Mon Sep 17 00:00:00 2001 From: Charly-sketch Date: Tue, 24 Mar 2026 16:22:22 +0100 Subject: [PATCH 24/25] fix(wsen-pads): fix constant threshold_alert --- lib/wsen-pads/examples/threshold_alert.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/wsen-pads/examples/threshold_alert.py b/lib/wsen-pads/examples/threshold_alert.py index 843f15be..1aac09d3 100644 --- a/lib/wsen-pads/examples/threshold_alert.py +++ b/lib/wsen-pads/examples/threshold_alert.py @@ -6,7 +6,7 @@ from wsen_pads import WSEN_PADS from wsen_pads.const import ODR_10_HZ -PRESSURE_ALERT_HPA = 1021.8 # Alert threshold +PRESSURE_ALERT_HPA = 1000 # Alert threshold READ_INTERVAL_S = 1 # Time between printed readings i2c = I2C(1) From 140836256e46e220a8b0c133e5d886114406f5db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20NEDJAR?= Date: Tue, 24 Mar 2026 16:38:59 +0100 Subject: [PATCH 25/25] fix(wsen-pads): Fix f-string in weather_station and floor height constant. --- lib/wsen-pads/examples/floor_detector.py | 2 +- lib/wsen-pads/examples/weather_station.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/wsen-pads/examples/floor_detector.py b/lib/wsen-pads/examples/floor_detector.py index 749d97aa..f6f2989f 100644 --- a/lib/wsen-pads/examples/floor_detector.py +++ b/lib/wsen-pads/examples/floor_detector.py @@ -12,7 +12,7 @@ SAMPLES_FOR_BASELINE = 20 SAMPLES_PER_MEASURE = 10 -METERS_PER_FLOOR = 0.3 +METERS_PER_FLOOR = 3.0 baseline_pressure_list = [] diff --git a/lib/wsen-pads/examples/weather_station.py b/lib/wsen-pads/examples/weather_station.py index 538d06b5..a4348c8f 100644 --- a/lib/wsen-pads/examples/weather_station.py +++ b/lib/wsen-pads/examples/weather_station.py @@ -27,6 +27,6 @@ temperature = sensor.temperature() print("P:", pressure, "hPa T:", temperature, "°C") - flash.write_line(f"{temperature:.1f};{pressure:.1f}") + flash.write_line("{:.1f};{:.1f}".format(temperature, pressure)) sleep(5)