Setup PI ZERO W as ultra portable server and AP (tutorial) updated to 2022 :)

Do you use lite version? What is the size of your .img file?

and also why you are using HDD with pi w?

I use the Raspbian with Desktop(which is over 4GB in size Raspberry Pi OS – Raspberry Pi) as I access the Pi via VNC Viewer(https://www.realvnc.com/en/connect/download/viewer) sometimes.

No reason other than I had it lying around.

I thought you were streaming media using zero w. I use same os raspbian jessie with vnc

That’s actually something I’ve been looking at recently, via the VNC Viewer app(https://play.google.com/store/apps/details?id=com.realvnc.viewer.android) on my phone.

hello!

since i created this tutorial few years ago, lots of things have changed, and some of the steps / links became obsolete or unusable, due to new software versions etc.

i’ve just put together a quick tutorial, if anyone nowadays still needs to set up a legacy blynk server for offline use. personally i’ve struggled for few days to make it work, either because of new hardware changes or missing / incorrect details in the various documentations on the internet.

this is an updated mini tutorial, all steps tested and working on rpi zero w v2, as of 2022 april.

~how to install and setup a STANDALONE, OFFLINE local blynk server, using a win10 pc~

0) introduction:
the latest (and probably the last) version of the blynk local server (server-0.41.17.jar) needs java 11 to run… java 11, in turn, needs ARMv7 or newer cpu to run. so it will not work with older rpi models!!!

to check your board details, type this:

  • cat /proc/cpuinfo

for my project, i needed a minimalist and offline blynk server, with built in wifi. i used a rpi zero w v2. this is how i made it work:

1) download rpi imager Raspberry Pi OS – Raspberry Pi

2) sd card:
use an original and high quality sd card, at least 8gb. (the faster the better)

3) install the latest rpi os (using rpi imager):

  • choose os > rpi os (other) > rpi os lite (32bit)
  • choose storage
  • click on advanced option (bottom right):
    set hostname, enable ssh, set user and password, set wifi (the one the rpi will connect to set up the server. it needs internet)
  • click write
  • when finished, remove the sd card and put in the rpi

4) start the rpi: allow time for the first boot!

5) install putty on your pc Download PuTTY: latest release (0.79)

6) find the rpi ip address (look on the router menu in connected clients, for example)

7) connect to the rpi using putty and ssh:

  • open putty
  • fill in the ip address of the rpi (at the host name), and click open
  • click accept on the warning windows, a terminal window should open
  • enter the hostname and password for the rpi
    *note: in the terminal, to paste text just right click. to copy text from terminal, just select the text.

8) download latest upgrades for the rpi os:

  • sudo apt-get update
  • sudo apt-get upgrade
  • sudo reboot

9) install java 11, blynk server, midnight commander:
https://github.com/blynkkk/blynk-server

  • wget "https://github.com/blynkkk/blynk-server/releases/download/v0.41.17/server-0.41.17.jar"
  • sudo apt install default-jdk
  • java -version
  • sudo apt install mc (optional, but useful file manager. start with sudo mc)
    *after this stage, it is a good idea to create a backup copy of the sd card, using an imager software. safely shut down the rpi: sudo shutdown -r now

10) boot the rpi, wait, then re-connect via putty (step 7)

11) install AP and management software:

  • sudo apt install hostapd
  • sudo systemctl unmask hostapd
  • sudo systemctl enable hostapd
  • sudo apt install dnsmasq
  • sudo DEBIAN_FRONTEND=noninteractive apt install -y netfilter-persistent iptables-persistent

12) dhcpd configuration:

  • sudo nano /etc/dhcpcd.conf
    go to the end of the file and add (right click):

interface wlan0
static ip_address=192.168.4.1/24
nohook wpa_supplicant

13) configure the DHCP and DNS services:

  • sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
  • sudo nano /etc/dnsmasq.conf

add the following:

# Listening interface
interface=wlan0

# Pool of IP addresses served via DHCP
dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h

# Local wireless DNS domain
domain=wlan

# Alias for this router
address=/blynksv.wlan/192.168.4.1

14) configure the AP Software:

  • sudo rfkill unblock wlan
  • sudo nano /etc/hostapd/hostapd.conf

add these lines (passphrase between 8 and 64 characters):

country_code=GB
interface=wlan0
ssid=blynksv
hw_mode=g
channel=7
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=1234567890!!!!!!
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

15) restart the rpi:
ATENTION: after this command you will not have internet connection anymore, so download any other packages what you need!!!

  • sudo systemctl reboot

after reboot, connect to to the new wifi with your pc, start putty, and connect to 192.168.4.1 or blynksv.wlan

16) start the blynk server:

  • java -jar server-0.41.17.jar -dataFolder /home/pi/Blynk

As output you should see something like that:
Blynk Server successfully started.
All server output is stored in current folder in ‘logs/blynk.log’ file.

17) enabling server auto restart:

RCLOCAL METHOD IS OBSOLETE, READ THIS:

  • sudo nano /etc/rc.local

add before the exit 0 line:

  • java -jar /home/pi/server-0.41.17.jar -dataFolder /home/pi/Blynk &

*or, if the approach above doesn’t work, execute:

  • crontab -e

add:
@reboot java -jar /home/pi/server-0.41.17.jar -dataFolder /home/pi/Blynk &

reboot with:

  • sudo reboot

18) check if server is running (it needs some time to start):
find process id of Blynk server:

  • ps -aux | grep java

you should see something like that:
username 10539 1.0 12.1 3325808 428948 pts/76 Sl Jan22 9:11 java -jar server-0.41.17.jar

*or:

  • sudo netstat -plnt
    you should see all 3 blynk ports listening:

tcp6 0 0 :::8440 :::* LISTEN 434/java
tcp6 0 0 :::9443 :::* LISTEN 434/java
tcp6 0 0 :::8080 :::* LISTEN 434/java

19) connect with admin panel:
in the browser, enter: 192.168.4.1:9443/admin

20) further, study:
https://github.com/blynkkk/blynk-server#advanced-local-server-setup

5 Likes

A very very nice tutorial, good work! :+1:

Hoooowwwwever… :hugs: If you’d like to put on the big-boys pants and sit at the grown ups table, I urge you to reconsider the use of rc.local or crontab. It’s an obsolete and inferior way to make a service up and running.

Take a look at this:

This actually confuses me! :face_with_raised_eyebrow: Unless you map IPv4 to IPv6 this shouldn’t work?!? Or are the ::: representing *.*.*.* IP’s? I don’t have a Linux system available to me at the moment so I can’t check myself :frowning:

Anyhow, good work @wanek

1 Like

thanks for the recommendation!

i really do not know much about linux, and just followed blindly the instructions on the official local server docs: the rc.local method worked out of the box, so i didn’t tried using anything else… the auto restart functionality is nice to have, so i will “upgrade” to the systemd method.

i always welcome the constructive comments, and eager to improve my skills.

regarding the netstat command and ipv6, i have no clue, didn’t mapped anything. all the steps i have done are documented in the above tutorial.

you’ve recommended me the netstat to check the ports, it works, so i’m using it :slight_smile:

1 Like

Years ago, I suggested that those instructions should be changed, but I guess it wasn’t a priority… Many advantages with systemd, especially the auto restart!

I know :grinning: I think there is some automatic voodoo mapping on more recent distributions for IPv4->IPv6. I have to find some forgotten passwords to check it :grimacing:

I know you have big pants @wanek :wink:

1 Like