pimoroni-pico/micropython/modules/breakout_icp10125
Phil Howard 6a3ba0d421 MicroPython: Shim MP_REGISTER_MODULE for >1.18 compat.
MicroPython has changed MP_REGISTER_MODULE to use only *two* args and now runs the preprocessing stage on files before running makemoduledefs.py.

This change avoids the build exploding, since the new regex matches the last two args as a single argument and generates a malformed module defs include.

The pattern here exploits the fact that 1.18 and below do not preprocess files, so *both* MP_REGISTER_MODULE lines are included in the source, but *only* the three arg version is matched by regex.

In >1.18 the files will be processed and the three arg version removed before makemoduledefs.py processes it.
2022-06-14 12:08:47 +01:00
..
README.md Python bindings & docs for ICP10125 2021-09-08 14:10:21 +01:00
breakout_icp10125.c MicroPython: Shim MP_REGISTER_MODULE for >1.18 compat. 2022-06-14 12:08:47 +01:00
breakout_icp10125.cpp MicroPython: Drop redundant Print. Saves 4K. 2022-06-13 18:59:51 +01:00
breakout_icp10125.h MicroPython: Drop redundant Print. Saves 4K. 2022-06-13 18:59:51 +01:00
micropython.cmake Python bindings & docs for ICP10125 2021-09-08 14:10:21 +01:00

README.md

ICP1025 High-accuracy Barometric Pressure & Temperature Sensor

The ICP1025 library is intended to drive the TDK InvenSense ICP10125 temperature and pressure sensor.

Getting Started

Construct a new PimoroniI2C instance for your specific board. Breakout Garden uses pins 4 & 5 and Pico Explorer uses pins 20 & 21.

import breakout_icp10125
import pimoroni_i2c

i2c = pimoroni_i2c.PimoroniI2C(4, 5)

icp10125 = breakout_icp10125.BreakoutICP10125(i2c)

Taking A Measurement

The measure method triggers a measurement, blocks for enough time for the measurement to complete, and returns the result as a tuple with three values:

  1. Temperature (degrees C)
  2. Pressure (Pa)
  3. Status

If the status is icp10125.STATUS_OK then the reading is valid. Otherwise you should probably discard it or attempt another reading.

For example, the following code will continuously poll the ICP10125 for NORMAL readings and print them out if they are valid:

import breakout_icp10125
import pimoroni_i2c

i2c = pimoroni_i2c.PimoroniI2C(4, 5)

icp10125 = breakout_icp10125.BreakoutICP10125(i2c)

while True:
    t, p, status = icp10125.measure()
    if status == icp10125.STATUS_OK:
        print(t, p)
    time.sleep(1.0)

Measurement Types

The ICP1025 has eight measurement commands. Four are supported by this library since the remaining four are identical save for the order of Temperature/Pressure data readout being reversed.

Each measurement type has a fixed duration.

Normal

Normal measurements are the default type, and take 7ms to complete offering a good balance of stability and speed.

result = icp10125.measure(icp10125.NORMAL)

Low Power

Low-power measurements take just 2ms and trade stability for speed/power efficiency.

result = icp10125.measure(icp10125.LOW_POWER)

Low Noise

Low-noise measurements take 24ms (roughly 3.5x as long as normal) and trade speed for stability.

result = icp10125.measure(icp10125.LOW_NOISE)

Ultra Low Noise

Ultra Low-noise measurements take 95ms

result = icp10125.measure(icp10125.ULTRA_LOW_NOISE)