Skip to content

ST25R3916 U216 on ESP32-C3 returns IC_IDENTITY 0xF7 #9

Todo

Description

@mfranchini

Describe the bug

Hardware

  • NFC reader: M5Stack Unit NFC U216, specified as ST25R3916-AQWT
  • MCU: ESP32-C3 Dev Module
  • I2C: SDA GPIO10, SCL GPIO6, 100 kHz, address 0x50
  • I2C_EN is pulled up to 3.3 V through a 10 kΩ resistor
  • Reader powered from 5 V, with common GND

Observed

The I2C scanner detects address 0x50 when the reader is connected.

A direct read of IC_IDENTITY, using register-read command 0x7F for register 0x3F, succeeds consistently on GPIO6 but returns 0xF7. This decodes to ic_type 0x1E and revision 7.

HomeKey reports:
IC_IDENTITY 0xF7: ic_type 0x1E is not ST25R391x

The M5Stack M5Unit-NFC library also fails to initialize the reader.

Expected

The reader is specified as an ST25R3916. The ST25R3916 datasheet lists IC type code 00101, but the observed value decodes to 11110.

Could you clarify whether this U216 module and this I2C transaction are supported by the ESP32-C3 HomeKey build, or whether the reported identity indicates a module issue?

To reproduce

  1. Connect the M5Stack Unit NFC U216 to an ESP32-C3 Dev Module:
    • SDA → GPIO10
    • SCL → GPIO6
    • 5V → 5V
    • GND → GND
    • I2C_EN pulled up to 3.3V through 10kΩ
  2. Flash the HomeKey-ESP32 firmware for ESP32-C3.
  3. Open the serial monitor at 115200 baud and boot the board.
  4. Observe the NFC reader initialization error. An I2C scan detects address 0x50; a direct read of IC_IDENTITY using command 0x7F returns 0xF7 consistently.

Expected behavior

The reader should initialize successfully as an ST25R3916 over I2C. Reading IC_IDENTITY should report the ST25R3916 type code (00101 / 0x05), rather than 0x1E.

Screenshots

No response

Environment

  • OS:
  • IDE &IDE Version:
  • Repository Version:

Additional context

No response

Issue checklist

  • I searched for previous reports in the issue tracker
  • My report contains all necessary details

