Where do I insert Auth tokens in Blynk local server, raspi?

First I set up RasPi3 to use the Blynk cloud, That was a breeze and all worked great.
Now I decided to install the server and give it a try. The server is running but I can not figure out where to put my Auth token so the app will connect with the server. I have read the docs & google for hours and just cant figure it out.

You have to create a new project (after logging into the app using the new server address not the Blynk cloud) and your server will create the new Blynk auth code for you.

Then you recreate your project bit by bit, or work out how to Clone it…

You put the Auth code in the same place you put it when you got it working.
You will also need to point to your local server IP.

Blynk.begin(auth, ssid, pass, IPAddress(192, 168, 1, 2)); for example is my local server

@Shane_Pennington in your sketches you might want to add another variable as:

char server[] = "blynk-cloud.com"; // or xxx.xxx.xxx.xxx or abc.com

and then

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

You could do the same for the port number but I wouldn’t recommend changing from the default port number unless you know what you are doing.

Hi Dave, I have got that far but I cant figure out where to put the new Auth token that was generated.

Hi Jamin, So your saying to run
pi@raspi:~/blynk-library/linux $ sudo ./blynk --token=cd35b************************
like I was trying to connect to cloud only insert new token and redirect to local server?

I tried this:
Auth=new auth token
ssid=network name
pass=network pass
server=local Blynk server

pi@raspi:~ $ Blynk.begin(cd***************************************db, pen************, 3*******, IPAddress(192, 168, 1, ***)); -bash: syntax error near unexpected token cd***************************************db,'`

@Shane_Pennington token are specific to each server and even down to the particular server allocated to you when you access the Blynk cloud server. Different parts of the world have different IP addresses allocated to blynk-cloud.com. So your local server has different token to the cloud server.

So if you haven’t already done so you will create an account on your Pi from your Smartphone, obtain token and use in in the sudo … command.

Hi Costas, Thank you for the clarification. I believe I had an understanding of most of that except how to use sudo command to actually apply the new Auth token that the new Blynk server account on iPhone gave me. Is there an explanation of this in the docs? I have looked and looked for it but cant seem to find or maybe understand where it is. Thank you Sir.

@Shane_Pennington if you are using the Pi as a local server and also has the MCU you can ignore much of what is included in this thread. The references to Blynk.begin() etc are for Arduino type MCU’s including ESP’s.

Unix style MCU’s like the Pi use a totally different notation i.e. java like your post of:

sudo ./blynk --token=cd35b************************

The format for a local server, where xxx.xxx.xxx.xxx is the IP of your local server is:

sudo ./blynk --server=xxx.xxx.xxx.xxx --token=xxxxxxxx

There is also a port flag of --port=xxxx but it will default to 8442.

1 Like

THAT DID IT! Thank you Sir!

I feel kinda stupid that was pretty simple. Can you tell me, is that stated somewhere in the docs? That was exactly what I was looking for.

So from what I understand now, there are 2 commands that need to be executed before the server is completely functional.

#1 pi@raspi:~ $ java -jar server-0.21.1.jar -dataFolder /home/pi/Blynk
#2 pi@raspi:~/blynk-library/linux $ sudo ./blynk --server=xxx.xxx.xxx.xxx --token=xxxxxxxxxx

1 Like

@Shane_Pennington yes the first is to start the java server on the Pi and the second is “to connect your Pi to the Pi server”. Sounds weird connecting the Pi to the Pi but it also includes the Smartphone app interface.

@Dmitriy I have never seen –server or –port documented for the Pi. Does it appear anywhere?

1 Like

4 not 3 :slight_smile:

Yes sir, I forgot a group. Edited above.

Would putting the two commands in pi@raspi:~ $ crontab -e be the correct way to auto run commands at boot?

I find crontab much easier to use than the “official” boot up methods, so yes.

You should create a script and run it via crontab as there are technically a few other commands you need to issue relating to port redirects as per the docs.

1 Like

Thank you again! I will be looking into that tonight.

Me too :slight_smile:. @vshymanskyy

This part have not written in docs right? @Costas

Right @elanozturk but it’s only needed if you are using the Pi as a server AND as your iOT connected device.

Oh, wow… I wasn’t aware one could double up a server like that, good use of a singe resource. I just wish the RPI was as 'easy" as Arduino to program. I barely figured out how to install server on a RPI and a Linux netbook… programming RPI GPIO is beyond me, as of yet :slight_smile: