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

Problem with push notifications (on RPi - WiringPi)


#1

hey guys,
I have problems with the push notifications example sketch. I cloned the newest github library and build the library on my raspberry pi. I wrote this simple program to send me a notification when the Blynk program gets started on my raspberry pi.

#define BLYNK_PRINT stdout

#ifdef RASPBERRY
 #include <BlynkApiWiringPi.h>
#else
 #include <BlynkApiLinux.h>
#endif
#include <BlynkSocket.h>
#include <BlynkOptionsParser.h>

static BlynkTransportSocket _blynkTransport;
BlynkSocket Blynk(_blynkTransport);
#include <BlynkWidgets.h>



void setup()
{
  delay(100);
  // Notify immediately on startup
  Blynk.notify("Device started!!");
}

void loop()
{
  Blynk.run();
}

int main(int argc, char* argv[])
{
  const char *auth, *serv;
  uint16_t port;
  parse_options(argc, argv, auth, serv, port);

  Blynk.begin(auth, serv, port);

  setup();
  while(true) {
    loop();
  }

  return 0;
}

The Blynk program starts succesfully:

[1]
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.5.0-beta on Linux

[106] Connecting to blynk-cloud.com:8442
[146] Ready (ping: 9ms).

but after that nothing happens, I don’t get any notifications, but my raspberry pi is listed as “online”.
After a few seconds my raspberry pi is listed as “offline”.
Could you please help me?


#2

Please read the welcome message and format your pasted code so it’s human readable. People tend to be more helpful then :wink:

Edit: Hey @Gunner, this is YOUR job :smiley: I just want to see the code :stuck_out_tongue:


#3

Cinderfella, Cinderfella, all I hear is Cinderfella… :stuck_out_tongue:


#4

I now switched from 0.5.0-beta to 0.4.10, because this version is listed as stable but unfortunately the issue still exist :confused:


#5

But… What’s it supposed to do? I don’t have an RPi myself, but your code kinda looks like the “system default” sketch which does … nothing!

Check out https://examples.blynk.cc/


#6

yes it is the default sketch, but I want to first test the push notification command.
I added Blynk.notify in the setup function, but the notification never reaches my smartphone (Android).
Interestingly I get a message whenever I close the Blynk sketch. (Offline warning)
I tried the notification interval sketch but unfortunately the sketch doesn’t compile:

main.cpp: In function ‘void notifyUptime()’:
main.cpp:25:37: error: ‘String’ was not declared in this scope
   Blynk.notify(String("Running for ") + uptime + " minutes.");
                                     ^
Makefile:70: recipe for target 'main.o' failed
make: *** [main.o] Error 1

#7

Paste your code


#8

Copy and Paste from the Blynk Example Browser

/*************************************************************
  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************

  Simple push notification example

  App project setup:
    Push widget

  Connect a button to pin 2 and GND...
  Pressing this button will also push a message! ;)
 *************************************************************/

/* Comment this out to disable prints and save space */
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT stdout

#ifdef RASPBERRY
 #include <BlynkApiWiringPi.h>
#else
 #include <BlynkApiLinux.h>
#endif
#include <BlynkSocket.h>
#include <BlynkOptionsParser.h>

static BlynkTransportSocket _blynkTransport;
BlynkSocket Blynk(_blynkTransport);
#include <BlynkWidgets.h>

BlynkTimer timer;

void notifyUptime()
{
  long uptime = millis() / 60000L;

  // Actually send the message.
  // Note:
  //   We allow 1 notification per 15 seconds for now.
  Blynk.notify(String("Running for ") + uptime + " minutes.");
}

void setup()
{
  // Notify immediately on startup
  Blynk.notify("Device started");

  // Setup a function to be called every minute
  timer.setInterval(60000L, notifyUptime);
}

void loop()
{
  Blynk.run();
  timer.run();
}

int main(int argc, char* argv[])
{
  const char *auth, *serv;
  uint16_t port;
  parse_options(argc, argv, auth, serv, port);

  Blynk.begin(auth, serv, port);

  setup();
  while(true) {
    loop();
  }

  return 0;
}
```cpp

Help implementing sketch into (C++) code on Raspberry Pi
#9

Have you installed the latest App version? there were some prior (and heavily mentioned in this forum) notification issues that have since been resolved.