How to read data between two photon

Good Morning
I have two photon. Photon1 have connect more sensor and generate with Particle.Variable some data.
Now I would do like to read this data from Phonton2 via wifi (connect at the same router). I was not able to find in documentation or in community forum a answer.
It’s possible? are there a example? in community forum.
Thanks a lot
Valentino

Publish/subscribe would be the easiest way, though you could use direct connections. Depends on your requirements, but either is documented.

A simple forum search for “two devices communication” came up with this :wink:

That’s the beauty of the search feature - providing it’s put to its intended use

With the two suggested Particel features you should be able to get started by looking them up in the docs and more searching in the forum.

4 Likes

Thanks a lot ScruffR and Moors7 for yours answers.
I wish you happy Easter.
Valentino

Perhaps a less elegant way is one that I have used on Arduino-based systems which uses I2C. The software is called EasyTransfer and it works great. The one advantage, if applicable in this case, is that it doesn’t use any form of radio or Internet services. Again, given the additional benefits of the Particle pub/sub model, it might not provide any value but I thought I would mention it.

I haven’t tried it with any Particle devices but since it’s standard I2C it “should” work.

1 Like

I’ve tried it and can confirm that it works great.

//Sender
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);
}
//Receiver
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);
    }

}
1 Like

Thanks @bko, you saved me the trouble of verification.

The progressive tutorial’s last part (“The Buddy System”) details how to publish/subscribe between two Photons – and they can be anywhere in the world (including on your LAN).

cheers,
ParticleD

3 Likes

Thanks a lot all people answer to my post.
Next time I will exercise and if possible I give a feedback.
Best regards Valentino