# Particle Subscribe

**URL:** <https://community.particle.io/t/particle-subscribe/37151>\
**Category:** Troubleshooting\
**Created:** [November 3, 2017, 3:59pm UTC](https://community.particle.io/t/particle-subscribe/37151 "2017-11-03T15:59:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bscuderi](https://avatars.discourse-cdn.com/v4/letter/b/4491bb/32.png) [@bscuderi](https://community.particle.io/u/bscuderi)\
**Post date:** [November 3, 2017, 3:59pm UTC](https://community.particle.io/t/particle-subscribe/37151/1 "2017-11-03T15:59:44Z")

</div>

I can’t figure out why my photon isn’t subscribing. Photon one sends out a publish succesfully and I can see that and its associated data in the dashboard, however, photon two isn’t seeing it. I have the handler taking the data and storing it to a particle variable and my variable was never updating. At first I thought it was how I was converting my strings to a number or something but then I threw in the handler for it to publish its own event so I could troubleshoot if it was even subscribing correctly. It never publishes that event so something is wrong with my subscribe code?!

```cpp
// the pertinent code
// photon 1

void loop() {
Particle.publish("CurrentTemperature", temperature); // publish to cloud
}

// photon 2
double poolTemp = 0.0;

void setup() {
Particle.subscribe("CurrentTemperature", tempHandler, MY_DEVICES);
Particle.variable("PoolTemp", poolTemp);
}

void loop() {
}

void tempHandler(const char *event, const char *data)
{
poolTemp = atof(data);
Particle.publish("hey", "on");
}

```

---

<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:** [November 3, 2017, 4:12pm UTC](https://community.particle.io/t/particle-subscribe/37151/2 "2017-11-03T16:12:58Z")

</div>

> [@bscuderi](#):
>
> Particle.publish("CurrentTemperature", temperature);

Your publish statement should include PRIVATE. Hopefully, you have some delay in there so you're not publishing every millisecond or so.

```cpp
Particle.publish("CurrentTemperature", temperature, PRIVATE);

```

Also, note this info from the docs,

> NOTE 2: Particle.publish() and the Particle.subscribe() handler(s) share the same buffer. As such, calling Particle.publish() within a Particle.subscribe() handler will wipe the subscribe buffer! In these cases, copying the subscribe buffer's content to a separate char buffer prior to calling Particle.publish() is recommended.

---

<div class="post-metadata">

**Author:** ![bscuderi](https://avatars.discourse-cdn.com/v4/letter/b/4491bb/32.png) [@bscuderi](https://community.particle.io/u/bscuderi)\
**Post date:** [November 3, 2017, 6:46pm UTC](https://community.particle.io/t/particle-subscribe/37151/3 "2017-11-03T18:46:22Z")

</div>

Yeah the code has lots of other stuff in there. Actually it only publishes once every four hours. I see it come through in the dashboard but my subscribe wouldn’t work. Okay so with that note maybe my subscribe was working but maybe I’m not handling the data correctly?

---

<div class="post-metadata">

**Author:** ![bscuderi](https://avatars.discourse-cdn.com/v4/letter/b/4491bb/32.png) [@bscuderi](https://community.particle.io/u/bscuderi)\
**Post date:** [November 3, 2017, 7:06pm UTC](https://community.particle.io/t/particle-subscribe/37151/4 "2017-11-03T19:06:27Z")

</div>

> [@Ric](#):
>
> Particle.publish("CurrentTemperature", temperature, PRIVATE);

Hey thanks adding private made that work! Thanks 🙂 I knew I was close! Are we not able to get data from a public publish? I'm just confused why that worked I racked my brain yesterday trying to fifure this out!
