Using C++ on a Raspberry Pi with Blynk

@Gunner when you tested the C++ stuff on your Pi was it a Pi 3?

Wondered if you could test something for me if you have a Pi 3. Does the gpio pin still go high and low if you remove the button tied to the digital pin i.e. control just by the button tied to a virtual pin?

Works OK for my Pi Zero’s but not for @schmersgahoven’s Pi 3.

No fansnazzy new stuff for me, I am afraid… My RPi is one of the originals (RPi Model B ver 2.0). But so far all GPIO’s I have tested do what they should with either Virtual or Physical buttons in both C++ and Javascript clients.

1 Like

I’m about to order my first Pi or clone.

Should I just go for the Pi 3 and test this?

@Jamin I prefer the size and price of the Zero but it depends what plans you have for the Pi.

Plans = tinker

Well the 3 would be good for me as I’m terrible with a soldering iron as the Zero’s don’t have any headers.
For the Zero as a Blynk server it doesn’t need any headers but when you move on to client stuff it generally needs headers.

I have thought about buying some of these
With the jig you basically smack the headers on to the Zero with a hammer.

SimpleTimer should now be available, from the Master branch, for the Pi as @vshymanskyy pushed an update a few days ago. Intervals should be set at > 10ms.


This tutorial should be included as a reference in the help center raspberry pi setup guide.

1 Like

@Costas, can I publish (a modified version of) your post to ?

Of course you can @vshymanskyy, please feel free to make any modifications that you think will help other Blynkers.

@costas can you give me an example how the now updated timer under C should work? I see that the timer is called in the loop:; but I did not get how to define interval like for simple timer for Arduino with: timer.setInterval(1000L, blinkLedWidget); under void setup.

THX and Best

@schmersgahoven are you familiar with SimpleTimer “for Arduino”?

Have you created the blinkLedWidget() function?

Further details, if you need them, and

@costas maybe not 100% familar but I thougt reading enough to come along with easy (simple) :slight_smile: timer functions but it seems that not. I read your hints and thought I am doing right. I do not used blinkLedWidget() function but tried another simple code just a modification of yours from the top.
But the function will not repeat writing uptime to V0

// Mein Timer
//#define BLYNK_DEBUG
#define BLYNK_PRINT stdout
  #include <BlynkApiWiringPi.h>
  #include <BlynkApiLinux.h>
#include <BlynkSocket.h>
#include <BlynkOptionsParser.h>

static BlynkTransportSocket _blynkTransport;
BlynkSocket Blynk(_blynkTransport);

#include <BlynkWidgets.h>

SimpleTimer timer;

unsigned int uptime; 

  void repeatMe()
	uptime = (millis() / 1000);
  	Blynk.virtualWrite(V0, uptime);

  void setup()
	timer.setInterval(1000, repeatMe);

  void loop()

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);
    while(true) {
    return 0;

@schmersgahoven have you added a digital pin in your project as I believe that you established the virtual pins are only updated if they are tied to digital pins?

@costas I do not think that this is the reason. Due to this I tried to repeat the repeateMe() by using millis() but here I came into trouble with delayed reaction of app and offline erros. So I deleted my code and go back to the beginning by putting your code from above in the main.cpp and tried this. And I have the same issue. If I push a button it displays and offline message and Uptime is sconds are counted wih delay of 4-5 seconds. I think this is caused due to flood error because terminl gives me the trouble message. But the problems appears with new update. I do not have them before with your example from above. And my try with simpleTimer from my last poste is not working as well.
Can you mayb verify that your code from above is not working anymore with update of library or is it just a problem of my set up?

@schmersgahoven try the newly released 0.4.7 version that replaces SimpleTimer with BlynkTimer.

1 Like

I have used the code given above but get the following message

[5001] Connecting to
[5791] Ready (ping: 273ms).
[6686] Trouble detected:
[10792] Connecting to
[11495] Ready (ping: 339ms).
^X[12366] Trouble detected:

please help me out


I’m still having a ton of trouble getting the C++ example working

I’ve done everything but when I do ./ raspberry I get

In file included from main.cpp:45:0:
./BlynkApiWiringPi.h: In instantiation of ‘void BlynkApi<Proto>::processCmd(const void*, size_t) [with Proto = BlynkProtocol<BlynkTransportSocket>; size_t = unsigned int]’:
../src/Blynk/BlynkProtocol.h:349:9:   required from ‘bool BlynkProtocol<Transp>::processInput() [with Transp = BlynkTransportSocket]’
../src/Blynk/BlynkProtocol.h:166:31:   required from ‘bool BlynkProtocol<Transp>::run(bool) [with Transp = BlynkTransportSocket]’
main.cpp:97:13:   required from here
./BlynkApiWiringPi.h:177:9: error: ‘class BlynkProtocol<BlynkTransportSocket>’ has no member named ‘currentMsgId’
         static_cast<Proto*>(this)->sendCmd(BLYNK_CMD_RESPONSE, static_cast<Proto*>(this)->currentMsgId, NULL, BLYNK_ILLEGAL_COMMAND);
Makefile:70: recipe for target 'main.o' failed

Yeagh, sorry i’ll fix that soon

HI ,

Do you have a timeline for this?

Do you know what it is so I can maybe look at the problem too?

Is it looking for a function that hasn’t yet been implemented? or simply a case of me not including the right include files