Hardware and Reference
GPIO pinouts and interfaces by board, how to reach the controller, what to prepare on external services, and the electronics basics wiring depends on.
Hardware Pinouts and Interfaces
Raspberry Pi
Every current model provides a 40-pin header, and each pin has the same function across models. Pins can be numbered by connector position (Physical/Board) or by CPU channel (GPIO/BCM); Grablo uses GPIO/BCM.
| Function | Pins | Notes |
|---|---|---|
| I2C | GPIO 2 (SDA), 3 (SCL) | Also usable as general digital I/O. |
| SPI | GPIO 7, 8, 9, 10, 11 | Also usable as general digital I/O. |
| UART | GPIO 14 (TX), 15 (RX) | The primary UART. |
| Hardware PWM | GPIO 12, 13 | Also usable as general digital I/O. |
| 1-Wire | GPIO 4 | The default, changeable with the procedure below. |
Apart from the power pins, every GPIO pin runs at 3.3V. The current limits are 0.5mA per input and about 8mA per output, with the sum across all output pins staying under 50mA. On the power pins, the 3.3V rail supplies about 800mA and the 5V rail about 2.5A minus what the board itself (camera, USB, and so on) and the 3.3V rail draw. The Raspberry Pi has no analog input pins, so reading an analog signal requires an ADC such as the ADS1115.
Jetson Nano
On the Jetson Nano, pin numbers and GPIO numbers are different schemes. Enter the GPIO number in Grablo.
| Pin | GPIO | Pin | GPIO | Pin | GPIO |
|---|---|---|---|---|---|
| 7 | 216 | 19 | 16 | 31 | 200 |
| 11 | 50 | 21 | 17 | 32 | 168 |
| 12 | 79 | 22 | 13 | 33 | 38 |
| 13 | 14 | 23 | 18 | 35 | 76 |
| 15 | 194 | 24 | 19 | 36 | 51 |
| 16 | 232 | 26 | 20 | 37 | 12 |
| 18 | 15 | 29 | 149 | 38 | 77 |
| - | - | - | - | 40 | 78 |
I2C uses pins 3 (SDA) and 5 (SCK). I2C0 is reserved for internal use such as the camera
interface and cannot be wired to external devices. UART is on pins 8 (TX) and 10 (RX),
and its port name is /dev/ttyTHS1. PWM (pins 32 and 33) and SPI must be
enabled in Jetson-IO before use: run the command below, then choose
Configure Jetson 40pin header > Configure header pins manually,
select the functions, save, and reboot.
sudo /opt/nvidia/jetson-io/jetson-io.py
External GPIO Adapters
When a board has no GPIO pins, or has run out of them, use a USB-GPIO adapter. See Part 6 for how to register one.
| Adapter | Digital I/O | Other functions | Logic level |
|---|---|---|---|
| FT232H | 12 pins. AD4–AD7 are GPIO 0–3, AC0–AC7 are GPIO 4–11. | I2C (AD0=SCL, AD1 and AD2=SDA, wired together), SPI (AD0=SCLK, AD1=MOSI, AD2=MISO, AD3=CS) | 3.3V, with 5V-tolerant inputs. |
| MCP2221A | 4 pins. G0–G3 are GPIO 0–3. | I2C (SCL, SDA), UART (RX, TX), 10-bit ADC (G1–G3), 5-bit DAC (G2 or G3, output appears on both) | 3.3V by default; a jumper on the module switches it to 5V. |
| NUMATO USB-GPIO | 8 to 128 pins depending on the model, starting at IO0 as GPIO 0. | Six 10-bit ADC channels (IO0–IO3 and IO6–IO7 on the 8-channel model) | 5V |
Finding an I2C Address
Registering an I/O device requires its I2C address. Running the command below in the controller's terminal lists the addresses of devices on the hardware I2C pins in hexadecimal. The bus number can differ by board.
sudo i2cdetect -y 1
The command reports addresses only, not device names or types. With several devices attached, check each device's datasheet to match addresses to devices. Devices wired to pins other than the hardware I2C pins (software I2C) cannot be found this way.
Changing the 1-Wire Pin
The Raspberry Pi's 1-Wire pin defaults to GPIO 4. To wire a device such as the DS18B20 to another pin, edit the configuration file.
sudo nano /boot/firmware/config.txt
Find dtoverlay=w1-gpio and name the pin to use. For several 1-Wire pins,
write several lines. Save the file and reboot with sudo reboot to apply.
dtoverlay=w1-gpio,gpiopin=17 dtoverlay=w1-gpio,gpiopin=27
/boot/firmware/config.txt; on earlier versions it is
/boot/config.txt.
Serial (UART) Ports
Modbus and User Defined Communication need a port name. The Raspberry Pi's UARTs appear as the following devices.
| UART | Device name | Description |
|---|---|---|
| Primary | /dev/serial0 | The port on the hardware UART pins (GPIO 14 and 15). Its actual type varies by model, so this name is the safe one to use. |
| Secondary | /dev/serial1 | Reserved for Bluetooth on models that have it. |
| Full UART | /dev/ttyAMA0 | The full-featured UART. |
| Mini UART | /dev/ttyS0 | Lower performance, with some features missing. |
| USB-TTL converter | /dev/ttyUSB* | FT232RL, CP2102, PL2303, and CH340 chipsets are supported. After connecting, check with ls -l /dev/ttyUSB*. |
The Raspberry Pi 4 has four hidden full UARTs. Add the lines you need, from
dtoverlay=uart2 through uart5, to the configuration file and
reboot; they appear as ttyAMA1 onward, which
dmesg | grep tty confirms. The default pins are GPIO 0 and 1 for UART2,
GPIO 4 and 5 for UART3, GPIO 8 and 9 for UART4, and GPIO 12 and 13 for UART5 (TXD then
RXD).
Reaching the Controller and Transferring Files
These are the ways to run commands on the controller directly, or to place files such as soundfonts and AI models on it. This is a different path from the file upload used inside a project (Part 3).
Finding the Address
SSH and SFTP need the controller's hostname or IP address. The hostname set when the
operating system was installed works directly; on a Raspberry Pi it defaults to
raspberrypi or raspberrypi.local. Once connected,
ip a reports the actual IP address. If the hostname does not resolve, scan
the local network with an IP scanner.
Installing an SSH Server
Raspberry Pi OS and Debian-based distributions include an SSH server by default, but some distributions require installing it. With the controller online, run:
sudo apt-get update sudo apt-get install -y openssh-server
Connecting over SSH
An SSH client connects to the controller and runs commands remotely. On Windows, use
PuTTY; on macOS and Linux, use the ssh command in a terminal, or a client
such as Termius or MobaXterm. You need the hostname or IP address, the port (22 by
default), and an operating system account.
ssh username@raspberrypi.local
Transferring Files
Moving files between a PC and the controller uses SFTP. Enter the controller's hostname, login account, and port (22 by default) in an SFTP client such as FileZilla, then upload and download between the PC directory on the left and the controller directory on the right.
/home/username or /tmp.
Automatic Login
Grablo runs as a system service, so it starts on boot without anyone logging in. Features that draw to a screen, however, such as Display Image and video playback, need a desktop session. For unattended operation with a monitor attached, turn on automatic login. On Ubuntu and Debian, open Settings > System > Users, click Unlock, and switch on Automatic Login.
Preparing External Services
Some settings need a key or value issued by an external service. Here is how to obtain each of them.
| Service | Values to enter in Grablo | Used by |
|---|---|---|
| Google Cloud | API key | Text-to-Speech, Speech-to-Text |
| OpenAI | API key | Text-to-Speech, Speech-to-Text, LLM AI |
| ElevenLabs | API key, Voice ID | Text-to-Speech |
| Telegram | Bot token, chat ID | Telegram Bot setting, Telegram Message action |
| Firebase | Database address, web API key, login account | Database |
| SoundFont | Bank and preset numbers | Synthesizer action |
Google Cloud (TTS and STT)
- Create a project in the Google Cloud console and attach a payment method to it under Billing.
- Under APIs & Services, find and enable both Text-to-Speech API and Speech-to-Text API.
- In APIs & Services > Credentials, choose + Create credentials → API key and copy the value.
- On the same screen, restrict the key to those two APIs.This limits the damage if the key leaks.
OpenAI
- Sign in to the OpenAI platform, create a new secret key under Dashboard > API keys, and copy the value.
- Add a payment method and top up your balance under Settings > Billing > Payment methods.OpenAI's speech conversion has no free allowance, so a balance is required.
ElevenLabs
- After signing up, open your account name at the bottom left, then API Keys → Create Key, and copy the value.
- In Voices, preview the voice you want, then click View → ID to copy its Voice ID.The API key alone does not complete the setting; the Voice ID is required too.
Telegram Bot
- Find
BotFatherin Telegram, start the chat, and send/newbot. - Enter a display name for the bot, then a username.The username must end in bot and must not collide with another bot.
- Enter the issued token in Settings → Telegram Bot.
- Open the new bot's link to start a chat and press START.Without this step the bot cannot send you messages.
- Find
@userinfobotin Telegram and start it to learn your chat ID. Enter that value in Action → Telegram Message.
Firebase Realtime Database
- Create a project in the Firebase console, then create a database under Realtime Database → Create Database, choosing Start in locked mode for the security rules.
- Copy the database address shown at the top of the screen.
- Under Authentication → Sign-in method, enable the method you want. For email and password access, enable that method and add accounts on the Users tab; for access without a login, enable Anonymous.
- Copy the web API key from Project settings > General.
- On the Rules tab of Realtime Database, replace the rules with the following and publish.A database created in locked mode is closed to everyone. These rules open it to the users you allowed above.
{
"rules": {
".read": "auth != null",
".write": "auth != null"
}
}
Choosing an Instrument from a SoundFont
The Synthesizer setting takes a SoundFont file plus the bank and preset numbers that identify an instrument. Those numbers come from a SoundFont editor. Open the SoundFont (sf2, sf3) in an editor such as Polyphone, select an instrument in the Presets list, check the sound with the virtual keyboard, and enter the bank and preset values shown at the bottom of the screen.
Fetching Weather Data
Grablo has no dedicated weather action, so a weather API is called with the HTTP Communication action. With WeatherAPI.com, for example, sign up, find the API key on the dashboard, and request the following.
https://api.weatherapi.com/v1/forecast.json?key=API_KEY&q=Seoul&days=3&lang=en
q takes a city name, a latitude and longitude, or auto:ip;
days is the number of forecast days and lang the response
language. The values most often used from the response are below; extract them with the
JSON blocks and store them in variables
(Part 8).
| Path | Value |
|---|---|
current.temp_c | Current temperature in Celsius |
current.humidity | Current humidity (%) |
current.condition.text | Current conditions |
forecast.forecastday[].day.maxtemp_c | Daily high temperature |
forecast.forecastday[].day.daily_chance_of_rain | Daily chance of rain (%) |
forecast.forecastday[].astro.sunrise | Sunrise time |
Electronics Basics
What to know before wiring a device.
Digital Input and Output
In a digital circuit, current flows when the switch closes and stops when it opens. The closed state is HIGH and the open state is LOW. A digital input is the controller sensing that opening and closing on an external switch; a digital output is the controller driving it.
Analog Signals and ADCs
Values that vary continuously, such as light level or sound volume, are analog signals. The controller only handles digital signals, so reading an analog signal needs an ADC (Analog-Digital Converter) and producing one needs a DAC. The Raspberry Pi has no analog input pins, so register an ADC device such as the ADS1115 as an I/O device.
Calculating an LED Resistor
When the supply voltage is higher than the LED's forward voltage, a resistor must limit the current. Without one, current far above the rating flows and the LED is damaged. Ohm's law gives the value.
R = (supply voltage - LED forward voltage) / current
For a red LED with a 2V forward voltage on a 3.3V GPIO, allowing for the Raspberry Pi's per-pin output limit of about 8mA and targeting 5mA, the result is about 260Ω. The commonly available 220Ω gives about 5.9mA, comfortably within range. The resistor may go on either leg of the LED.
Pull-up and Pull-down Resistors
With a push button released, an input pin connected to neither the supply nor ground is neither HIGH nor LOW but floating. In that state, noise or static can flip the value arbitrarily and it cannot be controlled. A pull-up resistor pins the released state to HIGH and a pull-down resistor pins it to LOW, removing the problem.
Converting Between 3.3V and 5V
Raspberry Pi GPIO runs at 3.3V. Connecting a 5V-only sensor, or a 5V board such as an Arduino Uno, requires level conversion; connecting 5V without it damages the board.
- Voltage divider: Two resistors lower the voltage. To bring 5V down to 3.3V, for example, R1 of 1kΩ with R2 of 2kΩ produces about 3.3V. Use this for incoming 5V signals such as the echo pin of an HC-SR04 ultrasonic sensor.
- Logic level converter: A module supporting bidirectional conversion across several channels. Use it for two-way signals such as communication lines, wiring the higher voltage to HV and the lower to LV.
Raspberry Pi, Jetson Nano, and the Arduino Due and Zero are 3.3V devices; the Arduino Uno, Nano, and Mega are 5V devices.
Serial Communication Standards
| Standard | Characteristics |
|---|---|
| TTL UART | Wires the board's UART pins directly. Suited to short distances and one-to-one links. |
| RS-232 | The standard PC serial interface. One-to-one, and its voltage levels differ from TTL, so a converter is needed. |
| RS-422 | Differential signaling for longer distances, used for one-to-many in one direction. |
| RS-485 | Differential signaling that tolerates long runs and puts several devices on one pair. Widely used for industrial Modbus RTU. |
Motors and Relays
DC motors are controlled by voltage for speed, servo motors by a PWM signal for angle, and stepper motors by pulse count for rotation. All three are supported as I/O devices (Part 7).