Wher is the file for Arduinoexample: dht_advanced_session_example

Have just viewed the youtube: Introduction to Cayenne: Advanced Online Session
Introduction to Cayenne: Advanced Online Session - YouTube which used an Arduino example file meant to be on Community, can someone please provide a link to file
Cheers

Hi @rfb000 and welcome to the Cayenne Community.

@bestes – do you still have the sketch file you used when making this video? It appears at 26:23

@rsiegel @rfb000 I just searched for that sketch file…looks like I don’t have it anymore :frowning:

But, this would be a good place to start, you can use this code and make some small modifications as you need.

Hope this helps,

~Benny

Thanks Benny, I’m new to Cayenne and finding some examples difficult to find although I’m well experienced with Arduino code. Trolling through the Community posts can be a bit of a pain but I expect that the support pages are still being developed and further documentation is still being developed.

I’d really like to find a definitive reference to things like ‘Cayenne.run()’ ‘Cayenne.loop()’ ‘Cayenne.virtualWrite()’ etc something that confirms purpose and any arguments used in those functions.

I thought there would be a library description on GitHub or somewhere but not yet found so any links would be appreciated.

Thanks for the prompt response to my post

@rsiegel think this ^ is something we could add to ‘The Library’ ?

~B

@bestes

We can develop some kind of library with users` codes that are confirmed as working and where people can copy them without searching in themes with a lot of posts ? :slight_smile:

1 Like

@ognqn.chikov, he’s referring to this – if you think you have something that should go there, let us know! :slight_smile:

@bestes, I could make a post with what you tagged me for, but I’m not sure there is that much to say. Let me share here first and we can discuss?

For virtualWrite(), (and most of the other functions used in the Cayenne Arduino Library) we have documentation here.

Cayenne.run() is an infrastructure function that needs to be called at an interval to keep your device connected to Cayenne. It doesn’t take any optional parameters. For the most part, just include this once at the start of your sketch’s void loop() function and you’ll be good to go. And don’t go crazy with delay() functions in the rest of the sketch or it could cause connectivity issues. If you need to replace delay() in your code, you can use the SimpleTimer library. Here’s an example I made some time ago of of replacing delay() with SimpleTimer in a Cayenne sketch.

Cayenne.loop() isn’t present in the sketches used when connecting a device to Cayenne with the Arduino Library. Instead think of it like a replacement for Cayenne.run() when connecting an Arduino/ESP8266 device through the Cayenne MQTT/“Bring Your Own Thing” API via the Cayenne MQTT Arduino Library. Just like the run() function above, include it once in your loop() function and it will maintain connectivity to Cayenne.

This function has a single, optional parameter for advanced users. It can take a single integer value for yield time which specifies the time in milliseconds that code will wait to process incoming messages, for users with time sensitive code who want to ensure our connectivity function doesn’t block their other items in the main loop from running. If not specified, this defaults to 1000ms (so 1 second).

The code for it also includes this note:

/*
	* Main Cayenne loop
	*
	* @param yieldTime  Time in milliseconds to yield to allow processing of incoming MQTT messages and keep alive packets.
	* NOTE: Decreasing the yieldTime while calling write functions (e.g. virtualWrite) in your main loop could cause a 
	* large number of messages to be sent to the Cayenne server. Use caution when adjusting this because sending too many 
	* messages could cause your IP to be rate limited or even blocked. If you would like to reduce the yieldTime to cause your 
	* main loop to run faster, make sure you use a timer for your write functions to prevent them from running too often. 
	*/
1 Like