# \[solved\] Particle Photon not receiving i2c transmission

**URL:** <https://community.particle.io/t/solved-particle-photon-not-receiving-i2c-transmission/30704>\
**Category:** Troubleshooting\
**Created:** [March 20, 2017, 1:25am UTC](https://community.particle.io/t/solved-particle-photon-not-receiving-i2c-transmission/30704 "2017-03-20T01:25:42Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![bko](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bko/32/20704_2.png) [@bko](https://community.particle.io/u/bko)\
**Post date:** [March 21, 2017, 2:39am UTC](https://community.particle.io/t/solved-particle-photon-not-receiving-i2c-transmission/30704/7 "2017-03-21T02:39:13Z")

</div>

Hi @kaydend

OK, the following code works for me! First the transmitter sending one incrementing byte to address 8 and blinking the D7 LED to show that it is sending:

```cpp
uint8_t val = 0;

void setup() {
    Wire.begin();
    pinMode(D7,OUTPUT);
}

void loop() {
    delay(1000);
    digitalWrite(D7,HIGH);
    Wire.beginTransmission(8);
    Wire.write(&val,1);
    Wire.endTransmission();
    val++;
    delay(20);
    digitalWrite(D7,LOW);
}

```

Now the receive side using onReceive:

```cpp
uint8_t data[8];
int idx;

void receiveEvent(int numOfBytes) {
    idx = 0;
    while (Wire.available()) { 
        data[idx++] = (uint8_t)Wire.read();       
  } 
}

void setup() {
    Serial.begin(9600);
    Wire.begin(8);
    Wire.onReceive(receiveEvent);
    pinMode(D7,OUTPUT);

}

void loop() {
    if (idx != 0) {
        digitalWrite(D7,HIGH);
        Serial.print("RX (");
        Serial.print(idx);
        Serial.print("): ");
        for(int i=0;i<idx;i++) {
            Serial.println(data[i],HEX);  
        }
        idx = 0;
        digitalWrite(D7,LOW);
    }

}

```

I let this run for several minutes with no problems. Here’s a copy of the serial output.

```auto
RX (1): F9
RX (1): FA
RX (1): FB
RX (1): FC
RX (1): FD
RX (1): FE
RX (1): FF
RX (1): 0
RX (1): 1
RX (1): 2
RX (1): 3
RX (1): 4
RX (1): 5
RX (1): 6
RX (1): 7

```

---

_[View the full topic](https://community.particle.io/t/solved-particle-photon-not-receiving-i2c-transmission/30704)._
