Back to engineering archive

Record 039 / Connected systems

ESP32 and FRDM I2C interface pair

The selected ESP32 master converts local colour commands to a byte, checks the I2C write result and reads a one-byte reply from the FRDM interface.

Firmware module
ESP32FRDMI2C

Firmware flow

Send a command byte and read the response

Selected ESP32 master transaction after command parsing.

Send the mapped command byte, stop on a write error, then request a one-byte reply. Report the received byte if available; otherwise report that no reply arrived.

The reply value is not checked against an expected value. This flow describes source behavior, not a verified hardware result.

Read the implementation

Selected firmware excerpt. The diagram explains the code; it is not a hardware test.

Selected ESP32 master transaction excerpt

    // send command byte
    Wire.beginTransmission(I2C_ADDRESS);
    Wire.write(code);
    uint8_t err = Wire.endTransmission();
    if (err != 0) {
      Serial.printf("I2C Tx error %d\n", err);
      return;
    }

    // request 1-byte ACK
    Wire.requestFrom(I2C_ADDRESS, (size_t)1);
    if (Wire.available()) {
      uint8_t ack = Wire.read();
      Serial.printf("ACK received: 0x%02X\n", ack);
    } else {
      Serial.println("No ACK received.");
    }
ResultReport the transmission error and return
ActionRequest one response byte
ResultRead and report the byte
ResultReport that no response arrived

Technical notes

A one-byte command interface

The selected ESP32 master maps RED, GREEN, BLUE and OFF commands received over Serial to a command byte. It addresses the FRDM interface at 0x42 using SDA 21 and SCL 22.

Write status before readback

The master checks endTransmission() and returns on a nonzero status. After a successful write, it requests one response byte and reports either the byte or its absence.

What the response establishes

Receiving a byte is reported without comparing its value against an expected acknowledgement. The excerpt covers the master transaction; it does not establish a measured bus timing, a successful hardware build or a final delivered revision.

Engineering archiveArchive record

Project enquiries

Discuss your project.

Tell us what you’re developing and where you need engineering support.

Discuss your project