Activity

  1. mfranchini commented on Dec 1, 2026

    @mfranchini
    Author
    IMG_0187 IMG_0188
  2. m5agent commented on Dec 1, 2026

    @m5agent

    Thanks for the detailed report and the photos. The photos confirm the ST25R3916 Unit NFC, so the key question is why a genuine module reads 0xF7.

    Conclusion

    0xF7 is not a valid ST25R3916 identity, and the ESP32-C3 build is not what rejects the unit — the rejection is the chip-ID gate. HomeKey's ST25R3916 backend was developed against this exact M5Stack unit (AtomS3 Lite + U216, PR #294) and esp32c3 is in its CI matrix, so the transport is intended to work on C3. The issue is the value being returned, not a missing C3 feature.

    Per the ST25R3916 datasheet (DS12484 Rev 8, Table 117, p.135), IC_IDENTITY (0x3F) is a 5-bit ic_type in bits 7:3 plus a 3-bit ic_rev in bits 2:0. The ST25R3916/7 type is 00101; the default readout is 0x2A (rev 3.1). The B variants are type 00110 (0x30–0x37). A healthy U216 therefore reads 0x28–0x2F; 0xF7 (type 0x1E, rev 7) does not match any of those type codes.

    Your transaction (0x50+W, 0x7F, repeated START, 0x50+R, 1 byte) is the datasheet's Register Read mode. So 0xF7 means either the read is not returning the register content or the unit is not behaving as an ST25R3916. I can't distinguish those from the report, so I'd rather not guess.

    The M5Unit-NFC library also gates on type == 0x05 && rev != 0 (src/unit/unit_ST25R3916.cpp::begin(), VALID_IDENTIFY_TYPE in ST25R3916_definition.hpp), so if its log shows Not detected ST25R3916 1E,7, that is the same identity gate, not a second failure.

    Evidence level: code-level verification — U216 product page and schematic (ST25R3916-AQWT, I2C 0x50, I2C_EN pulled up on-module through R5 10 kΩ), ST datasheet Table 117, and the two driver sources. Hardware validation NOT RUN. Virtual-device validation NOT RUN: our emulator's current device list has no ESP32-C3 profile (ESP32/S3/C6/P4/Linux only), and the only ST25R3916 model is a deterministic I2C fixture on CoreS3 (not a U216 electrical model) that hard-codes 0x2A and models no supply behavior, so it cannot reproduce this.

    Checks that separate the two

    1. I2C scan: only 0x50, or many addresses? Only 0x50 means the chip really ACKs; many usually means SDA is stuck low or miswired.
    2. After a full power-cycle (5 V off, then on), read 0x00 (IO_CONF1, default 0x00) and 0x3F before any init. If 0x00 also reads 0xF7/0xFF, the read path or supply is wrong; if 0x00 is 0x00 and only 0x3F is 0xF7, the chip is the suspect.
    3. Measure 5 V at the Grove red wire and 3.3 V on the module. The module already pulls I2C_EN up through R5, so no external 10 kΩ is required; make sure 5 V and 3.3 V come up together. 100 kHz is fine for register reads (HomeKey wants 400 kHz for tag timing after init, not for this read).
    4. Cross-check the same unit on another host (AtomS3/CoreS3) with the M5Unit-NFC Detect example, and a second U216 if available. The example's Not detected ST25R3916 <type>,<rev> line shows whether it is the same read (1E,7) or no response (00,0).

    If 0x3F still returns 0xF7 on a known-good host with 5 V present, this is not a host/firmware problem — please contact M5Stack support for a replacement. Posting the scan address list, the M5Unit-NFC serial line, and the two voltage readings here will let me narrow it down further.

    NOT RUN: electrical measurements, a second unit/host, RF/tag operation.

  3. mfranchini commented on Dec 1, 2026

    @mfranchini
    Author

    After a full power cycle, I ran the direct register-read test at SDA GPIO10, SCL GPIO6, 100 kHz, address 0x50.

    Reading IO_CONF1 (register 0x00, command 0x40) returned 0xF7. Reading IC_IDENTITY (register 0x3F, command 0x7F) failed with ESP_ERR_INVALID_RESPONSE and returned 0 bytes.

    The U216 schematic shows I2C_EN pulled up through the on-module 10 kΩ resistor R5. I will also check the I2C scan results and measure the voltage between the module's 5 V and GND wires.

  4. m5agent commented on Dec 1, 2026

    @m5agent

    Conclusion

    0x00 is the decisive reading, and it says the byte is not register content.

    IO_CONF1 (address 0x00, space A) has reset value 0x00 (Table 19, p.71) — every defined bit is 0. 0xF7 would mean single=1, rfo2=1, i2c_thd=11, out_cl=11, which no read-only test can produce, and neither driver writes it: M5Unit-NFC only ever puts 0x00/0x07 there, and HomeKey's St25r3916Reader never touches 0x00. The 0x3F read now returning 0 bytes with ESP_ERR_INVALID_RESPONSE is also inconsistent with the earlier "returns 0xF7 consistently" on the same unit.

    So the transaction is failing at the electrical level; the 0x1E/rev 7 decode is an artifact of that, and replacement is not indicated yet. Your command bytes are correct — register read is 0x40 | addr (§4.3.4, and OP_READ_REGISTER{0x40} / OP_TRAILER_MASK{0x3F} in the library) — there is nothing to fix in the transaction itself.

    Evidence level: code-level verification — datasheet Tables 19/117 and §4.3.4; U216 schematic (SCL/SDA have their own on-module 2.2 kΩ pull-ups R3/R4 to VCC_3V3, separate from R5 on I2C_EN, and U3 makes VCC_3V3 from +5 V); M5Unit-NFC and HomeKey sources. Hardware validation NOT RUN. Virtual-device validation NOT RUN: our Device Service exposes 37 profiles across 14 SoCs and none is ESP32-C3, and the only ST25R3916 model is a deterministic CoreS3 I2C fixture that hard-codes 0x2A with no bus or supply behaviour, so it cannot reproduce a NACK or a bogus byte.

    Checks, in the order that discriminates

    1. Post the transfer status for the 0x00 read as well (the return of i2c_master_transmit_receive, or the requestFrom() count plus Wire.getError()), and confirm the read phase uses a repeated START — releasing the bus between the mode byte and the read drops the register selection (§4.3.4). If that call is also non-OK, 0xF7 was only the initialised buffer and no byte was ever read.
    2. Read 0x00 ten times in one run and post every value and status. A value that changes, or a status alternating OK/NACK, is the physical layer.
    3. Idle DC on SDA and SCL: both should sit at VCC_3V3, since R3/R4 pull them there. Measure VCC_3V3 rather than only +5 V — R5's I2C_EN pull-up is on that same rail, so a dead or marginal U3 LDO both drops the chip out of I2C mode and leaves the bus floating. Also confirm your power cycle actually removes +5 V (a reset button does not).
    4. Bit-bang a single read at ~10 kHz with explicit ACK checks; that separates the C3 I2C peripheral/timing from the chip.
    5. Cross-host: this unit on AtomS3/CoreS3 with the M5Unit-NFC Detect example. 2A,2 there points at the C3 wiring/pins; 1E,7 or another NACK points at the module, and then support/RMA applies.

    NOT RUN: electrical measurements, second host/unit, RF/tag operation.

  5. mfranchini commented on Dec 1, 2026

    @mfranchini
    Author

    Clarification on the direct-read results:

    For register 0x00:

    • Wire.endTransmission(false) returned 0
    • Wire.requestFrom() returned 1
    • Wire.read() returned 0xF7

    For register 0x3F:

    • Wire.endTransmission(false) returned 0
    • Wire.requestFrom() returned 0, with ESP_ERR_INVALID_RESPONSE

    So 0xF7 was returned as one byte by Wire for register 0x00; the IC_IDENTITY read returned no byte in this run.

  6. mfranchini commented on Dec 1, 2026

    @mfranchini
    Author

    With the reader powered, I measured approximately 5 V between the red and black wires. Idle SDA and SCL both measure 3.3 V relative to GND.

  7. m5agent commented on Dec 1, 2026

    @m5agent

    Conclusion

    That closes the open item, and it moves the diagnosis: 0xF7 was clocked from the bus, so it is not a buffer artefact, and in the same run the 0x3F read address NACKs. A slave that ACKs its write address, returns a byte for 0x00, and then refuses the read phase moments later is not mis-decoding an identity — the read direction is marginal. 0xF7 also cannot be 0x00 content: 0b1111_0111 is seven high bits and one low, i.e. SDA was released for most of the byte immediately after the same chip pulled it low to ACK the address.

    Why the returned statuses say less than they look: endTransmission(false) == 0 carries no ACK information on arduino-esp32 — in both 2.x and 3.x Wire.cpp the non-stop overload only sets an internal flag and returns 0 without transmitting; the write and the read are issued together inside the following requestFrom(). requestFrom() returns the byte count only when i2c_master_write_read_device() returned ESP_OK, and 0 otherwise (rx index/length are reset, so Wire.read() on a failed transfer returns -1 and cannot replay a stale byte). Your 1 therefore does prove ACKed address + repeated START + one byte clocked; your 0 with ESP_ERR_INVALID_RESPONSE is a NACK in that run.

    Evidence level: code-level verification — arduino-esp32 libraries/Wire/src/Wire.cpp (endTransmission(bool), requestFrom, read) and cores/esp32/esp32-hal-i2c.c (i2cWriteReadNonStop), checked in 2.0.17 and 3.3.13; ST25R3916 datasheet Table 19 and §4.3.4. Hardware validation NOT RUN. Virtual-device validation NOT RUN: /api/v1/devices re-checked just now — 37 profiles, no ESP32-C3 — and the only ST25R3916 model is a deterministic NFC Unit fixture at 0x50 that always ACKs, returns a fixed 0x2A, and models no bus timing or supply, so it cannot reproduce a NACK or a bogus byte.

    Steps that now discriminate

    1. The ten-iteration loop from my last comment is the decisive one now that the byte is real: 0x00 and 0x3F ten times each in one boot, printing value and requestFrom() count. Healthy is 0x00/0x2A every time; counts alternating between 1 and 0 is the physical layer.
    2. Write-back: write 0x07 to 0x00, read it back, then write 0x00 and read back. Reading back exactly what you wrote clears the read direction; 0xF7 again does not.
    3. Bit-bang a single read at ~10 kHz with explicit ACK sampling after the address and after each byte. That separates the C3 peripheral/timing from the module, and unlike the hardware I2C block it still works through a weak SDA pull-up.
    4. Read a second I2C device on the same two pins at another address. Misreads there mean the host side (pins, pull-ups, Wire.begin config); correct reads mean the U216.

    The cross-host Detect run on AtomS3/CoreS3 is still the only test that splits C3 from module, and the SDA/SCL idle DC plus VCC_3V3 measurement from my last comment is still the cheapest explanation for a byte that cannot be register content.

    NOT RUN: electrical measurements, bit-bang, second device/host, RF/tag operation. If 1–4 come back clean and 0x3F still NACKs, support/RMA applies; until one of them misbehaves I would not call the module faulty.

  8. mfranchini commented on Dec 1, 2026

    @mfranchini
    Author

    Update: with SDA=GPIO10, SCL=GPIO6 and I2C at 100 kHz, the scanner detects address 0x50. However, after a full power cycle, direct reads of both register 0x00 and register 0x3F return 0 bytes with ESP_ERR_INVALID_RESPONSE. The register-selection phase returns status 0. Idle SDA and SCL measure 3.3 V, and the module supply measures 5 V.

    A previous run returned 0xF7 once for register 0x00, but this value has not been repeatable.

  9. mfranchini commented on Dec 1, 2026

    @mfranchini
    Author

    In the repeated-read test, most requests returned 0 bytes with ESP_ERR_INVALID_RESPONSE. One read of register 0x3F returned one byte, 0xF7. The log excerpt includes the first four complete iterations and part of iteration 5.

  10. mfranchini commented on Dec 1, 2026

    @mfranchini
    Author

    Repeated-read update (10 attempts per register, SDA=GPIO10, SCL=GPIO6, 100 kHz):

    • Register 0x00: 4 reads returned one byte, always 0xF7; 6 returned 0 bytes with ESP_ERR_INVALID_RESPONSE.
    • Register 0x3F: 5 reads returned one byte, always 0xF7; 5 returned 0 bytes with ESP_ERR_INVALID_RESPONSE.

    The software I2C test did not complete a read in the shown output: it reported missing address ACKs and START/clock failures. Supply measured about 5 V; idle SDA and SCL were both 3.3 V.

  11. m5agent commented on Dec 1, 2026

    @m5agent

    Conclusion

    The two results don't contradict each other — the scanner and the failing read exercise different halves of the bus. The stock Arduino scanner only does beginTransmission(0x50) + endTransmission(), i.e. an address write; it never addresses 0x51 and never asks the module to drive SDA. So "scan finds 0x50" proves the module ACKs its slave address, and says nothing about the read direction that is failing now. 0xF7 is also not a register value: seven of eight bits high is what a released line samples as, and with that byte now gone entirely, "the read direction is not being driven" is the consistent reading — not a wrong chip ID.

    What your measurements do settle is the static branch: 5 V present and both lines idling at 3.3 V means the rails and the on-module R3/R4 pull-ups are fine. What a DMM cannot show is whether the module drives SDA on the ninth clock, and how fast the line rises — that is now the only place this can fail. (endTransmission(false) == 0 still carries no ACK information; the only meaningful status is requestFrom()'s byte count.)

    Evidence level

    code-level verification — ST25R3916 datasheet §4.3.4 and Tables 19/117; U216 schematic (R3/R4 2.2 kΩ to VCC_3V3, R5 10 kΩ on I2C_EN, U3 5 V→3.3 V); M5Unit-NFC opcodes (OP_WRITE_REGISTER 0x00, OP_READ_REGISTER 0x40, OP_TRAILER_MASK 0x3F); arduino-esp32 3.3.13 Wire.cpp (requestFrom reports 0 bytes when the write-read call fails); esp-idf, where every byte of i2c_master_write_read_device() / i2c_master_transmit_receive() is queued and the whole call returns a single NACK status — so ESP_ERR_INVALID_RESPONSE says a NACK happened, not which byte produced it. Hardware validation NOT RUN. Virtual-device validation NOT RUN: /api/v1/devices today is 37 profiles over ESP32/S3/C6/C61/P4/RP3A0 (no ESP32-C3), and the emulator's only ST25R3916 model is an SPI fixture on Cardputer-Adv, so neither side of this I2C path is executable here.

    Steps that split the transaction

    1. Read with no register select: size_t n = Wire.requestFrom(0x50, 1); Only the count matters, the data byte is meaningless. n == 1 → the module ACKs 0x51 and drives SDA, so the read direction works and the fault is in the register-select/repeated-START path. n == 0 → the module does not answer a read address at all.
    2. Write one register with a STOP, to get a real ACK code: Wire.beginTransmission(0x50); Wire.write(0x00); Wire.write(0x00); uint8_t e = Wire.endTransmission(true); — mode byte 0x00 is "write register 0x00" (OP_WRITE_REGISTER | 0x00), data 0x00 is IO_CONF1's reset value, so nothing changes. e == 0 proves the mode byte and a data byte were ACKed; e == 2 is a NACK, and then the write side is failing after the address.
    3. If 1 and 2 pass and only the combined write+read fails, it is the repeated START or bus rise time, not address decoding: put 1 kΩ from SDA to 3.3 V in parallel with R3, retry at 10 kHz, and if you have a logic analyzer capture one failing read — START / 0x50+ACK / 0x40 / repeated START / 0x51 / data. Without a scope, the 10 kHz bit-bang from my last comment gives the same phase information.
    4. If step 1 also returns 0 bytes, run the M5Unit-NFC Detect example on an AtomS3 or CoreS3 before anything else; if it fails there too, the module is the fault and support/RMA applies.

    Not covered, and one thing I need

    Our own electrical capture, an ESP32-C3 host and a second module — none available on my side, so everything above is datasheet/source-level. Also please say which call prints ESP_ERR_INVALID_RESPONSE and your core/IDF version: on arduino-esp32 3.3.13 Wire goes through the legacy i2c_master_write_read_device(), which returns ESP_FAIL on NACK, so that code name points at a different API than the sketch I am assuming.

  12. mfranchini commented on Dec 1, 2026

    @mfranchini
    Author

    The error is printed by Wire.requestFrom(), not by endTransmission(false). The serial log says:

    i2cWriteReadNonStop(): i2c_master_transmit_receive failed: [264] ESP_ERR_INVALID_RESPONSE
    requestFrom(): i2cWriteReadNonStop returned Error 264

    Arduino-ESP32 board package version: 3.3.12
    Selected board: ESP32C3 Dev Module
    I2C pins: SDA=10, SCL=6; clock=100 kHz.

  13. mfranchini commented on Dec 1, 2026

    @mfranchini
    Author

    Additional test on ESP32-C3, SDA=10, SCL=6, 100 kHz:

    • A bare Wire.requestFrom(0x50, 1) with no preceding register-read command returned 0 bytes with ESP_ERR_INVALID_RESPONSE.
    • Writing IO_CONF1 register 0x00 with value 0x00 using endTransmission(true) returned 0.

    The write transaction succeeds. The register-read transaction using a mode byte and repeated START remains intermittent: it sometimes returns 0 bytes and sometimes 0xF7.

  14. mfranchini commented on Dec 1, 2026

    @mfranchini
    Author

    Another run with the same wiring and settings produced different results:

    • Bare Wire.requestFrom(0x50, 1): 0 bytes; i2c_master_receive failed with ESP_ERR_INVALID_RESPONSE.
    • Writing IO_CONF1=0x00: i2c_master_transmit failed with ESP_ERR_INVALID_RESPONSE; endTransmission(true) returned 4.

    In an earlier run, the same write returned 0. So register-level I2C transactions are intermittent in both directions, although the scanner detects address 0x50.

  15. m5agent commented on Dec 1, 2026

    @m5agent

    Conclusion

    The two new runs move the diagnosis: this is no longer a read-only fault. A two-byte write that returned 0 in one run and NACKed in the next (i2c_master_transmit, endTransmission 4) means data phases drop out in both directions, while zero-length address probes still ACK 0x50. Address decode works; whole data transactions fail intermittently. That is a physical/electrical signature — contact, edges, or supply — or an I2C block abandoning transfers, not register decoding.

    The bare read is a fair test, and its result is real. The ST25R3916 datasheet documents exactly that case: a master that omits the mode byte and reads immediately after the slave address gets FFh followed by a register dump starting at 01h, a mode included for device detection (application section, "I2C: master reads slave immediately after the first byte", DS12484). So 0 bytes twice is a genuine no-ACK, not an unsupported access. 0xF7 is 0xFF with one bit pulled low — a released SDA with a glitch, not an identity value; the same byte for 0x00 and 0x3F, whose contents differ, cannot be register content either.

    Two code notes, one correcting myself: on the -ng HAL a NACK reaches endTransmission() as 4, not 2 — 2 is only the zero-length probe path (ESP_ERR_NOT_FOUND). And 264 is the IDF 6.x spelling of this NACK; the 3.3.x package bundles IDF 5.5.x, which returns ESP_ERR_INVALID_STATE (259) for the same condition, so print ESP.getSdkVersion() once if you build outside the IDE.

    Evidence level: code-level verification plus datasheet — arduino-esp32 3.3.12/3.3.13 libraries/Wire/src/Wire.cpp, cores/esp32/esp32-hal-i2c-ng.c (:259 probe path, :366-372 i2cWriteReadNonStop), esp-idf esp_driver_i2c/i2c_master.c (transmit_receive / receive / probe, NACK mapping in 5.5 vs 6.1); ST25R3916 datasheet §4.3.4. Hardware validation NOT RUN. Virtual-device validation NOT RUN: /api/v1/devices re-checked, 37 profiles, no ESP32-C3.

    Steps

    1. One boot, 30 iterations, millis() on every line, three results per iteration: probe (Wire.beginTransmission(0x50); Wire.endTransmission(true) — 0 ACK / 2 no ACK), the two-byte write (0 / 4), and the bare read with the byte printed when it succeeds (expect 0xFF). This shows whether the address ACK ever fails, and whether failures are front-loaded (supply/POR) or random (contact).
    2. Bus recovery between iterations: release SDA, clock SCL nine times, retry. If a NACK clears after recovery, the slave is being left mid-transfer — that alone explains a fault that moves between write and read.
    3. Reseat and swap the Grove cable, buzz SDA/SCL/GND while flexing it, then rerun the same loop at 10 kHz. Clean at 10 kHz = rise time/capacitance; still failing = contact, supply, or the module.
    4. Same loop on an AtomS3 or CoreS3. Failing there too makes the module the fault and RMA is justified; clean there puts it on the C3 host side.

    Not covered: no ESP32-C3, no second U216 and no scope here, so I cannot separate the remaining causes from my side, and I cannot watch VCC_3V3 during a transaction. If 1-4 come back clean and writes still NACK, one scope capture of a failing write is the next artifact worth having.

  16. GOB52 commented on Dec 2, 2026

    @GOB52
    Contributor

    Maintainer note, limited to the M5Unit-NFC side of this report.

    Could you post a complete, minimal sketch together with its verbatim serial output?

    Right now every number in this thread comes from code we cannot see, and the runs contradict each other: 0xF7 was first "consistent" and then not repeatable; the same two-byte write to IO_CONF1 returned 0 in one run and NACKed in the next; the bare requestFrom() returned 0 bytes in one run after a register read had just succeeded. Differences between the sketches used for each run are as plausible an explanation as the bus is, and we cannot tell them apart from summaries. One file plus its unedited log would settle that.

    To have a common baseline, here is the sketch we would like to see the output of. It is self-contained — plain Wire, no M5 libraries — and prints the status of every phase:

    #include <Arduino.h>
    #include <Wire.h>
    
    constexpr int PIN_SDA   = 10;
    constexpr int PIN_SCL   = 6;
    constexpr uint8_t ADDR  = 0x50;
    constexpr uint32_t FREQ = 100000;
    
    static void probe()
    {
        Wire.beginTransmission(ADDR);
        Serial.printf("  probe        endTx=%u\n", Wire.endTransmission(true));
    }
    
    static void write_reg(uint8_t reg, uint8_t val)
    {
        Wire.beginTransmission(ADDR);
        Wire.write(0x00 | (reg & 0x3F));  // Register Write mode byte
        Wire.write(val);
        Serial.printf("  write 0x%02X   endTx=%u\n", reg, Wire.endTransmission(true));
    }
    
    static void read_reg(uint8_t reg)
    {
        Wire.beginTransmission(ADDR);
        Wire.write(0x40 | (reg & 0x3F));  // Register Read mode byte
        const uint8_t e = Wire.endTransmission(false);  // repeated START
        const size_t n  = Wire.requestFrom(ADDR, (size_t)1);
        const int v     = (n == 1) ? Wire.read() : -1;
        Serial.printf("  read  0x%02X   endTx=%u n=%u val=", reg, e, (unsigned)n);
        if (v < 0) {
            Serial.printf("--\n");
        } else {
            Serial.printf("0x%02X\n", (unsigned)v);
        }
    }
    
    void setup()
    {
        Serial.begin(115200);
        delay(1000);
        Serial.printf("sdk=%s sda=%d scl=%d freq=%lu\n", ESP.getSdkVersion(), PIN_SDA, PIN_SCL,
                      (unsigned long)FREQ);
        Wire.begin(PIN_SDA, PIN_SCL, FREQ);
    
        for (int i = 0; i < 10; ++i) {
            Serial.printf("--- iter %d  t=%lu ms\n", i, millis());
            probe();
            read_reg(0x00);         // IO_CONF1, reset value 0x00
            read_reg(0x3F);         // IC_IDENTITY, expect 0x28-0x2F
            write_reg(0x00, 0x00);  // writes the reset value, changes nothing
            delay(100);
        }
    }
    
    void loop()
    {
    }

    Please run it from a cold power-up (5 V removed, not a reset) and paste the whole log, including the sdk= line. If you modify it, post the modified file.

    Separately: "the M5Unit-NFC library also fails to initialize" is most likely a different failure — the example is not using your pins.

    The bus is set up by m5::unit::wiring::addI2C() (examples/UnitUnified/NFCA/Detect/main/main.cpp:112), which takes SDA/SCL from M5.getPin() for the board M5Unified detects. On a generic ESP32-C3 dev module M5Unified reports board_unknown, whose ESP32-C3 Port A entry is SCL = GPIO0 / SDA = GPIO1, so the example opens Wire on those two pins — not your GPIO10/6. To point it at your wiring, replace that one line:

        Wire.end();
        Wire.begin(10, 6, 100000);
        unit_ready = Units.add(unit, Wire) && Units.begin();

    (The examples still need M5.begin() from M5Unified; on a board with no display the lcd calls are harmless no-ops. IRQ is optional — config_t::using_irq defaults to false and the driver polls.)

    If you do run it, the line worth posting is Not detected ST25R3916 <type>,<rev> from UnitST25R3916::begin(). It waits 50 ms, then retries the identity read up to 5 times with 20 ms gaps, and prints the decode of the last attempt (the gate is type == 0x05 && rev != 0). 00,00 there means no read ever completed — consistent with the NACKs you are seeing — whereas 1E,07 would mean a byte came back and it was 0xF7.

    On the diagnosis: nothing in the evidence so far points at this library. 0xF7 appearing identically for 0x00 and 0x3F — two registers whose contents differ, and 0xF7 being 0xFF with a single bit low — reads as a released SDA rather than register content.

    The one datapoint still missing is this unit on an M5 host: NFCA/Detect on an AtomS3 / CoreS3 / Core with the stock Grove cable and nothing else attached. If it initializes and lists PICCs there, the module is good and the problem is on the ESP32-C3 side (pins, cable, pull-ups, supply). If it reproduces the same NACKs there, the module is the fault and M5Stack support / RMA is the right path.

  17. mfranchini commented on Dec 2, 2026

    @mfranchini
    Author

    I ran the exact plain-Wire sketch you provided, unchanged, after removing and restoring the reader’s 5 V supply. Board: ESP32-C3 Dev Module, SDA=GPIO10, SCL=GPIO6, 100 kHz. The sketch reports sdk=v6.1.1-dirty.

    The I²C communication is intermittent. In the first run, probes usually ACKed (endTx=0) but two returned endTx=5; some reads returned one byte, always 0xF7 for both registers 0x00 and 0x3F, while others returned zero bytes. Writes to 0x00 returned both endTx=0 and endTx=4.

    After a cold power cycle, the second run showed the same behavior: intermittent probe ACKs, many reads with n=0, and writes returning both 0 and 4. I measured 5 V at the reader supply and 3.3 V idle on SDA and SCL.

    I don’t have an AtomS3/CoreS3 available, so I can’t perform the cross-host test. Given that the exact baseline sketch shows intermittent ACK/NACK and the same 0xF7 value for different registers, what would you recommend as the next diagnostic step on the ESP32-C3, or should I contact M5Stack support about the module?

    LOG #1
    sdk=v6.1.1-dirty sda=10 scl=6 freq=100000
    [ 1046][I][esp32-hal-i2c-ng.c:112] i2cInit(): Initializing I2C Master: num=0 sda=10 scl=6 freq=100000
    --- iter 0 t=1056 ms
    probe endTx=0
    read 0x00 endTx=0 n=1 val=0xF7
    read 0x3F endTx=0 n=1 val=0xF7
    write 0x00 endTx=0
    --- iter 1 t=1194 ms
    probe endTx=0
    read 0x00 endTx=0 n=1 val=0xF7
    read 0x3F endTx=0 n=1 val=0xF7
    [ 1316][E][esp32-hal-i2c-ng.c:275] i2cWrite(): i2c_master_transmit failed: [264] ESP_ERR_INVALID_RESPONSE
    write 0x00 endTx=4
    --- iter 2 t=1426 ms
    probe endTx=0
    read 0x00 endTx=0 n=1 val=0xF7
    [ 1520][E][esp32-hal-i2c-ng.c:372] i2cWriteReadNonStop(): i2c_master_transmit_receive failed: [264] ESP_ERR_INVALID_RESPONSE
    [ 1531][E][Wire.cpp:532] requestFrom(): i2cWriteReadNonStop returned Error 264
    read 0x3F endTx=0 n=0 val=--
    [ 1589][E][esp32-hal-i2c-ng.c:275] i2cWrite(): i2c_master_transmit failed: [264] ESP_ERR_INVALID_RESPONSE
    write 0x00 endTx=4
    --- iter 3 t=1698 ms
    probe endTx=0
    read 0x00 endTx=0 n=1 val=0xF7
    read 0x3F endTx=0 n=1 val=0xF7
    write 0x00 endTx=0
    --- iter 4 t=1849 ms
    probe endTx=0
    [ 1945][E][esp32-hal-i2c-ng.c:372] i2cWriteReadNonStop(): i2c_master_transmit_receive failed: [264] ESP_ERR_INVALID_RESPONSE
    [ 1956][E][Wire.cpp:532] requestFrom(): i2cWriteReadNonStop returned Error 264
    read 0x00 endTx=0 n=0 val=--
    read 0x3F endTx=0 n=1 val=0xF7
    write 0x00 endTx=0
    --- iter 5 t=2083 ms
    probe endTx=5
    [ 2183][E][esp32-hal-i2c-ng.c:372] i2cWriteReadNonStop(): i2c_master_transmit_receive failed: [264] ESP_ERR_INVALID_RESPONSE
    [ 2194][E][Wire.cpp:532] requestFrom(): i2cWriteReadNonStop returned Error 264
    read 0x00 endTx=0 n=0 val=--
    read 0x3F endTx=0 n=1 val=0xF7
    [ 2259][E][esp32-hal-i2c-ng.c:275] i2cWrite(): i2c_master_transmit failed: [264] ESP_ERR_INVALID_RESPONSE
    write 0x00 endTx=4
    --- iter 6 t=2368 ms
    probe endTx=0
    [ 2453][E][esp32-hal-i2c-ng.c:372] i2cWriteReadNonStop(): i2c_master_transmit_receive failed: [264] ESP_ERR_INVALID_RESPONSE
    [ 2464][E][Wire.cpp:532] requestFrom(): i2cWriteReadNonStop returned Error 264
    read 0x00 endTx=0 n=0 val=--
    read 0x3F endTx=0 n=1 val=0xF7
    write 0x00 endTx=0
    --- iter 7 t=2664 ms
    probe endTx=0
    [ 2752][E][esp32-hal-i2c-ng.c:372] i2cWriteReadNonStop(): i2c_master_transmit_receive failed: [264] ESP_ERR_INVALID_RESPONSE
    [ 2763][E][Wire.cpp:532] requestFrom(): i2cWriteReadNonStop returned Error 264
    read 0x00 endTx=0 n=0 val=--
    read 0x3F endTx=0 n=1 val=0xF7
    write 0x00 endTx=0
    --- iter 8 t=2910 ms
    probe endTx=5
    read 0x00 endTx=0 n=1 val=0xF7
    read 0x3F endTx=0 n=1 val=0xF7
    [ 3054][E][esp32-hal-i2c-ng.c:275] i2cWrite(): i2c_master_transmit failed: [264] ESP_ERR_INVALID_RESPONSE
    write 0x00 endTx=4
    --- iter 9 t=3164 ms
    probe endTx=0
    read 0x00 endTx=0 n=1 val=0xF7
    read 0x3F endTx=0 n=1 val=0xF7
    write 0x00 endTx=0
    Building sketch
    Ln 58, Col 2
    ESP32C3 Dev Module
    on /dev/cu.usbmodem101

    LOG #2

    sdk=v6.1.1-dirty sda=10 scl=6 freq=100000
    [ 1046][I][esp32-hal-i2c-ng.c:112] i2cInit(): Initializing I2C Master: num=0 sda=10 scl=6 freq=100000
    --- iter 0 t=1056 ms
    probe endTx=0
    [ 1123][E][esp32-hal-i2c-ng.c:372] i2cWriteReadNonStop(): i2c_master_transmit_receive failed: [264] ESP_ERR_INVALID_RESPONSE
    [ 1134][E][Wire.cpp:532] requestFrom(): i2cWriteReadNonStop returned Error 264
    read 0x00 endTx=0 n=0 val=--
    read 0x3F endTx=0 n=1 val=0xF7
    [ 1207][E][esp32-hal-i2c-ng.c:275] i2cWrite(): i2c_master_transmit failed: [264] ESP_ERR_INVALID_RESPONSE
    write 0x00 endTx=4
    --- iter 1 t=1316 ms
    probe endTx=5
    [ 1416][E][esp32-hal-i2c-ng.c:372] i2cWriteReadNonStop(): i2c_master_transmit_receive failed: [264] ESP_ERR_INVALID_RESPONSE
    [ 1427][E][Wire.cpp:532] requestFrom(): i2cWriteReadNonStop returned Error 264
    read 0x00 endTx=0 n=0 val=--
    [ 1485][E][esp32-hal-i2c-ng.c:372] i2cWriteReadNonStop(): i2c_master_transmit_receive failed: [264] ESP_ERR_INVALID_RESPONSE
    [ 1496][E][Wire.cpp:532] requestFrom(): i2cWriteReadNonStop returned Error 264
    read 0x3F endTx=0 n=0 val=--
    [ 1554][E][esp32-hal-i2c-ng.c:275] i2cWrite(): i2c_master_transmit failed: [264] ESP_ERR_INVALID_RESPONSE
    write 0x00 endTx=4
    --- iter 2 t=1663 ms
    probe endTx=5
    [ 1763][E][esp32-hal-i2c-ng.c:372] i2cWriteReadNonStop(): i2c_master_transmit_receive failed: [264] ESP_ERR_INVALID_RESPONSE
    [ 1774][E][Wire.cpp:532] requestFrom(): i2cWriteReadNonStop returned Error 264
    read 0x00 endTx=0 n=0 val=--
    [ 1832][E][esp32-hal-i2c-ng.c:372] i2cWriteReadNonStop(): i2c_master_transmit_receive failed: [264] ESP_ERR_INVALID_RESPONSE
    [ 1843][E][Wire.cpp:532] requestFrom(): i2cWriteReadNonStop returned Error 264
    read 0x3F endTx=0 n=0 val=--
    write 0x00 endTx=0
    --- iter 3 t=1959 ms
    probe endTx=0
    [ 2012][E][esp32-hal-i2c-ng.c:372] i2cWriteReadNonStop(): i2c_master_transmit_receive failed: [264] ESP_ERR_INVALID_RESPONSE
    [ 2023][E][Wire.cpp:532] requestFrom(): i2cWriteReadNonStop returned Error 264
    read 0x00 endTx=0 n=0 val=--
    [ 2081][E][esp32-hal-i2c-ng.c:372] i2cWriteReadNonStop(): i2c_master_transmit_receive failed: [264] ESP_ERR_INVALID_RESPONSE
    [ 2092][E][Wire.cpp:532] requestFrom(): i2cWriteReadNonStop returned Error 264
    read 0x3F endTx=0 n=0 val=--
    write 0x00 endTx=0
    --- iter 4 t=2212 ms
    probe endTx=0
    [ 2286][E][esp32-hal-i2c-ng.c:372] i2cWriteReadNonStop(): i2c_master_transmit_receive failed: [264] ESP_ERR_INVALID_RESPONSE
    [ 2297][E][Wire.cpp:532] requestFrom(): i2cWriteReadNonStop returned Error 264
    read 0x00 endTx=0 n=0 val=--
    [ 2355][E][esp32-hal-i2c-ng.c:372] i2cWriteReadNonStop(): i2c_master_transmit_receive failed: [264] ESP_ERR_INVALID_RESPONSE
    [ 2366][E][Wire.cpp:532] requestFrom(): i2cWriteReadNonStop returned Error 264
    read 0x3F endTx=0 n=0 val=--
    write 0x00 endTx=0
    --- iter 5 t=2495 ms
    probe endTx=5
    [ 2595][E][esp32-hal-i2c-ng.c:372] i2cWriteReadNonStop(): i2c_master_transmit_receive failed: [264] ESP_ERR_INVALID_RESPONSE
    [ 2606][E][Wire.cpp:532] requestFrom(): i2cWriteReadNonStop returned Error 264
    read 0x00 endTx=0 n=0 val=--
    [ 2664][E][esp32-hal-i2c-ng.c:372] i2cWriteReadNonStop(): i2c_master_transmit_receive failed: [264] ESP_ERR_INVALID_RESPONSE
    [ 2675][E][Wire.cpp:532] requestFrom(): i2cWriteReadNonStop returned Error 264
    read 0x3F endTx=0 n=0 val=--
    [ 2733][E][esp32-hal-i2c-ng.c:275] i2cWrite(): i2c_master_transmit failed: [264] ESP_ERR_INVALID_RESPONSE
    write 0x00 endTx=4
    --- iter 6 t=2842 ms
    probe endTx=5
    [ 2942][E][esp32-hal-i2c-ng.c:372] i2cWriteReadNonStop(): i2c_master_transmit_receive failed: [264] ESP_ERR_INVALID_RESPONSE
    [ 2953][E][Wire.cpp:532] requestFrom(): i2cWriteReadNonStop returned Error 264
    read 0x00 endTx=0 n=0 val=--
    [ 3011][E][esp32-hal-i2c-ng.c:372] i2cWriteReadNonStop(): i2c_master_transmit_receive failed: [264] ESP_ERR_INVALID_RESPONSE
    [ 3022][E][Wire.cpp:532] requestFrom(): i2cWriteReadNonStop returned Error 264
    read 0x3F endTx=0 n=0 val=--

  18. m5agent commented on Dec 2, 2026

    @m5agent

    Conclusion

    Two things are now separable, and the second one is why I would open the M5Stack ticket now instead of after more ESP32-C3 runs.

    endTx=5 is not a NACK. On this path a zero-length Wire.endTransmission(true) calls i2c_master_probe(), and Wire.cpp maps ESP_ERR_TIMEOUT to 5 (a NACK is ESP_ERR_NOT_FOUND, mapped to 2). In the IDF driver that probe returns ESP_ERR_TIMEOUT only when the bus lock cannot be taken or the hardware SCL-low timeout fires — the probe path arms a 20 ms one. A register read cannot legitimately hold SCL for 20 ms, so at those iterations the controller was not seeing a slow slave; it was seeing a line that stayed low, or a bus it could not start. And the timeouts are not spread at random: they follow a failed transfer (iter 4 → 5, iter 7 → 8), never a clean one. A bus that is stuck after an aborted transfer and recovers a few iterations later is what a slave left mid-transfer or an intermittent connection looks like — not a chip answering with the wrong identity.

    On 0xF7 I have to narrow what I said earlier. One 0xF7 could be a released SDA with a glitch; fifteen identical 0xF7s for 0x00 and 0x3F cannot be that, because a released line reads 0xFF or varies. So the honest version is: the read returns a constant, and it is not register content (those two registers cannot hold the same value). Whether the constant comes from the module or from a systematically wrong first byte is exactly what the controls below decide.

    The uncontrolled variable: sdk=v6.1.1-dirty is not arduino-esp32 3.3.12. That release is based on ESP-IDF v5.5.5, and the -dirty suffix means the core was built against a locally modified IDF tree, which a boards-manager release never is. That also explains 264 between your two reports where 3.3.x returns 259. One run on a stock 3.3.12 is what makes this log a baseline; otherwise any answer, including M5Stack's, has to caveat the toolchain.

    Steps

    1. Release the pins and read them back after a failed probe/read/write, before retrying:
    static void bus_release(const char *tag)
    {
        Wire.end();
        pinMode(PIN_SDA, INPUT_PULLUP);
        pinMode(PIN_SCL, INPUT_PULLUP);
        delayMicroseconds(100);
        Serial.printf("  [%s] released sda=%d scl=%d\n", tag,
                      digitalRead(PIN_SDA), digitalRead(PIN_SCL));
        pinMode(PIN_SCL, OUTPUT);
        for (int i = 0; i < 9; ++i) {
            digitalWrite(PIN_SCL, LOW);  delayMicroseconds(5);
            digitalWrite(PIN_SCL, HIGH); delayMicroseconds(5);
        }
        pinMode(PIN_SDA, OUTPUT);
        digitalWrite(PIN_SDA, LOW);  delayMicroseconds(5);
        digitalWrite(PIN_SCL, HIGH); delayMicroseconds(5);
        digitalWrite(PIN_SDA, HIGH); delayMicroseconds(5);
        Wire.begin(PIN_SDA, PIN_SCL, FREQ);
    }

    If either line prints 0 there, something outside the controller is holding it — module or wiring — and step 2 separates those. If both print 1, the peripheral released cleanly, which puts weight back on the build.

    1. Second device on GPIO10/6: any 3.3 V I2C part, same loop. Cheapest host control, no M5 hardware needed.

    2. Second master for the unit: a Pico, another ESP32, or a 3.3 V USB-I2C bridge at 10 kHz. It does not need to be an AtomS3 — you are testing the unit, not the stack.

    On support: yes, open the ticket now, attach the sketch plus this log and the sdk= line, and ask them to run the unit on a known-good master. That is the cross-host test you cannot do yourself, so support is the shortest route to it. Do not send the module back yet: if step 2 is also bad the fault is host-side and the ticket should be withdrawn, and if step 1 shows a line recovering after a clock-out it behaves like a bus-recovery problem rather than a dead part. If step 2 is clean and M5 reproduces the NACKs on their master, then RMA is justified and the log already supports it.

    Evidence level: code-level verification — arduino-esp32 3.3.12 libraries/Wire/src/Wire.cpp (endTransmission mapping), cores/esp32/esp32-hal-i2c-ng.c (i2cWrite() with size 0 → i2c_master_probe()), esp-idf esp_driver_i2c/i2c_master.c (probe: NACK → ESP_ERR_NOT_FOUND, SCL timeout → ESP_ERR_TIMEOUT; i2c_hal_master_set_scl_timeout_val(..., 20 * 1000, ...)), the 3.3.12 release note, ST25R3916 datasheet §4.3.4 and Tables 19/117, and the U216 schematic. Hardware validation NOT RUN. Virtual-device validation NOT RUN: /api/v1/devices is still 37 profiles with no ESP32-C3, and the emulator's ST25R3916 is a deterministic slave that always ACKs and returns stored register bytes, so it cannot produce a NACK, an SCL timeout, or 0xF7.

    Not covered: we have no ESP32-C3 and no U216 on this side, so I cannot observe your lines during a failure. The two released sda/scl values from step 1 and one stock-build log are what would let me narrow this further.

  19. mfranchini commented on Dec 2, 2026

    @mfranchini
    Author

    Subject: Unit NFC U216 — intermittent I²C communication on ESP32-C3 and ESP32-WROOM-32U
    Hello M5Stack Support,

    I’m testing a Unit NFC U216 reader based on the ST25R3916. I have tried it with two boards using a plain Arduino Wire diagnostic sketch, with no M5 libraries:

    • ESP32-C3 Dev Module, SDA GPIO10, SCL GPIO6, 100 kHz
    • ESP32-WROOM-32U, SDA GPIO21, SCL GPIO22, 100 kHz
      On the ESP32-C3, the sketch repeatedly read 0xF7 from both registers 0x00 and 0x3F, while some reads and writes failed intermittently. After a cold power cycle, the behavior remained intermittent. The reported SDK string was v6.1.1-dirty.

    On the ESP32-WROOM-32U, most probes and reads failed; one read returned 0xAE. The writes failed in all reported iterations.

    I measured 5 V at the reader’s supply and approximately 3.3 V on idle SDA and SCL. The reader is connected with a common ground.

    I don’t have an AtomS3, CoreS3, or another M5Stack host to test the unit. Could you advise the next diagnostic step, or test whether this unit communicates correctly on a known-good I²C host? I can provide the full serial logs and sketch.

    Thank you.

  20. m5agent commented on Dec 2, 2026

    @m5agent

    Conclusion

    The WROOM-32U run takes the ESP32-C3 off the suspect list, but it does not yet take the toolchain off it — and that changes the next step.

    • Both boards fail at the data phase while still ACKing 0x50 at least some of the time, so this is not a C3 pin-mux or i2c-ng problem. A second SoC family on different pins fails at least as hard (every write NACKed on the WROOM).
    • The two hosts returned different bytes, 0xF7 and 0xAE. Neither is a documented identity: they decode to ic_type 0x1E/rev 7 and ic_type 0x15/rev 6, while the ST25R3916 is 0x05 (0x28–0x2F) and the B variant 0x06 (0x30–0x37). The same register cannot read differently on two hosts, so both values are artefacts of a failing transfer, not a wrong chip ID.
    • What the second host does not clear is sdk=v6.1.1-dirty. Stock arduino-esp32 3.3.12 bundles IDF 5.5.5; v6.1.1-dirty is a core built against a locally modified IDF tree. If both boards run that same build, the two runs still share one software stack, and that stack is the only remaining variable that could make two healthy setups fail the same way.

    So: yes, contact support about the module — but open the ticket and run the stock core in parallel, not one after the other. If stock 3.3.12 is clean, the ticket closes itself. If it fails identically, the ticket has a much stronger case and the unit is the only shared part left.

    Please also post ESP.getSdkVersion() from the WROOM-32U build. If it also prints v6.1.1-dirty, the cross-host comparison in your report is weaker than it looks.

    Evidence level: code-level verification — your two logs; ST25R3916 datasheet Tables 19/117 and §4.3.4; U216 schematic (R3/R4 2.2 kΩ to VCC_3V3, R5 10 kΩ on I2C_EN, U3 5 V→3.3 V); arduino-esp32 Wire.cpp / esp32-hal-i2c-ng.c. Hardware validation NOT RUN — no U216 on this bench. Virtual-device validation NOT RUN: /api/v1/devices re-checked, 37 profiles, no ESP32-C3; an ESP32-D0WDQ6 profile exists (basic-v27, same chip family as the WROOM-32U), but the ST25R3916 I2C fixture is admitted on CoreS3 only and is deterministic — it always ACKs and returns fixed register content, models no bus errors or supply — so it can produce the healthy trace but never this failure.

    Steps

    1. Stock-core run, same sketch, on either board: install "esp32 by Espressif Systems 3.3.12" from Boards Manager with no local IDF checkout, and print ESP.getSdkVersion() as the first line. It must print an IDF 5.5.x string, not v6.1.1-dirty. This is the single remaining software variable.
    2. If the two boards shared one Grove cable, swap it for a known-good one and re-seat both ends, then repeat the loop. The cable and the unit's connector are then the only hardware left in common; a change in the NACK rate is a contact problem, not the chip.
    3. Open the M5Stack support ticket now, referencing this thread, with both full logs, the sketch, the SDK string per board and photos of the wiring. Ask them to run the same sketch against a known-good U216 on a reference host and send you the log. Healthy reference: 0x00 → 0x00, 0x3F → 0x2A (0x28–0x2F), n=1 on every read, write endTx=0.

    Not covered

    • I cannot test your unit from here, and I have no U216 or M5Stack host on this bench to produce a measured reference log; the values above are from the datasheet.
    • The SDA/SCL release check and the stock run from my previous comment are still unrun. With a second host failing they no longer gate the decision, but support will ask about them.
    • Whether VCC_3V3 sags under transaction load is unmeasured; a DMM min/max on 5 V at the unit's connector during the loop would show a supply/contact sag, but only a scope on SDA will settle the edge behaviour.
  21. GOB52 commented on Dec 2, 2026

    @GOB52
    Contributor

    Maintainer note, two toolchain corrections. Both are verified against the released artifacts, and both narrow what the logs can be used for.

    1. sdk=v6.1.1-dirty is a stock core, not a locally modified IDF tree.

    The official arduino-esp32 4.0.0 boards-manager release prints exactly that string. From esp32c3-libs-4.0.0.zip of the 4.0.0 release: include/esp_common/include/esp_idf_version.h is 6 / 1 / 1, and the IDF_VER string baked into lib/libesp_system.a is literally v6.1.1-dirty.

    IDF_VER is not a version macro. __build_get_idf_git_revision() in tools/cmake/build.cmake calls git_describe(), which runs

    git -C $IDF_PATH describe --always --tags --dirty --match=v*.*
    

    (tools/cmake/third_party/GetGitRevisionDescription.cmake). esp32-arduino-lib-builder modifies the IDF tree before building it — patches/idf/README.md states that every *.diff there is applied with git apply --3way from the root of $IDF_PATH right after the ESP-IDF tree is resolved — so the working tree is dirty and the suffix is baked into every build. For comparison, the stock 3.3.x packages embed v5.5.5 (Espressif 3.3.12) and v5.5.4 (M5Stack 3.3.10) with no suffix, because those were built from an IDF tag rather than a release branch.

    So the core in use is 4.0.0 rather than 3.3.12, but nothing was modified locally and -dirty is not a red flag. Running 3.3.12 is still a worthwhile comparison, for a different reason than stated earlier: 3.3.x is IDF 5.5 and 4.0.0 is IDF 6.1, so it changes the I2C driver generation.

    2. 264 is a plain NACK on IDF 6.x.

    In components/esp_driver_i2c/i2c_master.c the same statement returns a different constant depending on the IDF major:

    s_i2c_send_commands(i2c_master, ticks_to_wait);
    // Wait event bits
    if (atomic_load(&i2c_master->status) != I2C_STATUS_DONE) {
        ret = ESP_ERR_INVALID_STATE;     // IDF 5.4.4 / 5.5.4        -> 259
    }
    
    if (atomic_load(&i2c_master->status) != I2C_STATUS_DONE) {
        ret = ESP_ERR_INVALID_RESPONSE;  // IDF 6.0.1 / 6.0.3 / 6.1  -> 264
    }                                    // upstream comment: "NACK is received"

    The surrounding code is otherwise identical in both trees; only the constant changed, in IDF 6.0. So 264 here carries the same meaning that 259 carried on IDF 5.x — the transfer was NACKed. The difference in error number between the two earlier reports is the IDF major version, not a change in symptom.

    One narrowing of my own earlier wording as well: I wrote that 0xF7 "reads as a released SDA". Fifteen identical bytes is not that, since a released line reads 0xFF. The defensible statement is only that the value is not register content — which the two hosts returning two different constants (0xF7 and 0xAE) confirms independently.

  22. mfranchini commented on Dec 2, 2026

    @mfranchini
    Author

    I repeated the exact plain-Wire test on the ESP32-C3 SuperMini using Arduino-ESP32 3.3.12 (sdk=v5.5.5), SDA=GPIO10, SCL=GPIO6, 100 kHz. The behavior persists: intermittent probe timeouts, failed reads/writes, and successful reads returning 0xF7 for both registers 0x00 and 0x3F. This also occurred with core 4.0.0 (sdk=v6.1.1-dirty). I have attached both logs and the unchanged sketch. I don’t have another I²C host to test the U216; could you test it on a known-good host?

  23. m5agent commented on Dec 2, 2026

    @m5agent

    Conclusion

    On your direct ask: I can't be that host — there is no U216 and no ESP32-C3 on my bench, so I cannot run your unit. But the stock 3.3.12 run is the control that was missing, and it settles the next step rather than the diagnosis.

    v5.5.5 is a released IDF 5.5 core, so the "dirty IDF / locally modified toolchain" caveat I raised earlier no longer applies. With the same failure on both C3 builds and on the WROOM-32U run in your support draft, the SoC, the pins and both IDF generations (5.5 and 6.1) have now been varied and the symptoms did not move. The U216, the Grove cable and the connector are the only parts present in every failing run. That is enough for support; a fourth host is unlikely to add anything.

    Two details in the new log are worth preserving for the ticket:

    • endTx=5 on 3.3.12, if it is there, is the probe path's 20 ms SCL timeout, not a NACK. A healthy slave cannot hold SCL that long, and seeing it on two IDF generations argues against a driver artefact.
    • 0xF7 for both 0x00 and 0x3F on a stock core rules out "wrong chip ID": two registers with different contents cannot hold the same value, and 0xF7 is not the 0xFF a released SDA gives.

    Also read 259 in the 3.3.12 log as the same NACK that 264 means on IDF 6.x — the constant changed with the IDF major, the condition did not (GOB52's correction above).

    Evidence level: code-level verification plus your two logs. Hardware validation NOT RUN — no U216 and no ESP32-C3 here. Virtual-device validation NOT RUN and not applicable: /api/v1/devices is 37 profiles with no ESP32-C3, and the only ST25R3916 model is a deterministic fixture with fixed register content that always ACKs, so it can produce a healthy trace but never this NACK/timeout behaviour.

    Steps

    1. C3-side, one last check: if all failing runs used the same Grove cable, swap it for a known-good one and re-seat both ends, then repeat the unchanged sketch once on stock 3.3.12 (10 iterations). A changed NACK/timeout rate means contact, not the chip — put that in the ticket.
    2. Open the M5Stack support ticket now, with both logs, the sketch and the sdk= line per run. Ask them to run this same plain-Wire sketch with your unit on a reference host and send you the log. Healthy reference: 0x00 → 0x00, 0x3F → 0x2A (0x28–0x2F), n=1 on every read, write endTx=0.
    3. If they reproduce the timeouts/NACKs, RMA. If their reference host is clean but yours still fails after step 1, RMA is equally supported by this thread. Do the cable swap before returning the unit, or it may come back "no fault found".

    Not covered

    • The two logs are not visible to me: the comment body has no attachment links on my side. Please paste the stock-3.3.12 log inline or re-attach it — support will need the verbatim log as well.
    • I still cannot observe VCC_3V3 at the module's LDO output during a transaction, and I have no second U216 to compare against.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions