---
title: "Getting started: configuration and first run"
description: "Set up Core Functions: install dependencies, add credentials, choose USB or SPI, pick sandbox or production, and run your first token check."
---

[Skip to content](https://portal.sandgrain.eu/knowledge-base/getting-started-configuration-and-first-run#main-content)

English

Show submenu for translations

![SandGrain\_Logo\_RGB\_white-bijgesneden (1)](https://portal.sandgrain.eu/hs-fs/hubfs/SandGrain_Logo_RGB_white-bijgesneden%20(1).png?width=427&height=83&name=SandGrain_Logo_RGB_white-bijgesneden%20(1).png)

Open main navigation

Close main navigation

- English
  
  Show submenu for translations
- [Contact us](https://portal.sandgrain.eu/login)

[Contact us](https://portal.sandgrain.eu/login?hsLang=en)

 How can we help you?

- There are no suggestions because the search field is empty.

1. [Knowledge Base](https://portal.sandgrain.eu/knowledge-base?hsLang=en)
2. [SDK](https://portal.sandgrain.eu/knowledge-base/sdk?hsLang=en)
3. [Core Functions](https://portal.sandgrain.eu/knowledge-base/sdk?hsLang=en#core-functions)

October 6, 2026

# Getting started: configuration and first run

Three things must be right before any example will run: your **credentials**, your **interface**, and your **environment**.

### 1. Install dependencies

Python 3.9 or newer is required.

**Linux / Raspberry Pi:**

```
sudo apt-get update sudo apt-get install -y python3-pip python3-rpi.gpio python3-spidev pip3 install requests pyserial
```

`python3-rpi.gpio` and `python3-spidev` are only needed if you use the SPI interface.

**Windows / macOS:**

```
pip install requests pyserial
```

**Only for the `_rsa2048` examples:**

```
pip install cryptography
```

### 2. Add your credentials

All cloud flows read from [`SandGrain_Credentials.py`](https://github.com/YOUR-ORG/YOUR-REPO/blob/main/SandGrain_Credentials.py) at the repository root. Fill in the template:

```
cloudflaretokens = {          'CF-Access-Client-Id': 'your_id.access',          'CF-Access-Client-Secret': 'your_secret' }  iotusername = 'your_device_username' iotpassword = 'your_device_password'  tenantusername = 'your_tenant_email' tenantpassword = 'your_tenant_password'
```

Credentials are issued once SandGrain has created your tenant account; contact [support@sandgrain.eu](mailto:support@sandgrain.eu).

**Protect your credentials.** [`SandGrain_Credentials.py`](https://github.com/SandGrain-CyberRock/CyberRock-Core-Functions/blob/main/SandGrain_Credentials.py) is edited in place and is **not** covered by the project's `.gitignore`. If you vendor this project into your own repository, run `echo 'SandGrain_Credentials.py' >> .gitignore` *before* filling in real values; otherwise your first commit will publish them.

### 3. Choose your interface

Set it in [`CyberRock_Config.py`](https://github.com/SandGrain-CyberRock/CyberRock-Core-Functions/blob/main/CyberRock_Config.py):

```
interface = 'USB'      # or 'SPI' serial_port = None     # None = platform default
```

| Interface | Platforms | Notes |
| --- | --- | --- |
| USB | Linux, Windows, macOS | 115200 baud. Default port `/dev/ttyACM0` (Linux/macOS) or `COM3` (Windows). |
| SPI | Linux / Raspberry Pi only | 10 MHz, mode 0, manual chip-select on GPIO 22. On Windows, SPI falls back to USB automatically with a warning. |

To list available serial ports:

```
import CyberRock_Config as config print(config.list_serial_ports())
```

### SPI wiring: Raspberry Pi 4 to token (SGT1001)

| Raspberry Pi pin | Token pin |
| --- | --- |
| Pin 17 (3.3 V) | VDD (pin 8) |
| Pin 25 (GND) | VSS (pin 4) |
| Pin 19 (BCM 10) | MOSI (pin 5) |
| Pin 21 (BCM 9) | MISO (pin 2) |
| Pin 23 (BCM 11) | CLK (pin 6) |
| Pin 15 (BCM 22) | CSN (pin 1) |

Enable SPI first with `sudo raspi-config` → Interface Options → SPI → Enable.

### 4. Choose your environment

Also in [`CyberRock_Config.py`](https://github.com/SandGrain-CyberRock/CyberRock-Core-Functions/blob/main/CyberRock_Config.py):

```
ENVIRONMENT = 'sandbox'      # or 'production'
```

| Environment | Device API |
| --- | --- |
| sandbox | `https://device-api.sandbox.sandgrain.io/` |
| production | `https://device-api.cyberrock.sandgrain.io/` |

The tenant API URL is derived automatically.

### 5. First run

**Step 1: confirm the token responds** (no credentials or network needed):

```
python examples/01-getting-started/token_id.py
```

You should see a 64-character TID.

**Step 2: your first full round-trip:**

```
python examples/02-prove-device-identity/host_auth_priority.py
```

You should see `AUTH_OK`. If you see `CLAIM_TOKEN`, the token is genuine but not yet bound to your tenant; run [`examples/01-getting-started/token_claim.py`](https://github.com/YOUR-ORG/YOUR-REPO/blob/main/examples/01-getting-started/token_claim.py) first.

### Checking your setup

| What you see | What it means |
| --- | --- |
| A 64-character TID | Interface is correct. Move on to a cloud flow. |
| `No response from token on serial port …` | Wrong port, or the token is not connected. Check `list_serial_ports()`. |
| `ModuleNotFoundError: No module named 'serial'` | Run `pip install pyserial`. |
| Hangs indefinitely | The Core Functions polling loops have no timeout; |

---

**Source code:** [SandGrain CyberRock - Core Functions on GitHub](https://github.com/SandGrain-CyberRock/CyberRock-Core-Functions)

|  | [What are Core Functions? -\>](https://portal.sandgrain.eu/knowledge-base/what-is-sandgrain-cyberrock-core-functions?hsLang=en) |
| --- | --- |

- [User Documentation](https://portal.sandgrain.eu/knowledge-base/user-documentation?hsLang=en#main-content)

    - [Quick Starter Guide](https://portal.sandgrain.eu/knowledge-base/user-documentation?hsLang=en#quick-starter-guide)
    - [User Manual](https://portal.sandgrain.eu/knowledge-base/user-documentation?hsLang=en#user-manual)
    - [Whitepaper](https://portal.sandgrain.eu/knowledge-base/user-documentation?hsLang=en#whitepaper)
    - [Token Leaflet](https://portal.sandgrain.eu/knowledge-base/user-documentation?hsLang=en#token-leaflet)
    - [Claim Token Procedure](https://portal.sandgrain.eu/knowledge-base/user-documentation?hsLang=en#claim-token-procedure)
    - [Daisy Chain](https://portal.sandgrain.eu/knowledge-base/user-documentation?hsLang=en#daisy-chain)
    - [Release Note](https://portal.sandgrain.eu/knowledge-base/user-documentation?hsLang=en#release-note)
    - [Naming Convention](https://portal.sandgrain.eu/knowledge-base/user-documentation?hsLang=en#naming-convention)
    - [SandGrain SDK](https://portal.sandgrain.eu/knowledge-base/user-documentation?hsLang=en#sandgrain-sdk)
    - [TrustBridge](https://portal.sandgrain.eu/knowledge-base/user-documentation?hsLang=en#trustbridge)
- [API Documentation](https://portal.sandgrain.eu/knowledge-base/api-documentation?hsLang=en#main-content)

    - [Device API Integration](https://portal.sandgrain.eu/knowledge-base/api-documentation?hsLang=en#device-api-integration)
    - [Daisy Chain and Attestation](https://portal.sandgrain.eu/knowledge-base/api-documentation?hsLang=en#daisy-chain-and-attestation)
- [SDK](https://portal.sandgrain.eu/knowledge-base/sdk?hsLang=en#main-content)

    - [Core Functions](https://portal.sandgrain.eu/knowledge-base/sdk?hsLang=en#core-functions)
    - [SandGrain SDK](https://portal.sandgrain.eu/knowledge-base/sdk?hsLang=en#sandgrain-sdk)

[![SandGrain\_Logo\_RGB\_white-bijgesneden (1)-1](https://portal.sandgrain.eu/hs-fs/hubfs/SandGrain_Logo_RGB_white-bijgesneden%20(1)-1.png?width=427&height=83&name=SandGrain_Logo_RGB_white-bijgesneden%20(1)-1.png "SandGrain_Logo_RGB_white-bijgesneden (1)-1")](https://portal.sandgrain.eu/?hsLang=en)

<https://www.facebook.com/> <https://www.twitter.com/> <https://www.instagram.com/> <https://podcasts.apple.com/> [mailto:email@email.com](mailto:email@email.com)

Copyright © 2026, sandgrain.eu