In part one of this 4 part series we covered the prerequisites you need to know to develop for Pebble watches. Part 2 will cover installing the SDK and Pebble emulator.
Part 1 - Introduction - Why write a Pebble app in 2020 - An explanation of the different Pebble devices & platforms - An introduction to Pebble apps Part 2 - Pebble SDK options - Installing the SDK Part 3 (Coming soon) - Introduction to PebbleJS - Writing your first app - Calling an API for data Part 4 (Coming soon) - Writing an App configuration page - Advanced PebbleJS concepts
Pebble SDK options
The Pebble Software Development Kit (SDK) is the set of tools we need to build our Pebble app. It manages turning our code into something that can run on the watch, as well as some testing and debug tools too. Once we’ve got this setup, we can starting writing code. This guide will cover installation on Linux (and potentially MacOS), but there are several other ways you can install the SDK.
The easiest option: Pebble VM
If you want the super easy option there’s an Ubuntu linux virtual machine (vm) available with the SDK already installed on it. You can download it here. If you have never used a virtual machine before, it’s like running a computer inside a computer. If you’re starting from scratch you need to first install virtualbox, then download the vmdk file, then open the vmdk file in virtualbox. If you pick this option you can jump straight to the next blog post in this series (coming soon).
The better option: Installing natively
Although the VM option is quickest, it’s a little bloated. If you’re happy copy-pasting commands into a terminal, a native install is the way to go. For this guide I’ll be explaining how to install on Linux (or MacOS) in the next section. If you want to install the SDK natively on Windows, see this link.
The above two options are the most straightforward, but here are a few more alternatives. There’s a docker image if containers are your thing, an install script for debian, and even a nix build system package. These are all outside the scope of this tutorial but might float your boat.
Native SDK install on Linux
For this tutorial I’m going to cover installation on Ubuntu 20.04, but it will work for any Debian based Linux distro, including Raspberry Pi OS. If you’re running MacOS the tutorial should serve as a good base guide, but you’re probably better following the guide available here.
Step 1. Update the operating system
Before we get started with anything else, lets make sure the operating system is up to date:
sudo apt update && sudo apt upgrade -y
Step 2. Install python2 and python2-pip
Because the SDK tooling isn’t python-3 compatible, we need to install the older python2 and associated pip onto our machine.
sudo add-apt-repository universe sudo apt update sudo apt install python2 -y
Now python2 is installed, we can use the pypa script to install python2-pip.
curl https://bootstrap.pypa.io/get-pip.py --output get-pip.py sudo python2 get-pip.py
Pip will be installed globally. If you want to install it only for your user, run the command without
sudo. The script will also install
wheel, which allow you to install source distributions.
You can verify the install with
the output from which should look similar to:
pip 20.0.2 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
Step 3. Install other dependencies
We need a few more dependencies, mostly for the emulator:
sudo apt install wget python-dev libsdl1.2debian libfdt1 libpixman-1-0 -y
Step 4. Installing the SDK tools
Okay. Time to actually install the SDK tooling.
Navigate to your home directory and create a new directory called ‘pebble-dev’.
cd ~ mkdir pebble-dev
Change into that directory, download the SDK tooling and extract it.
cd ~/pebble-dev wget https://developer.rebble.io/s3.amazonaws.com/assets.getpebble.com/pebble-tool/pebble-sdk-4.5-linux64.tar.bz2 tar -jxf pebble-sdk-4.5-linux64.tar.bz2
Now we have the pebble SDK tooling downloaded. Move into the directory and print your current path
cd ~/pebble-dev/pebble-sdk-4.5-linux64 pwd
the output should be something like
Step 4.1: Patch requirements.txt
The SDK you downloaded has an outdated link in the file requirements.txt. We need to update it to point to a mirror. Open the file with:
and scroll down to the last line, which reads:
delete that line and in it’s place paste:
such that the file now looks like:
libpebble2==0.0.26 enum34==1.0.4 httplib2==0.9.1 oauth2client==1.4.12 progressbar2==2.7.3 pyasn1==0.1.8 pyasn1-modules==0.0.6 pypng==0.0.17 pyqrcode==1.1 requests==2.7.0 rsa==3.1.4 pyserial==2.7 six==1.9.0 virtualenv==13.1.0 websocket-client==0.32.0 wheel==0.24.0 colorama==0.3.3 packaging==16.7 https://github.com/Willow-Systems/vagrant-pebble-sdk/raw/master/pypkjs-1.0.6.tar.gz
Once you have done that, press
ctrl + o then
enter to save the file, then
ctrl + x to exit the text editor
Step 4.2 Installing the python dependencies
Install the required python dependencies.
virtualenv .env source .env/bin/activate pip install -r requirements.txt deactivate
Step 5. Add to PATH
Now the SDK is installed we need to add it to our PATH
echo 'export PATH=~/pebble-dev/pebble-sdk-4.5-linux64/bin:$PATH' >> ~/.bashrc ~/.bashrc
The Pebble SDK tooling is now ready to go, verify with
If this doesn’t work, try closing and re-opening your terminal
Step 6. Disable analytics
Navigate to the root pebble-dev folder, and create a blank file called NO_TRACKING. If a file called ENABLE_ANALYTICS exists, delete it
cd ~/pebble-dev touch NO_TRACKING rm ENABLE_ANALYTICS
Step 7. Install the Pebble SDK
Now we can install the actual watch SDK. Do so with:
pebble sdk install https://github.com/aveao/PebbleArchive/raw/master/SDKCores/sdk-core-4.3.tar.bz2
If prompted if you want to enable analytics, press N. If the process crashes or exits at this point, just run it a second time and it will proceed.
All systems go
At this point the SDK should be installed, you can verify by cloning an example pebble project and building it. For example:
cd /tmp git clone https://github.com/pebble-examples/cards-example cd cards-example pebble build pebble install --emulator basalt
If all goes according to plan, the app should build and appear in the emulator!
That’s it for part 2. Part 3 (coming before December 2020) will dive into how to write your own Pebble app.
Thanks to the following guides & resources which were used to assemble this install guide: