Hello to everyone,
I’m currently working on a biomedical device for measuring heart rate and Galvanic Skin Response(GSR). Because of a sample rate needed for heart rate measurement(50 Hz), message to Cayenne must be send in a time of maximum 20 ms. I checked my device with example code from Arduino library and it worked perfectly. Howewer, I’ve got troubles with getting my test program for to work - channels and values on these channels are absent in my web browser device menu. What could be a cause of such behaviour of Cayenne? I’m new to Cayenne and IoT in general, so I may make some mistakes due to lack of experience/knowledge.
Device is based on ESP32 DevkitC, code for testing communication in my biomedical device looks like this(for now, values from sensors are replaced with random values, just for purpose of testing communication capabilities, comments for file functions are temporary):
#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP32.h>
#include <CayenneArduinoMQTTClient.h>
// WiFi network info.
char ssid[] = "AndroidAP";
char wifiPassword[] = "63c1875d1564";
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "";
char password[] = "";
char clientID[] = "";
unsigned long int lastMillis = 0;
unsigned int HeartRateSamples[150];
unsigned long int time_begin;
unsigned int time_of_operation;
unsigned int GSR_Value = 0;
unsigned int GSR_Sample = 0;
unsigned int GSR_Values = 0;
unsigned int Heart_Rate = 0;
unsigned int Voltage = 0;
unsigned int VoltageSample = 1;
unsigned int LoopCounter = 1;
unsigned int VoltageLoopCounter = 1;
bool measure_started = false;
void setup()
{
Serial.begin(9600);
randomSeed(300);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
}
void loop()
{
time_begin = micros();
HeartRateSamples[LoopCounter] = random(2000, 4000);
if(LoopCounter == 1 && measure_started == true)
{
//file.close();
}
if(LoopCounter%5 == 0)
{
GSR_Sample = random(500, 550);
GSR_Values += GSR_Sample;
}
if(LoopCounter == 149)
{
//file.open()
}
if(LoopCounter == 150)
{
GSR_Value = GSR_Values/30;
Cayenne.virtualWrite(0, GSR_Value);
Cayenne.virtualWrite(1, HeartRateSamples[150]);
LoopCounter = 0;
}
if(LoopCounter == 150 && VoltageLoopCounter == 10)
{
VoltageSample = random(400, 4000);
GSR_Value = GSR_Values/30;
Cayenne.virtualWrite(0, GSR_Value);
Cayenne.virtualWrite(1, HeartRateSamples[150]);
Cayenne.virtualWrite(2, VoltageSample);
LoopCounter = 0;
VoltageLoopCounter = 0;
}
measure_started = true;
LoopCounter++;
VoltageLoopCounter++;
time_of_operation = micros() - time_begin;
if(time_of_operation<20000)
{
delayMicroseconds(20000-time_of_operation);
}
}