2-way communication between MCUs can seem like a daunting task, but this project will help to simplify it. Particle Photons can utilize webhooks, enabling them to send data back and forth via a web protocol.
StepsFirst, I got 2 Particle Photons and set them up using the Android app.
Next, I created a new Photon sketch. In setup, I added the line:
Particle.publish("test", "This is a test");
And in loop, I added:
while(1){
char buffer[32];
char *str_counter = itoa(counter, buffer, 10);
Particle.publish("test", str_counter);
counter++;
delay(5000);
}
Next I created another sketch for my second Particle Photon. It will check if new data arrives and then store it in a cloud variable so I can see it in the cloud console. I copied and pasted the finished code, but replaced "test" with "test2" and the subscribe line with it subscribing to "test" instead. Read the attached code for the entire program.
That's it! Now your two Particle Photons can share data with each other, and you can view their data on the cloud console, all remotely.
Comments