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

Blynk RPI 3 Model B+ connect to local server

rpi
localserver
python

#1

Hello,

I have a blynk server already installed and working on my raspberry pi and I’d like to make the server also a client. For example the Raspberry pi is the server and the same raspberry pi is a client… I have installed node global blynk client on the RPI but it works only with the cloud services how can I change it?
Thanks a lot


#2

I have a seperate Server… but in testing dual server/client use, I simply ran any client script as normal (NodeJS or Python), but point the IP to 'itself" (that of the RPi the client is running on).

I do not use Node-Red, so unsure if that is what you are talking about?


#3

I don’t know about that… also I haven’t edited or viewed any python or NodeJS file. Where can I find it and how can I modify it so it connects to a local server instead of the cloud.
Thanks for replying!


#4

Here is the NodeJS method…


#5

And the Python method…

I believe there is also an in-script method, I recently saw someone use it… but I haven’t found it yet…

EDIT - OK this might work… untested (unneeded as I have already edited my Python library).

    import BlynkLib

    BLYNK_AUTH = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'
    blynk = BlynkLib.Blynk(BLYNK_AUTH, '192.xxx.x.xx', 8080)

RPI server, (same) RPI Client random errors (Using Blynk Python)
#6

I am more comfortable with the python method…
from the link that you gave me I searched for the BlynkLyb.py file and found it also I’ve located the class blynk and changed the ip to my locals server ip but I can not find were can I use this

also in class blynk the port is set to none in the init should I set it in 9443 or something?


#7

For python, I gave you two methods…

The 1st was a Blynkib.py change and affects all your Blynk python scripts.

The 2nd was a in-script only change (untested by me), thus you could choose between Cloud (add nothing and use the default library setting) or add the extra IP & port you wanted for a Local Server

All script (device) ports are 8080


#8

I think is easer with the first…
in blynkib.py I changed the ip to my local one but when i run the command blynk-client auth key it try’s to connect in the blynk-cloud…

do i have to change anything else?


#9

I found it tricky to find the correct location of the Blynklib.py file that was used… you might want to test the 2nd method… if it works, then you changed the wrong file.


#10

also forgot to say that i couldn’t find were is this…


#11

That would be the first part of your actual python script (the client) that you need to write… :stuck_out_tongue:

Check out the example scripts in the Blynk python library


#12

oh my god is so confusing ………… what is the default example just the button and blink the led ….


#13

Also I have to say I am so sorry for the stupid questions I am a Arduino fanboy and I have only 1 month experience with RPI…


#14

Welcome to the dark side of Blynk… both NodeJS and Python are a bit basic and not nearly as popular as ESP/Arduino & C++

They are Beta and Alpha levels respectively… one could say, “expert” levels… not that I am expert in either myself :wink:

No actual Blink LED example, but here are some to choose from. Located in the same github site that you might have installed the Library from…


#15

I think I found how you will understand what i am trying to find.
in Arduino there are some .ino files that are like this:

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

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

// Your WiFi credentials.
// Set password to “” for open networks.
char ssid[] = “YourNetworkName”;
char pass[] = “YourPassword”;

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

Blynk.begin(auth, ssid, pass);
}

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

Here if you need to connect to a local server you change the Blynk.begin section to this:

Blynk.begin(auth, ssid, pass, IPAddress(192,,,*), 8080);

and boom you have done it!

is there something similar for RPI python ? i just need to connect the pi with the local server i don’t need virtual write or anything else… the examples are to advanced for my situation


#16

After research I found this command and tried to run it but got an error in the terminal: ./blynk command not found
is this the answer to my problems or its irrelevant if it is what do I have to install so it could run ?


#17

This prior discussion is NOT about WiringPi (a C++ style of programming for the RPi… and one I gave up trying to use over a year ago).

I thought you said you were more comfortable with Python? I use Python 2 (IDLE) on the RPi to program Python sketches… But if you do not know how to create, edit and run Python on an RPi then you need to Google for tutorials… that level of instruction is not what this forum is about.

Or you can switch gears altogether and go the WiringPi route. It is similar C++ language but different method of editing and compiling than programming in Arduino IDE for Arduino/ESP… but I can’t help you with it.

PS, I am unsure of the disclamer…

:point_up:We don’t support BLE of Raspberry Pi 3 (yet)

As I use both Python and NodeJS on a RPi3 with Blynk… seems to work just fine.


#18

I didn’t know that it was WiringPi im more comfortable with Python!
Ok lets just say that the sync example from the example’s folder is the right for me I have edited with the

to use it Do I just run it? (I mean run the script in terminal or smth) cause when I do I an error saying that the BlynkLib module cannot be found…


#19

@Gunner I found the files and found a solution for my problem but I have an other one…
I try to run it and it works (!) but there is a problem I run it from this command:

python2.7 /home/pi/blynk-library-python/examples/02_virtual_read.py

but I don’t think that its the correct way because when I try to autorun it from the rc.local file I get this error:

ImportError: No module named BlynkLib

Also I get this error when I run the script like this:

sudo python2.7 /home/pi/blynk-library-python/examples/02_virtual_read.py

Is this problem irrelevant with the forum ?:roll_eyes:


#20

Simply means the system? path doesn’t include direction to find that library. Now as far as I know (still learning linux) the install should have set the path.

But you say you did get something working… how so? What program and/or commands?