Cloud not connected

#define BLYNK_PRINT Serial
#include "blynk/blynk.h"

char auth[] = "xxxxxx";

Timer timer (500,DoorAlarm);

WidgetLED led0(V0);

void setup()
  pinMode(2, INPUT_PULLDOWN);

void DoorAlarm ()

int Door_Sensor = digitalRead(2);

if (Door_Sensor == 1) led0.on();



void loop()

New to programming. As i downloaded this code, particle went offline. I used a timer to avoid “flood data” on Blynk server. Now the Photon is not communicating with the cloud. Need to download the firware via USB cable ?
Thanks in advance to the Particle community !!

@Omer, it is not a good idea to call network functions within a timer (eg. led0.on() ). Instead, set a flag that you can read in loop() which then calls the functions. One word of caution - the code as you have it will call led0.on() or at 500ms intervals. You may want to set a previous_state with which you can set the led only when the state of the door sensor changes.

The easiest way to recover your Photon is to put it in SAFE mode and then reflash it with your new code. :grinning:

Thanks @peekay123 for the help. Points noted !!

1 Like

@peekay123, i am looking into this example

Does it looks similar to my code (to some extent) ? User is writing multiple times on to the Blynk server but i guess the frequency is 1 sec, where as i was using sampling rate of 500 msec.

That is not a sample for Particle, where timers are run by FreeRTOS!

These SimpleTimers are run via in loop().

An equivalent timer library for Particles would be TimeAlarms


@ScruffR Especially the last bit of information (TimeAlarms) is very helpful. Didn’t knew about that.
Cheers :grinning:

1 Like