Get started

1. Create an account

Sign up for ThePiHub. Creating an account is free. It's the same login you'll use to view every device you connect.

2. Install the SDK on your Pi (or any Linux machine)

New to the Raspberry Pi? Start with Raspberry Pi's own guides: install the operating system with Raspberry Pi Imager, then follow their getting started page to start it up and get it online.

Then, on the Pi:

pip install thepihub

Python 3.10 or newer. That one command includes the live camera and direct connections to your browser; GPIO pins - buttons, LEDs, sensors - need one optional extra (thepihub[gpio]). A 32-bit Pi (an original Pi Zero) installs the camera pieces from apt instead - see the SDK's own README for that step.

3. Copy an example and run it

Every program in Projects is meant to be copied, not just read. Save one as greenhouse.py (each project's page has a View full code button) and run it:

python greenhouse.py

The first run: linking your Pi

The first time a machine connects, it has to be linked to your account. It takes a minute, and you only do it once.

1. Run it. The program says it isn't registered yet, prints a web address and a short code, and waits.

The terminal after running the program: a link, a code, and "Waiting for approval"
The program prints a link and a code, then waits for you.

2. Enter the code. On any device - your laptop or your phone will do - open the link while you're logged in, and type the code.

The link page with the code typed in
The link page, with the code from the terminal.

3. Link it. Press Link device. The page confirms, and shows the id the platform has given your Pi. You never choose or type an id.

The link page saying the device is linked to your account
Linked. The platform picks the device's id.

4. Confirm on the Pi. Back in the terminal, the program names the account that approved the link and asks you to confirm. Type y. A device belongs to one account for good, so the Pi asks you to check that it's yours before it agrees.

The terminal after approval: the account, the confirmation, and the device coming online
Confirmed: the Pi registers and comes online.

That's all. Every run after this connects straight away, with no code and no questions.

4. Watch it live

Open your dashboard and the device appears, with its widgets already laid out - a gauge for each number, a button for each command, a toggle or a slider for each setting you declared. You never write any web code or say where anything goes.

The device's dashboard: two gauges and a button
Your Pi, live: two gauges and a button, laid out for you.

Give it a name

Your Pi starts out named after its id (like raspberrypi-6bdbca). To give it a name you'll recognise, press the pencil next to the name at the top of its page, type the new name and press Enter (or the tick). Escape, or the cross, cancels.

The device's name box, open for editing, with the new name typed in
Press the pencil, type a name, press Enter.

A name can be up to 60 characters, and must be different from your other devices' names. Clear it and the original id comes back. It only changes what you see: your Pi and its program carry on exactly as before. You can also rename from your devices list: point at a device's card and press its pencil.

Code your own

Writing your own is just as short. This is the smallest program that puts a gauge on a dashboard:

from pihub import Device, Program

device = Device()

weather = Program(id="weather", name="Weather Station")
temperature = weather.output(id="temperature", type="Gauge")
device.add_program(weather)
device.start()

temperature.set(21.5)     # the gauge on the dashboard now reads 21.5

Running for real

Once a program is worth keeping around, pihub install my_program.py ensures it starts after a reboot and restarts if it dies.

Where to go next

  • Projects - weekend projects to demo or keep.
  • The SDK on GitHub - full details: outputs, commands, settings, notifications, the Camera, and direct browser-to-device connections.