Creating Local Blynk Servers For Noobs

Hello! I’m working with sigilwig33 on our Blynk server. Great news! Roffey’s comment really helped us nail the issue! The local server works beautifully, just as I had imagined.

You’re right, there were a lot of variables to tweak. Here’s what we did, from beginning to end, so fellow noobs looking to set up a local Blynk server with a raspberry pi can succeed! Community, please Use and edit what I say here for increased accuracy!


  1. purchase raspberry pi and an SD card for it. Use standard setup procedure for the rpi, formatting the card, installing raspbian, etc…

  2. obtain other equipment: microcontroller (arduino uno, in my case), router (we bought a cheap D-Link WBR-1310), an Ethernet shield for arduino to connect to the router (wifi shields also work, I believe), and 2 short Ethernet cables.

2.1) make the electrical connections. Give the router, microcontroller, and rpi power. The router will be our “bridge” because it facilitates the conversations the microcontroller, Pi (server), and Blynk app have with each other. So, the microcontroller has to talk with the router: either connect a wifi shield to the router’s wifi, or plug in an Ethernet cable. The same story with the Rpi, connect it to the router over either Ethernet or wireless. Lastly, your Blynk app needs to be a part of the conversation, so connect the smartphone/tablet to the wireless network (or be that one guy who hacked an Ethernet jack into a smartphone).

  1. follow the Blynk instructions for setting up a server on rpi (included below, layman’s terms overlayed) https://github.com/blynkkk/blynk-server

3.1) Login to Raspberry Pi (we plugged the pi into an old monitor and used keyboard and mouse)

3.2) Install java 8 by launching the Terminal and typing:
sudo apt-get install oracle-java8-jdk

3.3) Ensure sure you are using Java 8 by typing:
java -version
And the Output should contain: java version "1.8.0_40"

3.4) Download Blynk server jar file in the Terminal (or manually copy it to raspberry via ssh and scp command) :
wget "https://github.com/blynkkk/blynk-server/releases/download/v0.11.4/server-0.11.4.jar"

3.5) Run the server! Type java -jar server-0.11.4.jar -dataFolder /home/pi/Blynk
As output you will see something like that :
Blynk Server successfully started. All server output is stored in current folder in 'logs/blynk.log' file.
The server will run on the defaults ‘hardware port 8442’ and ‘application port 8443’ (SSL port). We’ll be using the hardware port in the microcontroller code, and the application port in the Blynk mobile app. These port values can be changed by following the Advanced Local Server Setup instructions here https://github.com/blynkkk/blynk-server

3.6) Optionally enable server start when the rpi boots up.
find and open the file entitled “rc.local” within /home/pi/etc/init.d/
Then add the linejava -jar /home/pi/server-0.11.4.jar -dataFolder /home/pi/Blynk &
(Or in case above approach doesn’t work for you, executecrontab -e add the following line @reboot java -jar /home/pi/server-0.11.4.jar -dataFolder /home/pi/Blynk &)
Save and close the file.

To test if the server successfully turns on upon boot up, I restarted the Pi (Terminal: sudo reboot") and in theory the Pi should launch the server automatically. To test, I tried enabling the server manually with code ``. If it was already running, it would return an error because it is already running. If it enables without question, the server was not likely successfully enabled by the Pi automatically.

  1. Give the Pi a static IP. Every computer equipped with dynamic Internet Protocol addresses (basically an ID badge to show to other computers on the network). For security, the Pi is equipped with a Dynamic IP, meaning it changes every time you restart the Pi. This isn’t good because if the IP keeps changing, we’ll have to keep both our Blynk app and microcontroller program up to date with the latest IP. That means reprogramming the robot every time you start it up. Not fun! But that is why there are Static IPs. These don’t change when the Pi reboots, so we only have to program it in once and we’ll be done.

4.1) follow this beautiful tutorial! http://www.modmypi.com/blog/tutorial-how-to-give-your-raspberry-pi-a-static-ip-address

NOTE: to test my pi’s gateway, I had to use the sudo command sudo ping xxx.xxx.xxx.xxx Sudo, essentially, just says to the Pi “do this command and don’t ask any questions because I’m not giving you any other choice”

4.2) Time to test the IP. First, take note of the IP Address as-is. 192.168.xxx.xxx. You can use the shortcut hostname -I (note, the “I” must be capitalized) to view the IP. Then reboot the Pi, and check the IP again. Hopefully the IP will stay the same.

NOTE: if you found that your IP still doesn’t work even after following the tutorial completely, try doing this. Re-add iface eth0 inet dhcp totes Interfaces file right next to iface eth0 inet static. Test again.

  1. The moment of truth. Time to test connecting your Blynk app to the server. Firstly, connect your smartphone to your server’s router. On the log-in page, hit the server button below the big green log in button. Knock the switch toward “custom.” Enter in your Rpi’s IP Address we determined from the Pi Terminal code hostname -I (note, the “I” must be capitalized). Use the Server’s application port (see step 3.5). Hit OK, then enter in your log in information, and log in! There you go!

  2. Your phone and server are talking now! That lets us move on: let’s add the microcontroller to the conversation. Since we have our smartphone connected to the server, we now can generate Auth Codes for our Blynk project boards. Go ahead and create a new project board, and send yourself the Auth Code.

6.1) I’m sure the process varies from board-to-board. With my arduino uno with Ethernet shield, all I had to do was open the Blynk example Sketch, plug in the Raspberry Pi’s IP, hardware port (See step 3.5), and project Auth Code. If those numbers are right, and all the electrical connections are there (see step 2.1), you should have blynking lights!

–Troubleshooting–
So, it’s not working yet, eh?

If you get a “Server can’t talk now” error trying to log into the Blynk app, try these out:

A) Quadruple check that your Pi IP doesn’t change when you reboot.
NOTE: In my experience, even a static IP varies between routers. So make sure you are using the IP address associated with the router you are using. //Can someone in the community help explain this?

B) Ensure the smartphone is connected to the correct wifi network associated with the Pi. Try again now.

C) Let it cook: a watched pot never boils. It seems that the server needs some time to collect its thoughts before it’s ready to connect to your phone. So power up the machine, stand up, stretch, walk out of the room, grab a snack, call your mom, then try logging in.

If you get an error associated with incorrect email/password, give these a shot:

D) in the current time, there seems to be some silliness with some of our Blynk accounts. When you use a local server instead of the Blynk cloud, it may not recognize your previous Blynk account. So, simply, try creating a new account. You may be surprised as we were, because ours connected to our server and arduino right away with our new account.

BE AWARE: But the funny thing is that I have at least 2 distinct Blynk accounts. When I log into my account though the Blynk Cloud, I see my old projects. When I log into my local server, I see my new projects (I used the same username and password for both). Maybe I have an account for each Blynk server IPs or something. Hopefully this can be resolved by the omnipotent Blynkineers.


I really hope this helps clear up some of the confusion for newcomers like me. Thanks so much Roffey, Dmitriy, and shining01!

Happy Blynking!

-djearle98

(on the bright side, I know like 7 Rpi Terminal codes now)

(fine, I know 6)

6 Likes