I’m working on a project that requires a value to be taken from sensor connected with arduino, then sent the value to NodeMCU through Serial , then the same value again to the Blynk app. But I’m having problem as it didnt send the same value from arduino to Blynk. From arduino to NodeMCU, I managed to send the same value, but it seems that NodeMCU cannot sample the same received value to be resend to Blynk. Below is the code which I uploaded on NodeMCU, the code on Arduino is not uploaded since I think it’s not wrong. I felt like I’m missing something in the NodeMCU code. Please help me solve this issue.
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "19db9b6385ca4c9e818e82f5576379be";
int myBPM;
char ssid[] = "Lolol";
char pass[] = "popopopo";
BlynkTimer timer;
void myTimerEvent()
{
while (Serial.available() > 0) {
sensorBPM(); }
Blynk.notify("BPM is HIGH!");
}
void setup()
{
Serial.begin(115200);
while (!Serial) {
;
}
Blynk.begin(auth, ssid, pass);
timer.setInterval(1000L, myTimerEvent);
}
void loop()
{
Blynk.run();
timer.run();
}
void sensorBPM()
{
myBPM = Serial.read();
Serial.println(myBPM);
Blynk.virtualWrite(V5,myBPM);
}