Metadata-Version: 2.4
Name: grokesplib
Version: 2.5.0
Summary: Student-friendly ESP32 MicroPython drivers for sensors, displays, servos, keypads, and RTCs
License-Expression: MIT
Project-URL: Homepage, https://github.com/Alamin54017/groklib
Project-URL: Repository, https://github.com/Alamin54017/groklib
Project-URL: Issues, https://github.com/Alamin54017/groklib/issues
Project-URL: Changelog, https://github.com/Alamin54017/groklib/blob/main/CHANGELOG.md
Keywords: micropython,esp32,education,sensors,robotics,rtc
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Education
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: Implementation :: MicroPython
Classifier: Topic :: Education
Classifier: Topic :: System :: Hardware
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# GROK: ESP32 MicroPython Hardware Library

![Version 2.5.0](https://img.shields.io/badge/version-2.5.0-blue)
![MicroPython](https://img.shields.io/badge/runtime-MicroPython-green)
![MIT License](https://img.shields.io/badge/license-MIT-blue)

**Learn electronics with small, readable Python programs.** GROK provides
student-friendly drivers for digital inputs and outputs, analog sensors,
HC-SR04 ultrasonic sensors, DHT11, hobby servos, I2C LCDs, DS3231/DS1307 clocks,
MAX30100/MAX30102 pulse sensors, and 4x4 keypads.

```python
import grok as gs

sensor = gs.ultrasonic_init(trigger_pin=5, echo_pin=18)

while True:
    distance = sensor.read()
    if distance is None:
        print("No valid echo: check wiring or move the object")
    else:
        print("Distance:", distance, "cm")
    gs.delay_ms(100)
```

The PyPI distribution is **`grokesplib`**. The Python module is **`grok`**.
Programs run on an **ESP32 with MicroPython**, where `machine`, `dht`,
`time.sleep_ms()`, and the other hardware APIs are available. Installing with
desktop `pip` distributes the library file; it does not give a PC ESP32 GPIOs.

## Contents

- [Install on your board](#install-on-your-board)
- [Wiring and choosing GPIOs](#wiring-and-choosing-gpios)
- [When to call which function](#when-to-call-which-function)
- [Initialization reference](#initialization-reference)
- [Digital input and output](#digital-input-and-output)
- [Ultrasonic distance and missing readings](#ultrasonic-distance-and-missing-readings)
- [DHT11 temperature and humidity](#dht11-temperature-and-humidity)
- [Analog sensors](#analog-sensors)
- [Servo](#servo)
- [I2C scanner and shared buses](#i2c-scanner-and-shared-buses)
- [LCD 16x2](#lcd-16x2)
- [RTC: DS3231 and DS1307](#rtc-ds3231-and-ds1307)
- [MAX30100 and MAX30102](#max30100-and-max30102)
- [4x4 keypad](#4x4-keypad)
- [Utilities and advanced classes](#utilities-and-advanced-classes)
- [Classroom projects](#classroom-projects)
- [Errors and troubleshooting](#errors-and-troubleshooting)
- [Changes from 2.3.0](#changes-from-230)
- [Development and publishing on PyPI](#development-and-publishing-on-pypi)
- [License and references](#license-and-references)

## Install on your board

### Option 1: Thonny Manage packages (beginner friendly)

After the maintainer publishes `grokesplib` on PyPI, students can install it
without copying or pasting the library:

1. Connect an ESP32 running MicroPython by USB.
2. In Thonny, select **MicroPython (ESP32)** and the correct serial port.
3. Open **Tools → Manage packages...**. Check that the target is the
   MicroPython device's library directory, normally `/lib`.
4. Search for **`grokesplib`**, select the package, and click **Install**.
5. Close the dialog and use **Stop/Restart** to reload the interpreter.
6. Run the installation check below, then write your own program using
   `import grok as gs`.

Use **Manage packages** for this library. **Manage plug-ins** installs extensions
for Thonny itself. Selecting local Python installs onto your computer rather
than the ESP32. The computer needs internet access; the board does not need Wi-Fi
for installation over USB. The package declares its MicroPython runtime so
Thonny can recognize it without the generic-package confirmation.

For offline installation, a teacher can provide the built
`grokesplib-2.5.0-py3-none-any.whl`. With the ESP32 interpreter selected, use
**Manage packages → Install from local file** and select that wheel.

For updates, reopen Manage packages, select/search `grokesplib`, install the
new version using the available Upgrade/Install control, and restart the
interpreter. Check `gs.__version__` again. If an older manually installed
`/grok.py` hides the managed `/lib/grok.py`, back up and remove that older file
with Thonny's device file browser, then restart.

Thonny 5.0's bundled installer is checked using a temporary filesystem target:
package recognition, installation into `/lib`, version listing, reinstallation,
and removal. Physical USB/device installation still needs testing on your board.
See [Thonny's package installation guide](https://github.com/thonny/thonny/wiki/InstallingPackages).

### Option 2: save the library with Thonny

1. Install ESP32 MicroPython firmware appropriate for your exact board.
2. Connect the board by USB and select its MicroPython interpreter in Thonny.
3. Open this repository's `grok.py` and save it **to the MicroPython device**
   as `grok.py` in the root directory, or as `/lib/grok.py`.
4. Save your own program as `main.py` on the device to run it at startup.
5. Restart the interpreter after updating the library.

Do not name your program `grok.py`, `machine.py`, `time.py`, or `dht.py`.
Those names can hide the library or firmware modules.

Check installation in the board's REPL:

```python
import grok as gs

print(gs.__version__)  # 2.5.0
```

### Option 3: USB with mpremote

Run these commands **on your computer** from the repository folder:

```sh
python -m pip install mpremote
mpremote connect COM5 fs cp grok.py :grok.py
mpremote connect COM5 fs cp examples/ultrasonic_distance.py :main.py
mpremote connect COM5 reset
```

Replace `COM5` with your board's port. Linux commonly uses `/dev/ttyUSB0`;
macOS uses a `/dev/cu.*` port. Close Thonny's connection before using mpremote.
The hardware remains subject to the wiring instructions below.

### Option 4: mip from GitHub

Once these changes have been pushed to GitHub, a network-connected board with
`mip` can install the MicroPython manifest:

```python
import mip

mip.install("github:Alamin54017/groklib")
```

Or use USB from the computer:

```sh
mpremote mip install github:Alamin54017/groklib
```

To install a release tag after the maintainer creates it:

```python
mip.install("github:Alamin54017/groklib", version="v2.5.0")
```

`mip` downloads from GitHub here; it does not use PyPI. See the official
[MicroPython package guide](https://docs.micropython.org/en/latest/reference/packages.html).

### Option 5: get the file from PyPI on a computer

**After the maintainer publishes this release**, run on the computer:

```sh
python -m pip install grokesplib
python -m pip show -f grokesplib
```

The second command lists the installation directory and `grok.py`. Copy that
file to your board with Thonny or mpremote, as above. You can find its full
path without importing hardware code:

```sh
python -c "from importlib.metadata import distribution; print(distribution('grokesplib').locate_file('grok.py'))"
```

Python 3.9 or newer is required for desktop package installation. This is a
packaging requirement; the hardware runtime is MicroPython. The library has
no third-party runtime dependencies on the ESP32.

## Wiring and choosing GPIOs

**Parameters named `pin`, `sda`, `scl`, `trigger_pin`, and `echo_pin` are GPIO
numbers, not physical header positions.** Examples target a classic ESP32
development board. Consult your board's pinout: ESP32-S2/S3/C3 boards differ.
Do not combine example circuits without assigning each device suitable pins.

| Part | Signal wiring used in examples | Electrical considerations |
| --- | --- | --- |
| LED/output | GPIO2 to LED through a resistor | Board LED pin and active level can vary; use a resistor for an external LED |
| Button/digital input | GPIO27; button to GND when using a pull-up | Released reads 1; pressed reads 0 |
| HC-SR04 | TRIG=GPIO5, ECHO=GPIO18, common GND | A typical 5 V module needs its ECHO voltage reduced to 3.3 V |
| DHT11 | DATA=GPIO4, common GND | Use a DATA pull-up to 3.3 V; many modules include it |
| Analog modules | AO to GPIO32, 33, 34, or 35 | Use an ADC-capable pin; keep AO in the board's permitted voltage range |
| Potentiometer | Ends to 3.3 V/GND, wiper to GPIO35 | Do not connect the wiper from a 5 V supply directly to the ESP32 |
| Servo | Signal=GPIO13, external supply, common GND | Use a supply suitable for the servo; do not power a motor from GPIO |
| I2C modules | SDA=GPIO21, SCL=GPIO22, common GND | Pull SDA/SCL up to 3.3 V or use suitable level translation |
| Keypad | Rows=25,26,27,14; columns=16,17,18,19 | Eight distinct GPIOs; rows need outputs, columns need pull-ups |

ESP32 GPIOs use 3.3 V logic. A typical HC-SR04 ECHO voltage divider can use
1 kΩ between ECHO and the input node, and 2 kΩ between that node and GND.
Check your module's specifications. LCD and RTC backpacks powered at 5 V may
pull the I2C lines up to 5 V; use appropriate level translation.

On a classic ESP32, GPIO34–39 are input only and do not have internal pull
resistors. They can be useful for ADC inputs but cannot drive servos, keypad
rows, TRIG, SDA, or SCL. ADC1 pins are preferable when using Wi-Fi; ADC2 has
Wi-Fi restrictions. Flash/PSRAM and boot-strapping pins also need care.
See the [ESP32 MicroPython quick reference](https://docs.micropython.org/en/latest/esp32/quickref.html)
and your board's schematic for pin-specific restrictions.

DS3231 can operate with a suitable 3.3 V module. DS1307 requires a 5 V supply;
keep the ESP32 side of SDA/SCL at 3.3 V. Use the battery specified for your
RTC module, checking whether its board includes a charging circuit.

## When to call which function

1. **At startup:** `import grok as gs`, then call each needed `*_init()` once.
   Keep the returned object in a variable such as `sensor`, `servo`, or `rtc`.
2. **During the loop:** call that object's reading or control methods.
   Check sensor results for `None` before comparisons, formatting, or math.
3. **When setting up an RTC:** call `set_datetime()` once with the actual time,
   or after correcting a stopped/unreliable clock. Do not reset it in a loop.
4. **When diagnosing I2C:** call `scanner.scan()`, using the same bus frequency
   as your devices. A device address confirms an acknowledgement, not its model.
5. **When pausing:** use `delay()` for seconds or `delay_ms()` for milliseconds.
6. **When finished:** call `servo.deinit()` to release PWM. Pulse sensor
   `deinit()` shuts down its LEDs; LCD `deinit()` clears its display; keypad
   `deinit()` releases rows. Shared I2C peripherals remain active.

| Your goal | Call in the loop | Result / reason to choose it |
| --- | --- | --- |
| Detect a digital level | `input.read()` | 0 or 1; suitable for buttons and digital module outputs |
| Control an output | `output.on()`, `off()`, `write(value)` | HIGH/LOW; these methods return `None` |
| Measure distance | `ultrasonic.read()` | cm or `None`; give retries/fallback if needed |
| Read temperature and humidity together | `dht.read()` | One cached `(Celsius, percent)` pair |
| Read only one DHT value | `dht.temperature()` / `humidity()` | Cache prevents immediate duplicate measurements |
| Read an analog signal | `sensor.read()` or the sensor's named method | Raw ADC count, 0–4095 |
| Compare analog levels as percent | `sensor.percent()` | ADC scale percent, 0–100; needs calibration for physical meaning |
| Position a servo | `servo.angle(degrees)` | Uses calibrated PWM pulse endpoints |
| Replace both LCD rows | `lcd.show(line1, line2)` | Clears leftover characters through padding |
| Change part of an LCD row | `lcd.print(text, row, column)` | Leaves other characters intact |
| Read the external clock | `rtc.read()` | Eight-item datetime tuple |
| Read pulse estimates together | `pulse.read()` | Both estimates use the same five-second window |
| Check for a held keypad key | `keypad.read()` | Key or `None`, returns immediately after scanning |
| Wait for one new key | `keypad.wait_key(timeout_ms=5000)` | Debounces and waits for release |
| Enter digits / a password | `keypad.number()` / `password()` | Blocking digit collection; optional total timeout |

## Initialization reference

**Required arguments have no `=`. Arguments with `=` are optional defaults.**
Use keyword arguments to make programs easier to read. All initializers return
a device object. Wrong argument values raise `ValueError`; missing I2C devices
raise `OSError`.

| Complete function signature | Parameters and units | Returned object |
| --- | --- | --- |
| `digital_init(pin, mode, pull=None)` | GPIO; `"in"`/`"out"`, case insensitive; input pull is `None`, `Pin.PULL_UP`, or `Pin.PULL_DOWN` | `DigitalInput` / `DigitalOutput` |
| `ultrasonic_init(trigger_pin, echo_pin, timeout_us=30000)` | Two distinct GPIOs; positive integer timeout in microseconds | `Ultrasonic` |
| `dht11_init(pin, retries=2)` | DHT11 DATA GPIO; nonnegative integer extra attempts, 0 means one attempt | `DHT11` |
| `ldr_init(pin)` | LDR voltage-divider/module AO GPIO | `LDR` |
| `pot_init(pin)` | Potentiometer wiper GPIO | `Potentiometer` |
| `potentiometer_init(pin)` | Alias of `pot_init` | `Potentiometer` |
| `soil_init(pin)` | Soil sensor AO GPIO | `SoilMoisture` |
| `soil_moisture_init(pin)` | Alias of `soil_init` | `SoilMoisture` |
| `gas_init(pin)` | MQ module AO GPIO | `GasSensor` |
| `flame_init(pin)` | Flame module AO GPIO | `FlameSensor` |
| `sound_init(pin)` | Sound module AO GPIO | `SoundSensor` |
| `servo_init(pin, frequency=50, min_us=500, max_us=2500)` | Signal GPIO; positive integer Hz; positive integer pulse endpoints in µs, `min_us < max_us < period` | `Servo` |
| `i2c_scan_init(sda=21, scl=22, freq=100000)` | Distinct SDA/SCL GPIOs; integer frequency in Hz, 1–400000 | `I2CScanner` |
| `lcd_init(sda=21, scl=22, freq=100000, address=None)` | I2C pins/frequency; address as integer such as `0x27`; `None` probes `0x27`, then `0x3F` | `LCD1602` |
| `rtc_init(sda=21, scl=22, model="DS3231", freq=None)` | I2C pins; `"DS3231"`/`"DS1307"`, case insensitive; `None` selects the shared 100000 Hz default for either model | `RTC` |
| `ds3231_init(sda=21, scl=22, freq=100000)` | Convenience initializer for DS3231 | `RTC` |
| `ds1307_init(sda=21, scl=22, freq=100000)` | Convenience initializer for DS1307; maximum 100000 Hz | `RTC` |
| `max30100_init(sda=21, scl=22, freq=100000)` | I2C pins/frequency; select the correct sensor model | `MAX30100` |
| `max30102_init(sda=21, scl=22, freq=100000)` | I2C pins/frequency; select the correct sensor model | `MAX30102` |
| `keypad_init(row_pins, col_pins, keys=None)` | Four GPIOs in each list; optional 4×4 layout of one-character strings | `Keypad4x4` |

## Digital input and output

Use digital input for switches or a sensor module's **DO** output. Digital
levels do not automatically mean "detected": some modules are active LOW.

```python
from machine import Pin
import grok as gs

button = gs.digital_init(27, "in", pull=Pin.PULL_UP)
led = gs.digital_init(2, "out")

while True:
    pressed = button.read() == 0
    led.write(pressed)
    gs.delay_ms(20)
```

| Method | Parameters | Return / behaviour |
| --- | --- | --- |
| `input.read()` | None | Integer 0 or 1 |
| `output.on()` | None | Set HIGH; returns `None` |
| `output.off()` | None | Set LOW; returns `None` |
| `output.write(value)` | Required value; truthy=HIGH, falsy=LOW | Returns `None` |
| `output.read()` | None | Current output level, 0 or 1 |

Outputs start LOW. Active LOW relay boards can therefore turn on when
initialized; choose wiring and an external driver appropriate to the module.
This library does not implement button debounce automatically.

## Ultrasonic distance and missing readings

```python
import grok as gs

sensor = gs.ultrasonic_init(5, 18, timeout_us=30000)
distance = sensor.read(retries=2)

if distance is None:
    print("No measurement")
elif distance < 20:
    print("Object is close")
else:
    print("Distance:", distance, "cm")
```

**Never do `sensor.read() < 20` without checking for `None`.** A disconnected
sensor, no echo, a timeout, or an invalid distance can all mean "no reading".
That is different from a measured distance of zero.

| Method | Parameters | Result |
| --- | --- | --- |
| `read(default=None, retries=0)` | `default`: returned after all attempts fail; `retries`: nonnegative integer extra attempts | Rounded cm, or your fallback; default fallback is `None` |

For example, `sensor.read(default=-1, retries=1)` makes at most two attempts
and returns `-1` on failure. Check that sentinel explicitly. Numeric fallbacks
are convenient for displays/logging but must not be treated as real distances.

The driver accepts distances from 2 to 500 cm using `duration_us / 58`;
your particular module may have a smaller specified reliable range. It rejects
`None`, nonnumeric pulses, zero/negative durations, and out-of-range values.
Hardware `OSError`s produce the fallback; programming exceptions propagate.
Retries wait 60 ms between triggers. Leave at least 60 ms between separate
calls; a 100 ms loop delay is a useful starting point. The pulse function can
wait for the echo to start and for it to end, so a failed attempt may take
roughly twice `timeout_us` plus overhead. Reading is blocking.
See [MicroPython pulse timing](https://docs.micropython.org/en/latest/library/machine.html#machine.time_pulse_us).

## DHT11 temperature and humidity

```python
import grok as gs

dht = gs.dht11_init(4)
while True:
    temperature, humidity = dht.read()
    if temperature is None or humidity is None:
        print("DHT11 unavailable")
    else:
        print("Temperature:", temperature, "C; humidity:", humidity, "%")
    gs.delay(2)
```

| Method | When to call | Return |
| --- | --- | --- |
| `temperature()` | Need only temperature | Celsius or `None` |
| `humidity()` | Need only humidity | Relative humidity percent or `None` |
| `read()` | Need both from the same measurement | `(temperature, humidity)`; `(None, None)` after failed attempts |
| `refresh()` | Need a new sample rather than the cache | Same tuple; waits for the minimum interval first |

These reading methods have no parameters. Set the retry policy when initializing:

```python
# One attempt per reading cycle, useful for a responsive robot/display loop.
dht = gs.dht11_init(4, retries=0)

# One initial attempt plus one retry, with two seconds between them.
# dht = gs.dht11_init(4, retries=1)
```

`retries` counts **extra attempts**. The default `retries=2` preserves up to three
attempts and roughly four seconds of retry waits on failure. With `retries=0`,
failure returns `(None, None)` after one sensor attempt without a retry delay.
The sensor attempt itself is still blocking. Retry waits total `retries * 2`
seconds when all attempts fail, plus sensor timing.

The library caches successful **and failed** attempts for two seconds regardless
of the retry setting. Calling `temperature()` followed immediately by `humidity()`
normally uses one measurement. `refresh()` still waits for the sensor's minimum
interval before trying again. Old values are cleared when a new measurement fails.
The broad validity checks reject corrupt values; they do not expand a DHT11's
specified measurement range. See the [MicroPython DHT guide](https://docs.micropython.org/en/latest/esp8266/tutorial/dht.html).

## Analog sensors

Use the module's **AO** pin for these drivers. Use `digital_init()` for its DO
pin. An LDR without an analog module needs a voltage divider with a resistor.

| Initializer | Named reading method | What it means |
| --- | --- | --- |
| `ldr_init(pin)` | `light()` | Raw light-dependent ADC count |
| `pot_init(pin)` / `potentiometer_init(pin)` | `value()` | Raw position-dependent ADC count |
| `soil_init(pin)` / `soil_moisture_init(pin)` | `moisture()` | Raw moisture-dependent ADC count |
| `gas_init(pin)` | `gas()` | Raw MQ module ADC count; allow the module's warm-up time |
| `flame_init(pin)` | `flame()` | Raw flame-module ADC count |
| `sound_init(pin)` | `sound()` | Instantaneous sound-module ADC count |

All of these objects also have `read()` and `percent()`, with no parameters.
`read()` and each named method return an integer from **0 to 4095**.
`percent()` returns `read() / 4095 * 100`, rounded to one decimal place.
**It is ADC full-scale percent, not moisture percent, lux, gas ppm, or dB.**
Signal direction depends on the circuit. Calibrate thresholds by measuring
known conditions. MQ sensors and flame modules are classroom instruments,
not certified gas/fire alarms.

```python
import grok as gs

ldr = gs.ldr_init(34)
while True:
    print("Raw:", ldr.light(), "ADC scale:", ldr.percent(), "%")
    gs.delay_ms(200)
```

Example soil calibration, using values **you measure for your own sensor**:

```python
soil = gs.soil_init(32)
dry = 3200  # Replace with your measured dry value
wet = 1400  # Replace with your measured wet value; it must differ from dry
raw = soil.moisture()
estimated_percent = max(0, min(100, (dry - raw) * 100 / (dry - wet)))
print(estimated_percent)
```

Calling `light()` and then `percent()` reads the ADC twice, so the values can
change slightly. Save one `raw` result if you need an exact corresponding percent.
Analog hardware errors propagate as exceptions rather than returning `None`.

## Servo

```python
import grok as gs

servo = gs.servo_init(13, frequency=50, min_us=1000, max_us=2000)
try:
    servo.angle(90)
    gs.delay(1)
    servo.angle(0)
    gs.delay(1)
finally:
    servo.deinit()
```

Use endpoints from your servo's datasheet. Defaults are 500–2500 µs at 50 Hz;
many servos need a narrower range such as 1000–2000 µs. Start near 90 degrees
and avoid forcing the mechanism against its stops. Pulse calibration affects
the actual angle; continuous-rotation servos interpret pulses as speed.

| Method | Required parameters | Behaviour |
| --- | --- | --- |
| `angle(angle)` | Finite number in degrees | Clamp to 0–180 and convert to pulse width |
| `duty(value)` | Finite raw duty number | Clamp to 0–1023; advanced control, not degrees |
| `off()` | None | Set duty to zero; stops pulses |
| `deinit()` | None | Release PWM; reinitialize before further use |

These methods return `None`. PWM starts with pulses off. `off()` may release
the servo's holding force. The driver uses `duty_ns()` for angle pulses when available, otherwise calculates
`duty_u16()` directly, and falls back to older ESP32 `duty()` APIs. Angle pulses
are not rounded to 10 bits before using a newer API. Raw `duty(value)` retains
its documented 0–1023 scale. Actual pulse resolution depends on firmware/hardware.

## I2C scanner and shared buses

```python
import grok as gs

scanner = gs.i2c_scan_init(21, 22, freq=100000)
print(scanner.scan())
print([hex(address) for address in scanner.scan()])
```

`scan()` has no parameters and returns a list of integer 7-bit addresses.
For example, `104` is `0x68`. An empty list means no device acknowledged.

| Typical address | Device |
| --- | --- |
| `0x27` / `0x3F` | Common LCD backpack |
| `0x68` | DS3231 **or** DS1307 |
| `0x57` | MAX30100 **or** MAX30102; some RTC boards also expose an EEPROM here |

Devices with different addresses can share SDA/SCL. **Use identical `freq`
values for every initializer on the same pair of pins.** DS1307 and a PCF8574
LCD can share a 100 kHz bus:

```python
rtc = gs.ds1307_init(21, 22, freq=100000)
lcd = gs.lcd_init(21, 22, freq=100000)
scanner = gs.i2c_scan_init(21, 22, freq=100000)
```

All I2C initializers default to **100 kHz** so an LCD, RTC, pulse sensor, and
scanner can share a bus without extra settings. DS3231 and the pulse sensors
also accept an explicit `freq=400000`; set it on every device sharing that bus.
DS1307 remains limited to 100 kHz. Check your backpack datasheet before using
higher frequencies with an LCD. See the
[PCF8574 timing specification](https://www.ti.com/lit/ds/symlink/pcf8574.pdf).

The library caches one hardware bus per pin pair and supports up to two
distinct pairs, using controllers 0 and 1. Conflicting frequencies, a third
bus, or overlapping pins raise `ValueError`. Restart the board before changing
a cached bus configuration. Controller availability depends on the ESP32 variant.
Avoid reconfiguring these controllers directly with `machine.I2C()` after
creating GROK devices. Access to the cache is not thread-safe; use one task
or protect multi-task hardware access yourself.

DS3231 and DS1307 cannot share one bus because both use `0x68`. The two pulse
models both use `0x57`. A scan cannot identify these chips: choose the RTC
model explicitly; pulse drivers additionally check their chip's part ID.

## LCD 16x2

```python
import grok as gs

lcd = gs.lcd_init(21, 22, freq=100000)
lcd.show("Hello students!", "GROK library")
gs.delay(2)
lcd.print("Ready", row=1, column=0)
```

| Method | Parameters/defaults | Behaviour |
| --- | --- | --- |
| `show(line1="", line2="")` | Values converted to strings | Replace both rows; truncate/pad each to 16 characters |
| `print(text, row=0, column=0)` | Required text; row 0/1, column 0–15 | Write only as much as fits; do not clear leftover text |
| `cursor(row, column)` | Both coordinates required | Move cursor; row/column clamped to bounds |
| `clear()` | None | Clear display and return cursor home |
| `backlight_on()` / `backlight_off()` | None | Control backlight |
| `command(value)` | Integer command byte, 0–255 | Advanced HD44780 command |
| `scan()` | None | Scan the shared bus |
| `deinit()` | None | Clear display; shared bus remains available |

All control methods return `None`. Use `show()` for repeated complete updates;
it overwrites old trailing characters. Rows and columns are **zero based**.
Use basic ASCII text. LCD character-ROM codes 0–255 depend on the LCD model;
larger Unicode characters are replaced with `?`.

Auto-detection checks `0x27` then `0x3F`. For another backpack address:

```python
lcd = gs.lcd_init(21, 22, freq=100000, address=0x26)
```

This driver expects P0=RS, P1=RW, P2=EN, P3=backlight, P4–P7=D4–D7.
Other backpack mappings and other LCD dimensions need a different driver.

## RTC: DS3231 and DS1307

An external real-time clock keeps calendar time using a backup battery.
These drivers communicate with the **external I2C module**, not the ESP32's
internal `machine.RTC`. Both models use address `0x68`.

```python
import grok as gs

rtc = gs.rtc_init(21, 22)  # Defaults to DS3231 at 100 kHz

# Run this separately ONCE with the actual date and time, then remove it.
# rtc.set_datetime(2026, 10, 9, hour=14, minute=30, second=0)

if rtc.lost_power():
    print("RTC may need setting: check the battery and set the actual time")
else:
    print(rtc.read())
```

For DS1307 use **one** of the following equivalent initializers:

```python
rtc = gs.rtc_init(21, 22, model="DS1307")
# Alternative: rtc = gs.ds1307_init(21, 22)
```

Both RTC models default to 100 kHz. LCD/scanner defaults use that same frequency,
so `rtc_init()`, `lcd_init()`, and `i2c_scan_init()` can be used together directly.
DS3231 also accepts an explicit `freq=400000`; DS1307 does not.

| Method | Parameters/defaults | Return / purpose |
| --- | --- | --- |
| `read()` | None | Eight-item datetime tuple |
| `datetime(value=None)` | No value reads; an eight-item tuple/list sets | Tuple when reading; `None` when setting |
| `set_datetime(year, month, day, hour=0, minute=0, second=0, weekday=None)` | Required date; optional time; weekday calculated if omitted | Set the clock; return `None` |
| `date()` | None | `(year, month, day)` |
| `time()` | None | `(hour, minute, second)` |
| `lost_power()` | None | Boolean oscillator status; model-specific limitations below |
| `temperature()` | None | DS3231 internal temperature in °C; DS1307 raises `NotImplementedError` |
| `scan()` | None | List of bus addresses |

### Date/time parameters and tuple order

```text
(year, month, day, weekday, hour, minute, second, subsecond)
```

| Field | Allowed values |
| --- | --- |
| `year` | Integer 2000–2099 |
| `month` | Integer 1–12 |
| `day` | Integer 1–31, checked against month and leap year |
| `weekday` | Integer 0–6: Monday=0, Tuesday=1, …, Sunday=6 |
| `hour` | Integer 0–23; all writes use 24-hour format |
| `minute` / `second` | Integer 0–59 |
| `subsecond` | Must be integer 0; these RTCs do not store subseconds |

This follows the `machine.RTC.datetime()` field order, not `time.localtime()`'s
order. `set_datetime()` calculates weekday when omitted; if you supply one,
make sure it matches your date. Direct `datetime(tuple)` requires weekday.

```python
rtc.set_datetime(2026, 10, 9, hour=14, minute=30, second=0)
print(rtc.read())  # (2026, 10, 9, 4, 14, 30, 0, 0), apart from elapsed seconds

rtc.datetime((2026, 10, 9, 4, 14, 30, 0, 0))  # Same time, weekday supplied
year, month, day, weekday, hour, minute, second, _ = rtc.read()
print("%04d-%02d-%02d %02d:%02d:%02d" % (year, month, day, hour, minute, second))
```

Read one tuple for a timestamp. Separate `date()` and `time()` calls can cross
midnight. Use `delay_ms()`/`time.ticks_ms()` for elapsed-time logic; an RTC is
for calendar timestamps. The library does not apply a timezone, daylight
saving, or NTP synchronization. Set UTC or local time consistently.

### Power flags and errors

DS3231 `lost_power()` reads the oscillator-stop flag. A true result means the
clock may be unreliable. DS1307 has no equivalent historical flag: this method
reads its current clock-halt bit. **False on DS1307 does not prove it kept time
through a power failure.** Check the battery and known time when commissioning.

Setting the time starts DS1307's oscillator. For DS3231 it enables
battery-backed oscillation and clears the stop flag while preserving other
control/status bits. Initialization never replaces the saved date/time.
Reading existing 12-hour registers is supported and converted to 24-hour output.
Malformed BCD/calendar registers and unsupported century values raise
`ValueError`; missing/disconnected hardware raises `OSError`. Reads do not
automatically reject the power flag, so check it before trusting timestamps.

DS3231 `temperature()` reads its internal oscillator-compensation sensor at
0.25 °C resolution; it does not initiate a new conversion. DS1307 has no
temperature sensor. Alarm, square-wave, EEPROM, and DS1307 RAM operations
are outside this library's API.
The register behaviour is based on the manufacturer's
[DS3231 datasheet](https://www.analog.com/media/en/technical-documentation/data-sheets/DS3231.pdf)
and [DS1307 datasheet](https://www.analog.com/media/en/technical-documentation/data-sheets/DS1307.pdf).

## MAX30100 and MAX30102

**BPM and SpO2 are experimental educational estimates, not medical
measurements.** The simple peak/ratio algorithms are not clinically validated
or calibrated and can return plausible but incorrect results for noise/motion.

```python
import grok as gs

pulse = gs.max30102_init(21, 22)
try:
    bpm, spo2 = pulse.read()  # Blocks for about five seconds
    if bpm is None or spo2 is None:
        print("No usable signal: keep a finger still over the sensor")
    else:
        print("BPM estimate:", bpm, "SpO2 estimate:", spo2, "%")
except OSError as error:
    print("Pulse sensor error:", error)
finally:
    pulse.deinit()
```

Use `max30100_init()` for a MAX30100. Driver initialization verifies the part
ID before writing configuration. Each uses `0x57`, so both cannot share one bus.
Use a breakout with suitable supply regulation and 3.3 V-compatible I2C signals.

| Method | Parameters/defaults | Return |
| --- | --- | --- |
| `read_samples(samples=50, timeout_ms=None)` | Integer samples 1–1000; optional positive integer total timeout in ms | `(ir_values, red_values)`, two equal-length raw-count lists |
| `bpm(samples=250)` | Integer samples 1–1000 | BPM estimate rounded to one decimal, or `None` |
| `spo2(samples=250)` | Integer samples 1–1000 | SpO2 estimate rounded to one decimal, or `None` |
| `read(samples=250)` | Integer samples 1–1000 | `(bpm, spo2)`; either component can be `None` |
| `scan()` | None | Bus address list |
| `deinit()` | None | Shutdown LEDs; returns `None`; reinitialize to resume |

Both sensors are configured for **50 samples/second**. `read_samples(50)`
takes about one second; the 250-sample estimate methods take about five seconds.
Larger windows cost more RAM and block longer. When omitted, the sampling
timeout is `samples * 20 + 1000` milliseconds. A missing data stream, FIFO
overflow, failed reset, chip mismatch, or I2C error raises `OSError`.

Every collection starts with a fresh FIFO window and waits for available
samples. MAX30100 returns full 16-bit words; MAX30102 returns 18-bit values.
The BPM algorithm searches peaks in the IR signal and uses the configured
sample rate. The SpO2 approximation uses red/IR AC-to-DC ratios. Unusable
signals return `None`, including flat signals and out-of-range estimates.
The accepted numerical intervals (30–220 BPM, 70–100%) are plausibility checks,
not accuracy guarantees. There is no reliable automatic finger detection.

`bpm()` stores only the IR list and discards red readings as they arrive, reducing
its sample storage compared with collecting both channels. Peak processing tracks
first/last positions and a count rather than allocating a peak list. The public
`read_samples()` return remains two ordinary lists. Pulse polling and LCD writes
reuse small I2C buffers to reduce temporary allocations; exact heap use depends
on your board/firmware. Initialize devices once and reuse them.

Prefer `read()` when you need both estimates; separate `bpm()` and `spo2()`
collect separate windows. See the manufacturer's
[MAX30100](https://www.analog.com/media/en/technical-documentation/data-sheets/MAX30100.pdf)
and [MAX30102](https://www.analog.com/media/en/technical-documentation/data-sheets/MAX30102.pdf)
datasheets for hardware/FIFO details.

## 4x4 keypad

Identify the row/column order from the keypad datasheet or by continuity tests.
Its connector order is not necessarily four rows followed by four columns.

```python
import grok as gs

keypad = gs.keypad_init([25, 26, 27, 14], [16, 17, 18, 19])
key = keypad.wait_key(timeout_ms=5000)
if key is None:
    print("No complete key press within five seconds")
else:
    print("Key:", key)
```

Default layout:

```text
1  2  3  A
4  5  6  B
7  8  9  C
*  0  #  D
```

| Method | Parameters/defaults | Behaviour / return |
| --- | --- | --- |
| `get_key()` / `read()` | None | Scan now; one-character string or `None`; held keys repeat |
| `wait_key(timeout_ms=None)` | Optional nonnegative integer timeout in ms | Wait for a stable press and release; key or `None` |
| `number(length=4, timeout_ms=None)` | Positive integer digit count; optional total timeout | Exactly that many digits as a **string**, or `None` |
| `password(length=4, show=False, timeout_ms=None)` | Digit count; whether to print actual digits; optional total timeout | Digit string or `None`; prints `*` per digit by default |
| `deinit()` | None | Return rows to input mode; returns `None` |

`wait_key()` includes a 30 ms debounce check and waits until release.
With no timeout, blocking methods can wait forever, including when a key is
held. `timeout_ms=0` returns `None` immediately. `number()`/`password()` use
one total deadline for the entire entry, including ignored keys and releases;
partial entries are discarded on timeout. Tick calculations handle wraparound.

```python
number = keypad.number(length=4, timeout_ms=30000)
if number is not None:
    print(number)  # For example, "0012": leading zeros preserved
    print(int(number))  # Convert only if you actually want a number

password = keypad.password(length=4, show=False, timeout_ms=30000)
if password is not None and password == "1234":
    print("Matched classroom example password")
```

Only `0`–`9` count toward number/password entry. `A`–`D`, `*`, and `#` are
ignored; there is no automatic Enter, delete, or cancel action. `show=False`
masks printed digits but does not provide secure password storage or encryption.
This is a **single-key** driver; simultaneous keys can produce ambiguous or
ghost readings. Inactive rows use input mode to avoid driving opposing levels.

Supply a custom mapping when the printed layout differs:

```python
keys = (
    ("1", "2", "3", "A"),
    ("4", "5", "6", "B"),
    ("7", "8", "9", "C"),
    ("*", "0", "#", "D"),
)
keypad = gs.keypad_init([25, 26, 27, 14], [16, 17, 18, 19], keys=keys)
```

## Utilities and advanced classes

| Function / value | Parameters | Result / when to use |
| --- | --- | --- |
| `delay(seconds)` | Nonnegative finite int/float seconds | Pause; `delay(0.5)` waits half a second; returns `None` |
| `delay_ms(milliseconds)` | Nonnegative integer milliseconds | Pause; `delay_ms(100)` waits 0.1 s; returns `None` |
| `memory()` | None | Run GC and return free heap bytes |
| `gc_collect()` | None | Run GC; returns `None` |
| `__version__` | None | Version string, currently `"2.5.0"` |
| `ADC_MAX` | None | 4095, normalized ADC maximum |
| `DEFAULT_I2C_FREQ` | None | 100000 Hz, the shared classroom default |
| `MAX_I2C_FREQ` | None | 400000 Hz; individual devices may have lower limits |

Use `memory()` when experimenting with RAM usage. Normal programs can rely on
MicroPython's garbage collector; collecting on every loop is usually unnecessary.
Run `examples/memory_check.py` after restarting your board to measure approximate
retained import heap cost without any sensors. Source/bytecode file size does not
equal runtime heap use; the example does not measure peak compilation or collection
memory. Check your full application with its actual devices and firmware.

Initializers are the recommended student entry points. For advanced code the
following public classes are available directly; methods are documented above:

| Constructor | Equivalent initializer / purpose |
| --- | --- |
| `DigitalInput(pin, pull=None)` | `digital_init(pin, "in", pull)` |
| `DigitalOutput(pin)` | `digital_init(pin, "out")` |
| `Ultrasonic(trigger_pin, echo_pin, timeout_us=30000)` | `ultrasonic_init(...)` |
| `DHT11(pin, retries=2)` | `dht11_init(pin, retries=2)`; `MIN_INTERVAL_MS=2000`, `RETRIES=3` is the default total attempt count |
| `AnalogSensor(pin)` | Generic AO input; `read()`/`percent()` |
| `LDR(pin)`, `Potentiometer(pin)`, `SoilMoisture(pin)` | Corresponding analog initializer |
| `GasSensor(pin)`, `FlameSensor(pin)`, `SoundSensor(pin)` | Corresponding analog initializer |
| `Servo(pin, frequency=50, min_us=500, max_us=2500)` | `servo_init(...)` |
| `I2CDevice(sda, scl, address=None, freq=100000)` | Advanced base class; optional integer address 0x08–0x77; `scan()` |
| `I2CScanner(sda, scl, freq=100000)` | `i2c_scan_init(...)`; direct constructor requires pins |
| `LCD1602(sda, scl, freq=100000, address=None)` | `lcd_init(...)`; direct constructor requires pins |
| `RTC(sda=21, scl=22, model="DS3231", freq=None)` | `rtc_init(...)` |
| `MAX30100(sda, scl, freq=100000)` | `max30100_init(...)`; direct constructor requires pins |
| `MAX30102(sda, scl, freq=100000)` | `max30102_init(...)`; direct constructor requires pins |
| `Keypad4x4(row_pins, col_pins, keys=None)` | `keypad_init(...)`; `DEFAULT_KEYS` holds the default layout |

Class register constants and `.pin`, `.adc`, `.pwm`, `.i2c` attributes are
advanced hardware details. Methods beginning with `_` and `_i2c_buses` are
private implementation details; applications should not depend on them.

## Classroom projects

The `examples/` folder contains complete board programs. Run one at a time,
or adapt the GPIO assignments before combining projects.

| File | Lesson / wiring |
| --- | --- |
| `blink.py` | Output and delays; LED on GPIO2 |
| `ultrasonic_distance.py` | Read/check/display distance; TRIG5, ECHO18 |
| `dht11_monitor.py` | Cache and failed measurements; DATA4 |
| `analog_monitor.py` | Raw ADC versus percent; potentiometer on GPIO35 |
| `servo_sweep.py` | Angle control and cleanup; signal13, external power |
| `i2c_scan.py` | Convert addresses to hex; SDA21/SCL22 at 100 kHz |
| `rtc_set_once.py` | Set the actual clock once; edit its date/time first |
| `rtc_clock.py` | Read timestamps; DS3231 by default, SDA21/SCL22 |
| `rtc_lcd_clock.py` | Share a 100 kHz bus; RTC and LCD on 21/22 |
| `keypad_entry.py` | Blocking input with a total timeout; default eight GPIOs |
| `pulse_monitor.py` | Read estimates/error handling; MAX30102 on 21/22 |
| `memory_check.py` | Measure retained import heap; no sensors required, restart first |

Useful extensions: light-controlled LED, calibrated soil threshold, keypad
servo position, and RTC timestamps attached to sensor logs. Decide the desired
behaviour when a reading is missing before adding automatic control.

## Errors and troubleshooting

`None` means **no usable sensor value** where documented. Do not add to it,
compare it to a number, or apply numeric formatting before checking it.
Initialization errors should be fixed before entering the main loop.

| Symptom | What to check |
| --- | --- |
| `ImportError` about `machine` | Run the program on ESP32 MicroPython; desktop Python cannot access board peripherals |
| Cannot import `grok` on board | Copy `grok.py` to the root or `/lib`; remove naming conflicts and restart |
| Ultrasonic returns `None` | TRIG/ECHO order, common GND, 5 V supply, ECHO level reduction, target range, measurement spacing |
| Error comparing `None` to a number | Save the reading and use `if distance is None` before comparisons |
| DHT11 `(None, None)` | Power, DATA pin, pull-up, wiring; allow time for retries and two-second spacing |
| ADC error or constant reading | Correct ADC-capable pin, AO versus DO, voltage limits, ADC2/Wi-Fi conflicts |
| Inverted analog response | Circuit direction varies; calibrate real dry/wet/light/dark conditions |
| LCD not detected | Scan with the same frequency; try actual address; check power, pull-ups, contrast potentiometer, backpack mapping |
| I2C frequency conflict | Use the same `freq` on scanner and devices; use 100000 when sharing with DS1307/PCF8574 |
| RTC time is invalid or stuck | Select the model, check power/battery, read the stop/halt flag, set valid actual time once |
| DS1307 temperature error | DS1307 has no temperature sensor; use DHT11 or DS3231 |
| Pulse sensor model error | Select matching MAX30100/MAX30102 driver; an address of 0x57 might be another device |
| Pulse sampling timeout / overflow | Power and bus reliability; keep collection free of long interruptions; reinitialize after faults |
| Pulse estimates are `None` | Keep finger still, improve contact, allow a longer window; raw/noisy signals may be unusable |
| Keypad repeats a key | `read()` reports held keys; use `wait_key()` for press-and-release |
| Keypad never completes | Correct row/column order, provide `timeout_ms`, release each key |
| Servo jitters or board resets | Suitable external power, common GND, calibrated pulses, and mechanical limits |

Hardware I2C/ADC/PWM failures generally raise `OSError` or the firmware's
hardware exception. The library catches expected ultrasonic and DHT failures;
it does not blanket-catch programming mistakes. Catch `OSError` around operations
you intend to retry, then fix wiring/power if failures persist.

## Changes from 2.3.0

Existing initializer names and positional calls remain available. New options
are optional. The 2.5.0 release also changes all I2C defaults to 100 kHz. Code
that explicitly mixes `freq=400000` and omitted frequencies must now supply the
same frequency to all devices on that bus. DS1307 remains limited to 100 kHz.
Review these behaviour changes when upgrading:

- Ultrasonic default failures still return `None`; a `None` pulse duration now
  works correctly. Optional retries/fallbacks and constructor timeout are added.
- Conflicting I2C frequencies now raise `ValueError`. Older code could silently
  reconfigure the peripheral and break previously created devices.
- DHT11 failures clear cached values, and retries/forced refresh respect spacing.
- Pulse estimate methods now collect 250 samples by default rather than 50.
  They block about five seconds. Raw `read_samples()` still defaults to 50.
- Pulse driver configuration/sample decoding is corrected. Unusable SpO2
  results return `None` instead of a clamped endpoint.
- Keypad debounce confirms the press; optional timeouts cover press and release.
  Lengths must be positive integers and GPIOs must be unique.
- Invalid parameters raise clear exceptions. Servo calibration/frequency is
  applied to angle pulses, and newer ADC/PWM APIs are supported.

See [CHANGELOG.md](https://github.com/Alamin54017/groklib/blob/main/CHANGELOG.md)
for the release details.

## Development and publishing on PyPI

This repository ships a single `grok.py` module so students can copy it directly.
The wheel contains that same module, package metadata, and MIT license. The
source archive also includes examples, tests, documentation, and the mip manifest.
Version metadata is read statically from `grok.__version__`; building does not
import the MicroPython hardware module.

Create a development environment on the computer:

```sh
python -m venv .venv
```

Activate it on Windows PowerShell:

```powershell
.\.venv\Scripts\Activate.ps1
```

If activation is restricted, use `.\.venv\Scripts\python.exe` in place of
`python` in the following commands. On Linux/macOS use `source .venv/bin/activate`.

```sh
python -m pip install -r requirements-dev.txt
python -m ruff check .
python -m ruff format --check .
python -m unittest discover -s tests -v
python tests/check_micropython.py
python -m build
python -m twine check --strict dist/*.whl dist/*.tar.gz
python tests/check_artifacts.py
```

The cross-compiler check validates MicroPython syntax for the library and all
board examples. It writes local `.mpy` files under `build/micropython/`; these
are not shipped, since bytecode compatibility depends on firmware version.
The regression tests simulate hardware; they do not measure electrical timing,
sensor accuracy, or physical compatibility. **Before release, test on the actual
ESP32 and modules students use**, including disconnected ultrasonic/DHT sensors,
both RTC models, battery-backed time retention, shared LCD/RTC I2C, servo
movement, keypad press/release, and pulse collection. Record board/firmware versions.
The GitHub workflow runs desktop validation and builds archives; it does not upload.

To check Thonny's actual bundled package installer on the computer:

```sh
python -m pip install -r requirements-thonny.txt
python tests/check_thonny_install.py
```

This uses Thonny 5.0's installer and a temporary device filesystem rather than
a connected board. It tests package recognition, installation into `/lib`,
version listing, reinstallation, and removal, and runs driver tests against
the installed file. The first run needs internet to prepare the installer.

### GitHub Trusted Publishing

The manual workflow `.github/workflows/publish.yml` publishes without storing
a PyPI API token. Before the first release, add a pending publisher in your
[PyPI account](https://pypi.org/manage/account/publishing/) with these fields:

| PyPI field | Value |
| --- | --- |
| PyPI project name | `grokesplib` |
| GitHub owner | `Alamin54017` |
| Repository | `groklib` |
| Workflow filename | `publish.yml` |
| Environment | `pypi` |

Create the `pypi` environment in GitHub repository settings if it does not yet
exist. After pushing the reviewed release and matching `v2.5.0` tag, open
**GitHub → Actions → Publish to PyPI → Run workflow**, choose the `main` branch,
and enter `2.5.0`. The workflow checks out that exact release tag, validates its
version, runs tests and packaging/Thonny checks, then uploads the wheel and
source archive through PyPI's GitHub identity verification.

This publishing workflow runs only when a maintainer starts it; ordinary pushes
and pull requests run validation. For a later bug fix, increase the version in
the module, manifest, README, and changelog, push a new matching tag, then run
the workflow with that new version. PyPI cannot replace an uploaded file.
See the official [Trusted Publishing setup](https://docs.pypi.org/trusted-publishers/creating-a-project-through-oidc/).

### Maintainer release steps

1. Confirm the `grokesplib` name is available on PyPI or that you control it.
   If changing it, update `project.name`, documentation, and the mip manifest.
2. Confirm maintainer/project details and MIT licensing. The repository links
   are configured for `Alamin54017/groklib`.
3. Set the release version in `grok.py` and `package.json`, update the changelog,
   and update the README version examples/badge. Use a fresh version for each
   release; PyPI does not allow replacing an uploaded filename.
4. Keep only the intended version's wheel and source archive at the top level
   of `dist/`. Run the checks above and complete the physical hardware checks.
5. Register separate PyPI/TestPyPI accounts, enable the required account security,
   and create upload credentials. Keep tokens outside this repository.
6. Try uploading and downloading the release on TestPyPI first:

```sh
python -m twine upload --repository testpypi dist/*.whl dist/*.tar.gz
python -m pip download --no-deps --index-url https://test.pypi.org/simple/ grokesplib==2.5.0
```

7. After checking the downloaded file and board installation, upload to PyPI:

```sh
python -m twine upload dist/*.whl dist/*.tar.gz
```

8. Push your reviewed code and create the matching GitHub release/tag (for example
   `v2.5.0`) so the documented pinned mip install is available.

Twine accepts API tokens through its supported credential configuration or
interactive prompt. Do not commit `.pypirc` or put credentials in examples.
Nothing in this repository automatically publishes or reserves a package name.
See the official [Python packaging tutorial](https://packaging.python.org/en/latest/tutorials/packaging-projects/)
for current build/upload instructions and
[CONTRIBUTING.md](https://github.com/Alamin54017/groklib/blob/main/CONTRIBUTING.md)
for the contribution workflow.

## License and references

MIT licensed; see [LICENSE](https://github.com/Alamin54017/groklib/blob/main/LICENSE).
Redistributions must retain its copyright and permission notice.

- [MicroPython ESP32 reference](https://docs.micropython.org/en/latest/esp32/quickref.html)
- [MicroPython GPIO API](https://docs.micropython.org/en/latest/library/machine.Pin.html)
- [MicroPython PWM API](https://docs.micropython.org/en/latest/library/machine.PWM.html)
- [MicroPython package management](https://docs.micropython.org/en/latest/reference/packages.html)
- [DS3231 datasheet](https://www.analog.com/media/en/technical-documentation/data-sheets/DS3231.pdf)
- [DS1307 datasheet](https://www.analog.com/media/en/technical-documentation/data-sheets/DS1307.pdf)
- [MAX30100 datasheet](https://www.analog.com/media/en/technical-documentation/data-sheets/MAX30100.pdf)
- [MAX30102 datasheet](https://www.analog.com/media/en/technical-documentation/data-sheets/MAX30102.pdf)
- [Python Packaging User Guide](https://packaging.python.org/)

For questions or bugs, include your board, MicroPython version, wiring, minimal
program, and error output in a
[GitHub issue](https://github.com/Alamin54017/groklib/issues).
