Skip to main content
Reacgen Biosystems

I²C interface reference

Register map, transaction structure, status bits, and control commands. All multi-byte values are little-endian; floats are IEEE 754 single-precision.

Draft: for early access integrators only.

Register layout may change before v1 firmware is final. Email info@reacgen.com for a stable preview build if you need to start hardware bring-up early.

Physical interface

I²C roleSlave
7-bit address0x69 (configurable from web UI)
Logic level3.3 V
ConnectorQwiic / JST SH 1 mm 4-pin
Recommended SCL400 kHz (fast mode)
EndiannessLittle-endian

For the Qwiic connector pinout, the 3.3 V power rules, and how to change the I²C address, see Wiring connection.

Transaction structure

Reading a register requires a repeated-START transaction: write the register address (no STOP), then immediately read the response. The first byte of every response is a status code; data bytes follow.

# Python (smbus2): repeated-START read
import struct
from smbus2 import SMBus, i2c_msg

ADDR = 0x69

def read_float(bus, reg):
    write = i2c_msg.write(ADDR, [reg])
    read  = i2c_msg.read(ADDR, 5)   # 1 status + 4 data
    bus.i2c_rdwr(write, read)
    data = list(read)
    if data[0] != 0x00:
        return float('nan')
    return struct.unpack('<f', bytes(data[1:]))[0]
// Arduino (Wire): repeated-START read
Wire.beginTransmission(0x69);
Wire.write(reg);
Wire.endTransmission(false);   // no STOP
Wire.requestFrom(0x69, 5);
uint8_t status = Wire.read();
// read 4 data bytes...

Response status codes

ByteMeaning
0x00OK. Data bytes that follow are valid
0x01Unknown or deleted register; no data bytes follow
0xFFClient-side wire-error sentinel used by libraries; not emitted by the sensor

Read registers

The sensor updates its register bank after every completed measurement. The default configuration waits 100 ms between measurement cycles, in addition to acquisition and processing time. Reads are served from the cache without blocking. Response length = data bytes + 1 status byte.

AddrTypeBytesFieldDescription
0x10float324measured_reflectanceRaw reflectance ratio: reflected power vs laser power (unitless)
0x11float324normalized_reflectanceReflectance normalized to the initial reference. Uses blank subtraction when an optional blank is available.
0x12float324calibrated_densityUnfiltered culture density in g/L from the calibration lookup table.
0x13float324growth_rateKalman filter specific growth rate µ in 1/h. NaN when the Kalman filter is disabled.
0x14float324laser_power_mwLaser optical output power in mW.
0x15——(reserved)Returns status 0x01. Do not use.
0x16float324filtered_calibrated_densityKalman-filtered density in g/L. More stable than 0x12. NaN when the Kalman filter is disabled.
0x17float324filtered_calibrated_growth_rateµ × filtered_density in g/L/h (volumetric). NaN when the Kalman filter is disabled.
0x18float324calibrated_absolute_growth_rateµ × calibrated_density (unfiltered) in g/L/h. NaN when the Kalman filter is disabled.
0x20uint81statusLive status flags. Always read from hardware state, never cached.
0x21uint324error_flagsLive system error/warning vector (the same bitmask that drives the status LED). 0 means no faults. Always built live, never cached. See the error-flags table below.
0x30uint324reading_numberMonotonic read counter. Increments each OD reading. Resets to 0 on job start.
0x31struct22latest_readingAtomic latest normal-cadence reading with age, calibration metadata, normalized reflectance, and calibrated value.
0x32struct20triggered_readingPending or completed result of a host-triggered one-shot reading. Poll phase until complete.

Atomic host readings

Registers 0x31 and 0x32 return the customer-facing values and their metadata in one transaction. This prevents a normal cadence update from splitting fields across different samples. The byte counts below describe the payload after the leading response-status byte.

Latest normal-cadence reading: register 0x31

Read 23 bytes total: one response-status byte followed by this 22-byte payload. The sensor responds immediately from its latest completed scheduled capture.

Offset  Size  Field
0       1     flags
1       1     quality
2       1     calibration_unit
3       1     reserved (0)
4       2     diagnostic_code (u16)
6       4     reading_number (u32)
10      4     age_ms (u32)
14      4     normalized_reflectance (float32)
18      4     calibrated_value (float32)

Fresh one-shot reading: control 0x0C and register 0x32

Write [0x40][0x0C], then poll register 0x32 and read 21 bytes total. Accept the result when request_sequence changes andphase is 2 (complete).

Offset  Size  Field
0       2     request_sequence (u16)
2       1     phase: 0 idle, 1 pending, 2 complete
3       1     flags
4       1     quality
5       1     calibration_unit
6       2     diagnostic_code (u16)
8       4     age_ms (u32)
12      4     normalized_reflectance (float32)
16      4     calibrated_value (float32)

While continuous measurement is running, the one-shot capture is serialized with scheduled readings. When the job is stopped, the sensor powers the laser, captures the sample, and shuts the laser down afterward. The request is observational: it does not update the normal reading counter, rolling average, Growth Model, datalog, or latest normal-cadence register.

Packed-reading flags

BitFieldSet when
0validThe captured sample is valid.
1calibratedA usable calibration lookup table was applied.
2job_running_at_captureThe continuous measurement job was running during capture.

Calibration units

ValueUnit
0Dry cell weight (g/L)
1OD600
2FNU
3NTU
4Custom
0xFFNone

If no usable calibration is active, the calibrated flag is clear, calibrated_value is NaN, and calibration_unit is 0xFF. Normalized reflectance is still returned when an initial reference is available. age_ms is the elapsed time since optical capture completion; 0xFFFFFFFF means no sample is available.

Write registers

AddrTypeBytesFieldDescription
0x40uint81controlDispatches a sensor command. See command table below.
0x50float324target_laser_pctLaser power target as percentage of maximum (0.0 to 100.0 %). Writing this also activates the laser power controller at the given target.
0x51——(reserved)Do not write.

Status byte: register 0x20

The status byte is a live snapshot built from hardware state accessors on every read. It is never served from the register cache, so control-flow events (job start, laser lock) are visible immediately.

BitFieldSet when
0job_runningOD measurement job is active
1has_blankA blank (reference media) measurement has been captured
2has_initialInitial reference is complete (job has produced at least one reading)
3laser_pwrctl_runningLaser constant power controller is active
4laser_stableLaser output has stabilized (within 0.5 % band for 5 consecutive cycles)
5reflectance_stableReflectance is stable (within 1 % band, <0.5 %/s rate of change, 6 cycles)
6errorOne or more error/warning flags are active. Read register 0x21 for the detailed vector.
7calibratedA usable calibration lookup table is present (2 or more points), so calibrated_density (0x12) is meaningful.

Typical startup sequence

After CMD_START_JOB (0x01):
  Immediately:  bit 0 set (job_running = 1)
  During init:  firmware captures 60 initial-reference samples
  On complete:  bit 2 set (has_initial = 1)

Use a timeout of at least 180 s for has_initial.

After CMD_TAKE_BLANK (0x03):
  On complete:  bit 1 set (has_blank = 1)

Error flags: register 0x21

Register 0x21 is a 32-bit little-endian vector of the system error and warning flags, the same bitmask the firmware uses to drive the status LED. A value of 0 means no faults. Like 0x20, it is built live on every read and never cached. Bits 9 to 31 are reserved (0).

Status byte bit 6 (error) is the OR of every flag below, so a client can poll the single status byte and only read 0x21 when bit 6 is set. The error-class bits (0 to 4) latch and are cleared with control command 0x07 (CMD_CLEAR_ERRORS); the warning-class bits (5 to 8) are live-derived and re-assert on their own.

BitFlagClassSet when
0SAFETY_CRITICALerrorOptical output power exceeded the safety limit
1SAFETY_WARNINGerrorReserved optical safety warning
2PI_FAILEDerrorOptical power controller failed to stabilize
3LOW_HEAPerrorFree heap dropped below the safe threshold
4STORAGEerrorSPIFFS / NVS load failure
5NO_BLANKwarningNo blank reference is set
6NO_INITIALwarningNo initial reference while a job is running
7WIFI_DOWNwarningWi-Fi is disconnected
8OTAwarningA firmware update is in progress

