Command a Particle from Another Particle

Hello Everyone

I am trying to communicate a command between to particles. I have a magnetic switch, that when closed reads 3.3V and when open, reads about 80mv. I am trying to have it that when the photon with the switch reads the 80mv, it communicates with my other photon to turn a specific pin on.

Is there anyone who might have insight?

The most straight forward way to do this is via the Publish/Subscribe system. Check that out in the docs.

1 Like

@tcheek38, looking at the documentation would be a good start, including:


1 Like

Right, as of now I have one particle publishing when its’ value reads low

Will the second particle subscribe and use an if statement to say something like - "if this is published, then output = high?’

@tcheek38, the subscribing Photon has a “myHandler()” function (see example in the docs). If that handler is dedicated to a specific event (eg pin is low) then you don’t need to do anything but do the pin action you need.

To be more sophisticated, the publishing Photon could send various conditions in the publish string. The subscribing Photon’s handler could then parse that string to take different/multiple actions based on the received string.

If you look a the PUBLISH example app in the web IDE, you will get an idea of what I mean. :wink:

I did something very similar, take a look at the buddy publish/subscribe example. I was able to break it down and modify it to get what I need.

where is this example?

Also, we understand the publish and subscribe feature,
the santax of how one relates to another is causing confusing

in the IDE there are a few example programs to help you get started.

publish example:
subscribe example:

getting started docs on publish & subscribe:


It is the subscribe example in the web IDE.