Last mile connectivity to cayenne cloud through Rpi

Connecting a sensor to Rpi and subsequently to cayenne cloud was very easy and interesting.

We are working on a project where Rpi is receiving data over radio serially.The serial data has 5-6 senors values (which needs to be parsed).

Is it possible to connect the parsed data to mydevices.cayenne cloud. This should be as if the sensor is connected locally to Rpi board.

Thanks in advance.

No, not currently but the API is being worked on and should be released soon. When the API is release you should have no problem doing that.

To follow up with Adamā€™s comment, you can do this with virtual analogs on the Arduino platform now if you donā€™t want to wait.

Read in the serial stream, parse, and create access functions as shown in the Arduino examples on Cayenne. Hereā€™s how I might do it on the ESP8266:

//#define CAYENNE_DEBUG         // Uncomment to show debug messages
//#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space

#include "CayenneDefines.h"
#include "BlynkSimpleEsp8266.h"
#include "CayenneWiFiClient.h"

// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token[] = "<your_token>";
// Your network name and password.
char ssid[] = "<your_ssid>";
char password[] = "<your_pwd>";

float firstParm;
float secondParm;
float thirdParm;

void setup()
{
  Serial.begin(9600);
  Cayenne.begin(token, ssid, password);
}

void loop()
{
  Cayenne.run();
  
  if (Serial.find(":")) //Some start token. Could be newline, etc.
  {
    firstParm      = Serial.parseFloat(); //Note that the parse routines expect CSV
	secondParm = Serial.parseFloat();
	thirdParm     = Serial.parseFloat();
	//...etcetera
  } 
}

CAYENNE_OUT(1)
{
	Cayenne.virtualWrite(1, firstParm);
}

CAYENNE_OUT(2)
{
	Cayenne.virtualWrite(2, secondParm);
}

CAYENNE_OUT(3)
{	
	Cayenne.virtualWrite(3, thirdParm);
}

Cheers,

Craig

1 Like

Thanks Craig & ats1080s for replies.

Sure Craig will try your solution on Raspberry pi till new Apiā€™s are released and post the results.

Thanks,
Ganesh

Hi Craig,

Tried the Cayenne.virtualWrite and it is working fine on Uno.
Dash board was updated with the expected values. Just came to know that ā€œmobile appā€ is not ready as it was for RPI.

I would like to replicate the same ( Cayenne.virtualWrite api.) in RPi as well.
Can you please give pointers on how to start developing on RPI for Cayenee. All I know is that Cayenne agent is installed in /etc/mydevices. Not sure where the code resides where we can use.

Could not find the right docs for development env for RPi for Cayenne agent

Thanks Again
Ganesh

Awesome sauce!

The Android support for Arduino is nearing Beta release, so that wonā€™t be long at all.

It will be a little different under RPi though, using a File I/O mechanism, but perhaps some Python examples will be developed for easier interaction with your user driver.

I canā€™t wait for RPi integration either.

Cheers,

Craig

Thanks Craig !!!
Sorry for the delayed reply ( it was a long weekend for us )

Yeah we need to have some python code to do all the parsing and interfacing with the cayenne cloud interface
using Cayenne.virtualWrite.

Currently setting the dev env on RPi for cayenne agent interface
Any pointers for docs/sample code for using cayenne driver interface on RPi would be helpful.

Regards
Ganesh

Iā€™ll send you the doc to check out via email :slight_smile:

-B