Skip to content

Add I2C sensor passthrough client support#148

Merged
beniroquai merged 1 commit into
masterfrom
mergemaster
Jul 6, 2026
Merged

Add I2C sensor passthrough client support#148
beniroquai merged 1 commit into
masterfrom
mergemaster

Conversation

@beniroquai

Copy link
Copy Markdown
Contributor

Introduces a new I2C helper module for raw /i2c_act transactions via the UC2 GPIO slave, including convenience APIs for register reads/writes, bus scanning, and sensor-specific parsing for SHT45 and TSL2591. UC2Client now initializes this helper as self.i2c, and a new ESP32 test script was added to repeatedly read and print SHT45 temperature/humidity and TSL2591 light data.

Introduces a new `I2C` helper module for raw `/i2c_act` transactions via the UC2 GPIO slave, including convenience APIs for register reads/writes, bus scanning, and sensor-specific parsing for SHT45 and TSL2591. `UC2Client` now initializes this helper as `self.i2c`, and a new ESP32 test script was added to repeatedly read and print SHT45 temperature/humidity and TSL2591 light data.
Copilot AI review requested due to automatic review settings July 6, 2026 20:44
@beniroquai beniroquai merged commit 097fb34 into master Jul 6, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new raw I2C passthrough helper to the Python client so sensors connected to the UC2 CAN GPIO slave’s I2C bus can be accessed via /i2c_act, and wires this helper into UC2Client as self.i2c. Also includes a new ESP32-facing test script that repeatedly reads SHT45 and TSL2591 sensor values.

Changes:

  • Add uc2rest.i2c.I2C helper with raw transactions, register helpers, bus scan, and SHT45/TSL2591 convenience reads.
  • Initialize the I2C helper in UC2Client (self.i2c = I2C(self)).
  • Add a quick ESP32 test script to read/print SHT45 and TSL2591 data in a loop.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
uc2rest/UC2Client.py Imports and initializes the new I2C helper as part of the client API surface.
uc2rest/i2c.py Implements the raw /i2c_act passthrough client + convenience sensor helpers.
uc2rest/TEST/TEST_ESP32_I2CScans.py Adds a simple script to exercise the new I2C sensor reads over serial.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread uc2rest/i2c.py
Comment on lines +59 to +60
if write:
payload["write"] = [int(b) & 0xFF for b in write]
Comment thread uc2rest/i2c.py
Comment on lines +164 to +167
# Set gain + integration time.
self.write_register(addr, self._TSL_CMD | self._TSL_CONTROL,
(gain & 0x30) | (integration & 0x07),
node=node, timeout=timeout)
Comment on lines +2 to +4
import uc2rest
import numpy as np
import time
#port = "/dev/cu.SLAB_USBtoUART"
#port = "COM3"
port = "/dev/cu.SLAB_USBtoUART"
baudrate = 912600
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants