Raspberry Pi Problems, can read digital but cannot create virtual pins

I can read and control pins using the application on the phone. For example, I can blink and LED. But I cannot create virtual pins in my C code on the Pi. That is, I want the LED display to show on the phone as a result of the data created in my C code that toggles a virtual pin on the Pi.

#include "wiringPi.h"

#include "Blynk/BlynkApi.h"

int x=0;

int main (void)
{
wiringPiSetup () ;
//pinMode (11, INPUT) ;
for (;:wink:
{

Blynk.virtualWrite (1, HIGH) ; delay (500) ;
Blynk.virutalWrite (1, LOW) ; delay (500) ;
}
return 0 ;
}

When I try to compile, I get an error that Blynk is not declared in this scope.

Please help, perhaps with a sample.
What I want to do is set a virtiual pin High on the Pi, and then have it display an LED on the Blynk Phone app. THANKS.

@neoteric, I hope you solved your problem :wink:

No, I did not resolve it.
I just can’t seem to get it to work.

Anybody have an idea?

The code I see looks wrong. I don’t see the “Blynk.run();” call + many other things.

Please make sure you’re running unmodified main.cpp file and library files to see if it works.
You can find instructions how to build Blynk on Raspberry here: https://github.com/blynkkk/blynk-library/blob/master/docs/Platforms.md#linux-raspberry-pi
If you have problems, please provide detailed information (commands, program output, etc)

Thanks!

did you read my issue? *I can run Blynk on the Pi. as described in the instructions. However, what I want to do is write a c program that sets a virtual pin, and display it on my phone.

  1. Cannot figure out simple code to have the pi set a value on a virtual pin, and have it display in the blynk app on the phone.
  2. How long would it take you to point me to an example of that, or show a line of code that does that.

PS, Just a little help please. I have put two days into this and am an not a complete newbie

PS, that above post does not come off as nice as I intended. I did not intend it to sound mean.

Thanks.

OK FOr those that need to know how, here is an example that sets virtual pin 5 to 255!

/**
 * @file       main.cpp
 * @author     Volodymyr Shymanskyy
 * @license    This project is released under the MIT License (MIT)
 * @copyright  Copyright (c) 2015 Volodymyr Shymanskyy
 * @date       Mar 2015
 * @brief
 */

//#define BLYNK_DEBUG
#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);

BLYNK_WRITE(1)
{
  BLYNK_LOG("Got a value: %s", param[0].asStr());
}

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

    Blynk.begin(auth, serv, port);

    while(true) {
        Blynk.virtualWrite(5, 255);
        Blynk.run();
    }

    return 0;
}

Just a question: My rpi is working with blynk but I don’t see how to control it. Do I have to make a new script or something? I can run the app on the phone and the server on the pi and it just sits there as if waiting for something.

He all,

We understand that coding in C++ for Raspberry pi may be not the best idea, so we a already thinking about providing a Python library… I’m personally very interested in this.

What do you think?

3 Likes

I would love a Python library :slight_smile:

  1. Backup the blynk-libraries folder.
  2. Go into the linux folder in the blynk libraryies folder.
  3. Modify main.cpp, as I did above. In the simple example above, I am setting a virtual pin to a value.
  4. type “make clean all target=raspberry” into the command line to remake it.

Use the examples, that are written for Arduino, to guide you.
As you can tell from my earlier posts, this is not how I thought it worked originally.

3 Likes

I would very much appreciate a library for python

thanks for the steps, i followed them and it is working.
would you please explain how to use the examples written for arduino ? i want to use the lcd widget or i want to use LDR to show some value in the app?

thank you.

Hi all, we now have a JavaScript library, which should make creating virtual pins on Raspberry really simple.
Just check this instructable:

Hi,
I’m using raspberry pi for my project. Is there a way where I can send data through I2C from virtual pin. I mean is there a particular file in blynk library for a particular virtual pin/ a file where I can edit all virtual pins ? So that I need not do anything apart from concentrating on my virtual pin.
If not, then how to call a virtual pin to do a particular task be it a internal software task or hardware one.

It can be done only via Node.js Blynk library

Here are some examples: