Arduino Online/Offline Override

When i get some time i’ll have more of a look - you may need to modify time out behaviours etc

1 Like

ALAS!!! You mean the BlynkEthernet.h right? I read a thread ago about this, and applying that would be making a line with the word “fatal” into a comment and adding two line of codes under it.

//BLYNK_FATAL("DHCP Failed!");
BLYNK_LOG("DHCP failed. check your network connection!");
BLYNK_LOG("bypassing blynk...");

Just uploaded it and it tries to connect, after a few seconds, it goes to my local commands and prints out “Off” as i wanted it to! WOOHOO!!! I think this is it! Will try and apply my actual instructions to my project and update my progress!
Thank you for your patience with me! I think this one is solved!!! :innocent:

—side note, i do not know how/why those lines of code worked, i just followed the instructions from the thread i have read. and i am just glad that they do. hehe


Well done - I hadn’t had time to look as I’m chasing other bugs at the moment!

1 Like

no problem! you helped me A LOT!!! Seriously, thanks! :smile:

1 Like

This is good stuff! I hadn’t finished my battery powered DHT11 monitor because of the possibility of it draining the batteries if the Cayenne server was down. This definitely helps, but I think I’m going to change direction and use MQTT when it is released and forgo any cayenne functions.

1 Like

Hey! I have build a aquarium controller wit arduino, I have 8 relay and temp. sensors. Some relay control lights and heaters. The lights are on schedule and the heaters are trigger by temp. Everything is made with cayenne, now my worry is when the net or server is going down they will stop working. Can you help with your code for local and how to combine with cayenne code? I"m very new to this coding!

It has been a long time since i made that, But if I remember correctly…

1)Search for a file within the arduino: BlynkProtocol.h and edit it.

do a find and remove the comments on ALL the lines like this:
There are 5 or six or so from memory

2)With the edited version saved, you can now use:

//Do Stuff for Online here

//Do Stuff for Offline here

Hope this helps :innocent:

Thanks! I will give it a try

Let me edit that… I think it goes more like this:

1)Search for a file within the arduino library (cayenne folder i
think…): BlynkProtocol.h
and edit it.

do a find and remove the comments on ALL the lines like this:
There are 5 or six or so from memory

2)With the edited version saved, you can now use:

//create a global boolean variable
bool varStatus=false;



Loop (){
//use an if-else test for varStatus

//Do online stuff here}
//Do offline stuff here}

////DO NOT TRUST MY SYNTAX!!! it’s been long since i programmed. I might
miss a syntax or two, but i hope you get the idea here…

:+1: I will try this next week, will see how it goes! When you say edit , you say to only uncomment or I have to do something else?

Uncomment then Save the BlynkProtocol.h
Alright, Good luck man

1 Like

How can i show ONLINE/OFFLINE status on Cayenne dashboard or on App with a Widget? I was thinking to give 0/1 to virtual pin an use it with 2 state widget any ideas?

Yes, that is how I would do it if you want a widget to display the state

Thank you for the answer, In my opinion Online/Offline state is essential because sometimes the board goes offline and it takes time to get offline message from cayenne

Can you let me know where I can find the KEYWORDS file? I would like to use CAYENNE_DISCONNECTED() as well. ( I have uncommented it in BlynkProtocol.h)

Actually, I have pretty much got this working now i.e. I want to know when Cayenne is disconnected - if so, I will shut down the processes I am running in case I miss the scheduled STOP time. I have set up a simple program to test it on a UNO with W5100 ethernet shield. Code following.
The problem I have - is that the LED I have to show if connected - still pulses HIGH even when the ethernet cord is pulled - I guess each time it tries to re connect? That makes it unsuitable to make decisions on. Has anyone a solution for this?
CAYENNE_DISCONNECTED() does not show as orange writing but still seems to work OK (I took the # out of keywords file).

//#define CAYENNE_DEBUG // Uncomment to show debug messages
#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
#include <CayenneEthernet.h>

// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token = “XXXXXXX”;

boolean onlineStatus = true;

const int TestPin = 13;

void setup()

pinMode (TestPin, OUTPUT);

onlineStatus = true;

onlineStatus = false;

void loop()
if ( onlineStatus == true) {
digitalWrite(TestPin, HIGH);
} else {
digitalWrite(TestPin, LOW);