Control commands: register 0x40

Write register address 0x40 followed by one command byte. Async commands return immediately and run in a background task. Poll the status register to confirm start, stop, and blank completion. CMD_CAL_READING is a current protocol exception: it has no I²C-visible completion bit and does not return the captured reflectance value. Use the web interface for the calibration workflow until the I²C API is extended.

ByteNameTypeDescription
0x01CMD_START_JOBAsyncBegin continuous OD measurements. Resets register bank to NaN and reading_number to 0.
0x02CMD_STOP_JOBAsyncStop the measurement task and turn off the laser.
0x03CMD_TAKE_BLANKAsyncCapture blank reference (clear media). Job must be stopped first.
0x04CMD_CAL_READINGAsyncCapture a reflectance reading against a known-density standard. I²C currently exposes no completion bit or captured result.
0x05CMD_DEACTIVATE_LASERSyncStop laser power controller and turn off laser immediately. Effective before ACK.
0x06CMD_ERASE_INITIALSyncClear stored initial reference. normalized_reflectance reverts to NaN.
0x07CMD_CLEAR_ERRORSSyncClear the latching error-class bits (0 to 4) in register 0x21 and status bit 6. Warning-class bits (5 to 8) re-assert if their condition persists.
0x08CMD_ENABLE_UKFSyncEnable the growth rate model (Kalman filter). Persisted to flash; takes effect on the next job start. Rejected while a job is running, so stop the job first. The growth-model registers (0x13, 0x16 to 0x18) stay NaN until it is enabled. There is no I²C disable command; disable from the web dashboard.
0x0CCMD_TRIGGER_READINGAsyncRequest one fresh observational reading. Poll register 0x32 for a new request sequence with phase = 2.

Data formats

IEEE 754 float (32-bit, little-endian)

# Python
struct.unpack('<f', bytes([b0, b1, b2, b3]))[0]

// C (little-endian host)
float f; memcpy(&f, buf, 4);

NaN representation

Registers not yet populated (job not started, Kalman filter disabled) contain IEEE 754 quiet NaN. Always check with math.isnan() before using a value.

Hex:        0x7FC00000
Wire bytes: [0x00, 0x00, 0xC0, 0x7F]  (little-endian)

uint32 (32-bit, little-endian)

# Python
struct.unpack('<I', bytes([b0, b1, b2, b3]))[0]

Async operation pattern

Use this polling pattern for start, stop, and blank commands. Calibration capture does not currently expose an I²C completion flag.

1. Write command byte to register 0x40
2. Wait ~50–100 ms (command dispatch)
3. Poll register 0x20:
   a. Read status (2-byte repeated-START)
   b. Check the relevant bit
   c. Set → operation complete
   d. Not set → wait 200 ms and repeat
4. Apply an operation-specific timeout; surface an error if the bit never changes

Timing reference

EventTypical duration
Job start → laser stable (bit 4)0.5–2 s
Job start → initial ref complete (bit 2)60 samples; allow at least 180 s
Blank measurementPoll bit 1; apply a 30 s timeout
Calibration readingNo I²C-visible completion flag
Inter-reading delay100 ms default, plus acquisition and processing time
Status register read latency<1 ms

Error handling

ConditionIndicatorAction
Unknown registerStatus byte = 0x01Skip; do not use the following bytes
Wire errorClient sentinel 0xFF or exceptionRetry after 100 ms; check wiring if persistent
Register value is NaNmath.isnan(value) is TrueCheck startup state, lookup table availability, and whether the Kalman filter is enabled for the requested field
reading_number not incrementingSame value on successive readsOD job not running; issue CMD_START (0x01)
System fault or warning activeStatus bit 6 (error) setRead register 0x21 and decode the flag vector; clear the latching error bits with CMD_CLEAR_ERRORS (0x07)
laser_stable never setsBit 4 stays 0 after >10 sLaser or hardware fault; check web interface serial log

For ready-made client libraries (Arduino and Python) and end-to-end examples, see Code libraries, the Arduino examples, and the Python examples.