Connecting arduino to cayenne using esp8266wifi

hi ,I am trying to connect the Arduino board to the Cayenne using ESP8266 wifi but I get this message every time. I don’t know what to do. can you help me .i am using Arduino uno

Because the code is for arduino boards which multiple hardware serial pins and arduino uno has only one. You can use software serial to connect the esp to arduino but it is less stable.

@shramik_salgaonkar
I tried the same program but I am getting the following error message

can you please help me.
The following code I took from community is titled (BPM using wemos d1r1)
Its shewing 0 on the channel 0.


i have also add the following line

BPM = 60000 / runningTotal;
println(BPM);

to the code and it Show error message

hai you can try this simple method (https://www.youtube.com/watch?v=JEeA6t5YpTE&list=PLfPtpZzK2Z_Qy2ZbbzvWa58cKKOisMUZ1&index=77)

@dhanaa126
I didn’t understand this method

what is println? shouldn’t it be Serial.println? https://www.arduino.cc/reference/en/language/functions/communication/serial/println/

Also, which code are you referring? can you share it.

@shramik_salgaonkar
this code
#define pulsePin A0
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>

// WiFi network info.
char ssid = “amin”;
char wifiPassword = “amin2019”;

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = “";
char password[] = "
";
char clientID[] = "
*************”;

const int postingInterval = 10 * 1000;

int rate[10];
unsigned long sampleCounter = 0;
unsigned long lastBeatTime = 0;
unsigned long lastTime = 0, N;
int BPM = 0;
int IBI = 0;
int P = 512;
int T = 512;
int thresh = 512;
int amp = 100;
int Signal;
boolean Pulse = false;
boolean firstBeat = true;
boolean secondBeat = true;
boolean QS = false;

void setup() {
Serial.begin(9600);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
}

void loop() {
Cayenne.loop();
if (QS == true) {
Serial.println("BPM: " + String(BPM));
QS = false;
} else if (millis() >= (lastTime + 2)) {
readPulse();
lastTime = millis();
}
}

void readPulse() {

Signal = analogRead(pulsePin);
sampleCounter += 2;
int N = sampleCounter - lastBeatTime;

detectSetHighLow();

if (N > 250) {
if ( (Signal > thresh) && (Pulse == false) && (N > (IBI / 5) * 3) )
pulseDetected();
}

if (Signal < thresh && Pulse == true) {
Pulse = false;
amp = P - T;
thresh = amp / 2 + T;
P = thresh;
T = thresh;
}

if (N > 2500) {
thresh = 512;
P = 512;
T = 512;
lastBeatTime = sampleCounter;
firstBeat = true;
secondBeat = true;
}

}

void detectSetHighLow() {

if (Signal < thresh && N > (IBI / 5) * 3) {
if (Signal < T) {
T = Signal;
}
}

if (Signal > thresh && Signal > P) {
P = Signal;
}

}

void pulseDetected() {
Pulse = true;
IBI = sampleCounter - lastBeatTime;
lastBeatTime = sampleCounter;

if (firstBeat) {
firstBeat = false;
return;
}
if (secondBeat) {
secondBeat = false;
for (int i = 0; i <= 9; i++) {
rate[i] = IBI;
}
}

word runningTotal = 0;

for (int i = 0; i <= 8; i++) {
rate[i] = rate[i + 1];
runningTotal += rate[i];
}

rate[9] = IBI;
runningTotal += rate[9];
runningTotal /= 10;
BPM = 60000 / runningTotal;
Serial.println(BPM);
QS = true;

}
CAYENNE_OUT_DEFAULT()
{
Cayenne.virtualWrite(0, BPM);
}

is the issue solved now?

After you added the
Serial.println(BPM);
i also I did not get any reading on cayenne it just give me 0.00


Note : iam using Nodemcu 1.0

That means you are not getting the data from the sensor. Can you add #define CAYENNE_DEBUG at the very top and see what you are getting in the serial monitor.

Ok i well try

@shramik_salgaonkar
I did note get any thing on the Serial monitor

check the baud rate in your code if it 115200. if not then change it to the baud rate used.

@shramik_salgaonkar
i started to get some reading on serial monitor


but i steel get 0 reading on the platform

As a said you are not getting any reading from the sensor. In fact the pulseDetected function is never called. Can you first try the code alone without cayenne code and see if you can get sensor data.

@shramik_salgaonkar
which part of the code do you mean

@shramik_salgaonkar
I am sorry put can you send me the code without cayenne code because i don’t have much experiences in coding.

sorry, i don’t have one with me. From where did you get the above code and also you can do a google search to get the code to read BPM.

@shramik_salgaonkar
i get the code from you. you boast it on the community in Jul '19
this is the link to the page
https://community.mydevices.com/t/getting-bpm-using-wemos-d1/12756/4

The github directory has been discontinued. Can you try this library to get BPM https://github.com/WorldFamousElectronics/PulseSensorPlayground