Use Barracks with your Raspberry Pi Zero W
Here are a few steps to integrate the Barracks client into your Raspberry Pi. You will just need a SD card, a free Barracks account, and oh … a Raspberry Pi! (model Zero W in our case).
Install Barracks into your Raspberry Pi
▶ Install & Configure Raspbian
1 – Flash a Raspbian image on your SD-Card by following the official tutorial.
Later, we will need to connect to the Raspberry via SSH. So we will configure it to connect automatically to your Wifi network on boot, with SSH enabled (which is not by default on the new Raspberry Pi Zero).
2 – Download these configuration files.
3 – Edit the downloaded file called wpa_supplicant.conf :
- Replace YOUR_SSID with your Wifi SSID (name)
- Replace YOUR_PSK the network’s password
⚠️ Note that the corresponding wifi network must not be in 5Ghz
Then, drag and drop the wpa_supplicant.conf and ssh files to the SD card (on the boot volume). Eject the SD card and put it in the unpowered Raspberry Pi. Power the Raspberry.
The Raspberry Pi is booting now!
▶ SSH connect to the Raspberry Pi
Once the Raspberry Pi is booted up (when the LED is not blinking anymore), open a terminal on your computer that should be connected to the same Wifi network you entered in the wpa_supplicant.conf file. Enter the following command :
Enter yes when the command line asks you the following :
The authenticity of host 'raspberrypi.local (fe80::1fec:f418:2f97:eadc%en0)' can't be established.
ECDSA key fingerprint is SHA256:XUbyk4wsqVcsRw99jbWb3BNXY+wqP6WsMtSAdfj577Q.
Are you sure you want to continue connecting (yes/no)?
The command line will ask you the pi@raspberry’s password, enter raspberry :
You are now connected, the command line prompt should be
▶ Install Barracks Client
Now that you are connected to your Raspberry Pi, we can install the Barracks client. Simply copy and paste the following command in the prompt command line.
wget https://github.com/barracksiot/barracks-raspberry-pi-client/releases/download/v1.4/barrackspiclient.deb && sudo dpkg -i barrackspiclient.deb
During the installation, you will have to enter you Barracks API Key. it will directly enroll your Raspberry Pi in Barracks.
You are now all set! 🤘
A few seconds after the end of the installation you should be able to see a new device ping in on your Barracks device management page.
What’s next ?
A Barracks service is now running on your Raspberry Pi. It will start connecting periodically to Barracks to check for new updates. The service automatically starts when the device boot.
You can change some basic settings in the Barracks default config file located at : /etc/default/barracks
- BARRACKS_API_KEY : Your Barracks API key.
- BARRACKS_UNIT_ID : The unitId used to ping Barracks. You can choose pretty much anything, yes even 🍓, just make sure you won’t have two devices with the same unitId
- PING_INTERVAL : The time interval in ms between the check update requests. (2 hours by default)
- BARRACKS_BASE_URL : The base url used for the requests. Useful if you use a proxy.
Publish your first Update!
From now on, you can publish Updates from you Barracks account. If you need help check this out!
To use this Barracks Client, the Update package must be a zip archive with a script called update.sh at the root. Once the service has found an Update, it will download the package, unzip it and execute the update.sh script.
For example, create an update from your barracks account, use this zip package as update package file. Make sure that the versionId is different than the default one (which is 0.0.1). Save it, then publish it.
At the next ping on Barracks, your Raspberry Pi will transform into a t-rex-runner-game local server. Once the update is installed (it may take a few seconds), connect to http://raspberrypi.local to play with the T-rex !
Here are some useful tips
- To force-check for new updates just restart the service using
1sudo systemctl restart barracks.service
- To see Barracks log on your device, just tail this file
1tail -f /var/log/barracks.log