# Multiple Photon InterConnectivity Project - Help Please!

**URL:** <https://community.particle.io/t/multiple-photon-interconnectivity-project-help-please/35778>\
**Category:** General\
**Created:** [September 4, 2017, 9:50pm UTC](https://community.particle.io/t/multiple-photon-interconnectivity-project-help-please/35778 "2017-09-04T21:50:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DIY\_Micah](https://avatars.discourse-cdn.com/v4/letter/d/b77776/32.png) [@DIY\_Micah](https://community.particle.io/u/DIY_Micah)\
**Post date:** [September 4, 2017, 9:50pm UTC](https://community.particle.io/t/multiple-photon-interconnectivity-project-help-please/35778/1 "2017-09-04T21:50:50Z")

</div>

Hi all. I am relatively new to IoT devices and programming but I thought I’d dive head long into a project I’d actually want to get running to learn how to do it. Crazy, I know.

Here is my idea that I have very little idea how to get running.

I want to make a gift for my siblings. These gifts would be an LED connected to a Photon, powered by a wall plug, connected to their various networks, and these lights would all be interconnected. When sibling A activates his light (saying “Hi”), it would turn blue. Then, in response to sibling A activating his light, siblings B, C, and D etc. would have their respective lights activate blue as well in whatever location and network they are located. In response, sibling B could activate their light saying “hi” in return and thus push their selected color onto the other lights, possibly with some pulsating because it was a response to sibling A first saying “hi”.

To start with, I already have two photons, two neopixel rings, and the power supplies for hardware. I have them both wired up and I have loaded simple projects that I have found online to make sure my neopixels are working and wired correctly. Both photons connect to the internet just fine.

Where I am now having problems is how to I tell the photons to look for the “Hi” that another lights are sending? I’m assuming I’d have to program in a publish command and use the cloud to manage sending and receiving the publish commands? Would I also need to add a subscribe function? How then could I set up a return “hi” to the other units? I’ve already spent the better part of a couple days to no avail and am back to the drawing board as it were on my coding. Any info/advice/sarcastic comments are greatly appreciated and welcomed.

I’m sure I’ll have many more questions arise but I feel like this is a good start.

Thanks and I look forward to your help.  
Micah

---

<div class="post-metadata">

**Author:** ![Moors7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/moors7/32/588_2.png) [@Moors7](https://community.particle.io/u/Moors7)\
**Post date:** [September 4, 2017, 10:24pm UTC](https://community.particle.io/t/multiple-photon-interconnectivity-project-help-please/35778/2 "2017-09-04T22:24:14Z")

</div>

Publish and subscribe is the way to go.  
Photon A publishes “Hi A”, to which Photon B subscribes. In turn, Photon B can publish “hi B”, to which Photon A subscribes.

So you’d end up with publish/subscribe pairs on the relevant devices.  
There’s an example in the docs: [https://docs.particle.io/guide/getting-started/examples/photon/#the-buddy-system-publish-and-subscribe](https://docs.particle.io/guide/getting-started/examples/photon/#the-buddy-system-publish-and-subscribe)

---

<div class="post-metadata">

**Author:** ![DIY\_Micah](https://avatars.discourse-cdn.com/v4/letter/d/b77776/32.png) [@DIY\_Micah](https://community.particle.io/u/DIY_Micah)\
**Post date:** [September 4, 2017, 11:41pm UTC](https://community.particle.io/t/multiple-photon-interconnectivity-project-help-please/35778/3 "2017-09-04T23:41:08Z")

</div>

Thanks for your reply @Moors7. So using this example, would I need to set up a pub/sub list for each photon?

I.E. A publishes “Hi” and B, C, D, E, etc. would all be subscribed to it. Then B pubs “Hi” and A, C, D, E… are sub’ed to that pub, etc?

---

<div class="post-metadata">

**Author:** ![Ric](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/ric/32/514_2.png) [@Ric](https://community.particle.io/u/Ric)\
**Post date:** [September 5, 2017, 12:04am UTC](https://community.particle.io/t/multiple-photon-interconnectivity-project-help-please/35778/4 "2017-09-05T00:04:01Z")

</div>

Yes, that’s the general idea. You can use the same event name for each of your devices in the Particle.publish(), and only change the data – the data argument could contain the name of the sibling that sent it, for instance. This way, each device only needs one Particle.subscribe, to that common event name.

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [September 5, 2017, 3:45am UTC](https://community.particle.io/t/multiple-photon-interconnectivity-project-help-please/35778/5 "2017-09-05T03:45:53Z")

</div>

To further expand on that, not even the full event name needs to be exactly subscribed to, but only the starting part (prefix) of it.  
So `Particle.subscribe("Hi", hiHandler, MY_DEVICES)` would fire for `Particle.publish("Hi A!", data, PRIVATE)` and for `Hi B!` just the same as for `Himalayas`.

So, as another tip is _not_ to use a nondescript event name like `Hi` but something more creative 😉
