Hi Blynkers I have done weeks of reading and trying but I still can’t get through this. So basically I am sending my sensor data, from Arduino UNO to NodeMCU. Then in NodeMCU, I can show the readings through serial monitor,which shows the transfer is successful. But then I can’t send the same data that the serial monitor in NodeMCU shows to my Blynk app. If I assign the myBPM to any values in NodeMCU coding, I can send it. But I want to send the same myBPM data received from the Arduino, not just any random self-written numbers. Here are the codes:-
(code for Arduino UNO)
#include <SoftwareSerial.h>
#include<SPI.h>
#define USE_ARDUINO_INTERRUPTS true // Set-up low-level interrupts for most acurate BPM math.
#include <PulseSensorPlayground.h> // Includes the PulseSensorPlayground Library.
#define REC A1 // pin A1 is used for recording
#define recordTime 7000 // recording time 3 seconds
const int PulseWire = 0; // PulseSensor PURPLE WIRE connected to ANALOG PIN 0
const int LED13 = 13; // The on-board Arduino LED, close to PIN 13.
int Threshold = 550;
PulseSensorPlayground pulseSensor;
SoftwareSerial BTserial(2, 3); // RX |
String str;
void setup(){
Serial.begin(115200);
BTserial.begin(115200);
Serial.println("Interfacing arduino with nodemcu");
pulseSensor.analogInput(PulseWire);
pulseSensor.blinkOnPulse(LED13); //auto-magically blink Arduino's LED with heartbeat.
pulseSensor.setThreshold(Threshold);
pinMode(REC,INPUT);
if (pulseSensor.begin()) {
Serial.println("We created a pulseSensor Object !"); //This prints one time at Arduino power-up, or on Arduino reset.
}
delay(1000);
}
void loop()
{
int myBPM = pulseSensor.getBeatsPerMinute();
if(pulseSensor.sawStartOfBeat()) { // Constantly test to see if "a beat happened".
Serial.println("♥ A HeartBeat Happened ! "); // If test is "true", print a message "a heartbeat happened".
Serial.print("BPM: "); // Print phrase "BPM: "
Serial.println(myBPM); // Print the value inside of myBPM.
if(myBPM >= 150){
Serial.println("WARNING!BPM IS HIGH"); // dlm if ni ayam
delay(5000);
if(myBPM >= 150){
Serial.println("WARNING!BPM IS HIGH"); // dlm if ni ayam
digitalWrite(REC, HIGH);
delay(recordTime);
digitalWrite(REC, LOW);
Serial.println("BPM is constantly HIGH!");
}
}
}
BTserial.println(myBPM);
delay(1000);
}
(code for NODEMCU)
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "19db9b6385ca4c9e818e82f55763787u";
int myBPM;
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Phuhu";
char pass[] = "12345678";
BlynkTimer timer;
// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void myTimerEvent()
{
if (Serial.available()) {
(Serial.write(Serial.read()));
Serial.print(myBPM);
}
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V5,myBPM);
Blynk.notify("BPM is HIGH!");
}
void setup()
{
// Debug console
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
timer.setInterval(1000L, myTimerEvent);
}
void loop()
{
Blynk.run();
timer.run();
}