Autostart Local Server Raspberry Pi 3

Hi,

I have a Raspberry Pi 3 Model B working well with local Blynk Server installed. The Pi runs with latest Rasbian Stretch Lite 2017-11-29 Kernel version:4.9.

I have an Arduino Etherten (Uno) connected by ethernet to our local network operating some relays switched by Blynk for Android on my mobile.

Unfortunately whenever the Pi iloses power I cannot get the Blynk local server file to autostart and I have to manually run “java -jar server-0.29.5-java8.jar -dataFolder /home/pi/Blynk”

To try enable server auto restart I have followed the suggested GitHub page (https://github.com/blynkkk/blynk-server#blynk-server) which advises
"find /etc/rc.local file and add:

java -jar /home/pi/server-0.29.5.jar -dataFolder /home/pi/Blynk &

I have also tried executing

crontab -e
& added the following line

@reboot java -jar /home/pi/server-0.29.5.jar -dataFolder /home/pi/Blynk &

Again no success. I have looked on many posts but I am still lost.

My Blynk sketch on my Arduino is as follows:

#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>


char auth[] = "9aef232fd4574ef7872fbaa6be3372c3";

byte mac[] = {
0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02
};
IPAddress ip(10, 0, 1, 184);

void setup()
{
// inserted delay for power up of ethernet device on Arduino Etherten

delay( 250 ); 

Ethernet.begin(mac, ip);


Blynk.begin(auth, IPAddress(10,0,1,18), 8442);
}

void loop()
{
Blynk.run();

// Remember to avoid delay() function!
}

My Arduino and Pi both have static IP addresses.

Thank you in anticipation of any advice.

Kevin

Hello. Do you see this line when editing crontab again?

Yes, the line

@reboot java -jar /home/pi/server-0.29.5.jar -dataFolder /home/pi/Blynk &

is at the end of the “crontab -e” when edited again but no autorestart occurs

Had the same problem.
There is the “-java8” missing in the rc.local.

As an alternative:

1 Like

Hi,

Thanks for that advice. However I’m a bit lost as to where “-java8” is missing in the rc.local, presumably in editing the suggested entry of:

“java -jar /home/pi/server-0.29.6.jar -dataFolder /home/pi/Blynk &” ?

Thanks,
Kevin

Depending on where you found your initial tutorial, or if you have searched this forum,
you may or may not be aware that… as of recent Local Server changes, there is now support for Java 9… however due to some incompatibilities with some hardware, there is now both Java options. So depending on what version you download you adjust your rc.local accordingly.

Newer Java 9 option…

server-0.30.0.jar <— Note, referencing latest Server version 0.30.0

…or the “older” Java 8 option.

server-0.30.0-java8.jar <— Note, referencing latest Server version 0.30.0

More details here:

OK thanks for the all advice from the various contributors.

I eventually went with the crontab -e option, using server 0.30.0

The entry that has worked consistently for me for the server auto restart is as follows:

@reboot java -jar /home/pi/server-0.30.0-java8.jar -dataFolder /home/pi/Blynk &

If you agree that this should generally apply in most Unix-like systems then perhaps the GitHub Server auto restart instruction should be upgraded to reflect this addition of “-java8” into the single added line.

Thanks again,
Kevin

It shouldn’t. -java8 is only for old hardware. Today even Raspberry PI is 64x that’s mean you may use Java 9 and don’t need Java 8 anymore.

Fair enough but your GitHub “Quick local server setup on Raspberry PI” still says as follows:

Quick local server setup on Raspberry PI

Login to Raspberry Pi via ssh;

Install java 8:

sudo apt-get install oracle-java8-jdk
Make sure you are using Java 8

java -version
Output: java version “1.8”

PS I’m just wondering if “Quick local server setup on Raspberry PI” is referencing older Pi 1 or 2 models, perhaps pre 64x? Nonetheless for novices like me a bit confusing.

Regardless of this minor confusion (for me at least) thanks so much for Blynk, it is fantastic software.

@Rocheaxe good point. At the moment of movement to Java 9 most of Blynk Local servers were on old 32-x bit raspberries. So we left it as it. But maybe now it is time to update that doc.

to include 32 and 64 bit instructions.

My Local Server runs on a 32bit only netbook… so I always use the Java-8 option.

Off topic, but would you fill me in how you were able to set your static IP of your Pi server? I see no mention of this in the Blynk/Github instructions and as far as I can tell, I can’t log into my app until I iron this out. TYIA

@Skybound there are hundreds of online tutorials for this e.g. https://www.modmypi.com/blog/how-to-give-your-raspberry-pi-a-static-ip-address-update

1 Like

The above method works on Rasberry Pi 4.
Thank you distans

1 Like