# Set subscribe handler data as global

**URL:** <https://community.particle.io/t/set-subscribe-handler-data-as-global/59099>\
**Category:** Cloud\
**Tags:** photon\
**Created:** [January 18, 2021, 2:15am UTC](https://community.particle.io/t/set-subscribe-handler-data-as-global/59099 "2021-01-18T02:15:30Z")\
**Posts on this page:** 1\
**Showing post:** 18

<div class="post-metadata">

**Author:** ![kannnyyy](https://avatars.discourse-cdn.com/v4/letter/k/c77e96/32.png) [@kannnyyy](https://community.particle.io/u/kannnyyy)\
**Post date:** [January 20, 2021, 6:18am UTC](https://community.particle.io/t/set-subscribe-handler-data-as-global/59099/18 "2021-01-20T06:18:26Z")

</div>

![particleconsole1](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/b/5/b5f3d2d31e2f8e4a275f65f068f32031163a1c75.png)

Here’s my particle cloud event console. Seems like the LDR Threshold if statement inside the void loop() is not allowing the particle.subscribe(temp) and (pressure) to be read constantly.

I will re-write my code, replacing particle.publish/subscribe with MQTT.client publish.subscribe, use softaware timer functions and keep my void loop as clean as possible.

> **[Keep your void loop() clean](http://help.blynk.cc/en/articles/2091699-keep-your-void-loop-clean)**
>
> Troubleshooting of one of the most popular mistakes of newbie Blynk users.

> **[Timer interrupts on the Particle photon and Blynk Communication via Bluetooth...](https://community.blynk.cc/t/timer-interrupts-on-the-particle-photon-and-blynk-communication-via-bluetooth-problem/32080/10)**
>
> @PeteKnight @Costas I have changed my code as you and the article has advised and everything is running smoothly. Thanks again. Now I’m investigating the possibility of implementing some energy saving techniques associated with putting my...

---

_[View the full topic](https://community.particle.io/t/set-subscribe-handler-data-as-global/59099)._
