BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Arduino Bluetooth HC-05 with pushbutton notification


#1

Hello all,

Newbie Warning

I am trying to use my Arduino nano + HC-05 to send a push notification to my android when I push a physical button, I have done a lot of trying to splice different codes together with zero luck, any guidance would be greatly appreciated.

#define BLYNK_PRINT Serial
#define BLYNK_USE_DIRECT_CONNECT
#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(2, 3); // RX, TX
int button = 13;
#define BLYNK_PRINT DebugSerial
#include <BlynkSimpleSerialBLE.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxx";

void setup()
{
  // Debug console
  Serial.begin(9600);
  
  Blynk.begin(Serial, auth);

  DebugSerial.begin(9600);

  DebugSerial.println("Waiting for connections...");

  // Setup notification button on pin 13
  pinMode(13, INPUT_PULLUP);
  // Attach pin 2 interrupt to our handler
  attachInterrupt(digitalPinToInterrupt(13), notifyOnButtonPress, CHANGE);
}

void notifyOnButtonPress()
{
  // Invert state, since button is "Active LOW"
  if(digitalRead(button) == HIGH){
    Serial.println("Button is pressed.");

    // Note:
    //   We allow 1 notification per 15 seconds for now.
    Blynk.notify("Yaaay... button is pressed!");
  }
}

void loop()
{
    if(digitalRead(button) == HIGH){
    Serial.println("Button is pressed.");

    // Note:
    //   We allow 1 notification per 15 seconds for now.
    Blynk.notify("Yaaay... button is pressed!");
  Blynk.run();
    }
}

#2

I believe Push notifications require the device itself to have internet access to the server… you don’t get that with the Bluetooth link… thus no notifications.

You will need to use WiFi adapter instead of BT

PS as per the instructions in the topic window, that you needed to erase to post this :wink: … when pasting code here, please follow the required formatting instructions… I edited your post to correct it.

Blynk - FTFC


#3

Thank you Gunner, I guess I will need to figure out a new way to do this without blynk unfortunately, my project must use bluetooth.