
Microcontroller
FrameworkComputer/ExpansionCards
Reference designs and documentation to create Expansion Cards for the Framework Laptop

a simple SCPI compatible module containing some temperature and IO capabilities
Scpi tempio is an open-source printed circuit board by kerstensrobin, from the kerstensrobin/scpi-tempio repository on GitHub, published under the GPL-3.0 licence. It is a 2-layer board of 42.6 × 22.2 mm with 31 parts on 52 nets, routed with 281 tracks and 35 vias.
It is built around the AP2112K-3.3. Its parts include 15 resistors, 5 capacitors, 5 connectors, 3 ICs and 1 diode. It belongs with the STM32 boards of this library.
USB-connected environmental sensor and GPIO control module based on the STM32G0B1KBTx.
[!WARNING] Hardware v0.01 is not ready for production. The board must be revised before another batch is ordered. Open issues:
- J1 VTref is on VBUS (5 V) on the PCB. The schematic was corrected (VTref to 3V3), but the PCB was never updated from it. With 5 V on VTref, a programmer that sets its I/O level from VTref (such as a genuine ST-Link) may drive SWD at 5 V into a 3.3 V MCU. Existing boards need a bodge: cut J1 pin 1 from VBUS and wire it to 3V3.
- The schematic hotfix also moved C7 (1 µF, the AP2112K input capacitor) from VBUS to 3V3. It must go back on VBUS before the PCB is updated from the schematic, or the regulator loses its input capacitor.
- U1 symbol still named STM32G070KBTx in the schematic's symbol cache; the fitted part is the STM32G0B1KBT6.
- Gerbers in
hardware/production/are from v0.01 and contain issue 1. Regenerate them after the fixes.Before ordering: fix the above, update the PCB from the schematic, run DRC with schematic parity, and check that J1 pin 1 is on 3V3 and C7 on VBUS.
| Path | Contents |
|---|---|
hardware/ | KiCad project SCPI_tempIO (board with rounded tracks), production/ holds the v0.01 JLC outputs |
firmware/ | STM32CubeMX + CMake project, TinyUSB submodule in firmware/lib/tinyusb |
examples/ | Host-side example scripts (tempio_demo.py runs every command) |
This module is a small USB-connected development and test interface based on the STM32G0B1KBTx microcontroller.
It provides:
The module is intended for:
Integrated sensor:
Typical measurements:
| Parameter | Typical Accuracy |
|---|---|
| Temperature | ±0.2 °C |
| Humidity | ±1.8 %RH |
The module connects to a host PC through USB-C and shows up as two interfaces at once. Both run the same SCPI commands and share one error queue:
| Interface | Use it for |
|---|---|
| USBTMC (USB488) | VISA / instrument software: USB0::0x1209::0x0001::<serial>::INSTR |
| CDC serial port | Terminals, pyserial, anything without VISA; no driver needed |
USB identification:
| Field | Value |
|---|---|
| VID:PID | 1209:0001 (pid.codes test ID, dev only) |
| Manufacturer | Nacho.works |
| Product | SCPI-TempIO v01 |
| Serial | 96-bit MCU unique ID, 24 hex characters |
The device appears as:
/dev/serial/by-id/usb-Nacho.works_SCPI-TempIO_v01_<serial>-if00It is a native USB device, so the baud rate and other serial settings are ignored; any value works.
VISA resource string:
USB0::0x1209::0x0001::<serial>::INSTRThe serial is the one returned by *IDN?. Some tools print the IDs in decimal: USB0::4617::1::<serial>::0::INSTR is the same instrument.
What USBTMC adds over the serial port:
viClear): drops a half-sent command and any unread responseviReadSTB): bit 4 MAV = response waiting, bit 2 EAV = error queue not emptyHost setup:
Windows / macOS: install NI-VISA or Keysight IO Libraries, they include the USBTMC driver.
Linux: works with pyvisa + pyvisa-py (pip install pyvisa pyvisa-py pyusb). Install the udev rule once so a normal user can open the device and the kernel usbtmc driver does not claim it:
sudo cp examples/99-scpi-tempio.rules /etc/udev/rules.d/
sudo udevadm control --reloadThen replug the unit. Without the rule, pyvisa lists the device but fails with Resource busy.
pyvisa-py (0.8) implements read/write/query on USB, but not read_stb() or clear(); those need NI-VISA or Keysight VISA. The firmware supports both.
The USBTMC interface is deliberately interface 0: pyvisa-py detaches the kernel driver from interface 0 when it opens a USB instrument, and would otherwise disconnect the serial port.
The module exposes 8 configurable GPIO pins, DIO0–DIO7 (MCU pins PA0–PA7).
Each pin can be configured as:
*RST)IMPORTANT:
GPIO pins are 3.3V logic only.Do not apply voltages above 3.3V.
Each GPIO pin includes a series protection resistor.
This improves tolerance against:
2×5 box header, 2.54 mm pitch. Top view, pin 1 top-left:
┌──────────────┐
3V3 ■ 1 2 ● DIO0
DIO1 ● 3 4 ● DIO2
DIO3 ● 5 6 ● DIO4
DIO5 ● 7 8 ● DIO6
DIO7 ● 9 10 ● GND
└──────────────┘Pin 1 (3V3) has the square pad on the bottom side and the triangle mark on the header housing. The pins alternate between the two rows: odd pins in one row, even pins in the other. DIO0 sits right next to 3V3, and GND is in the opposite corner.
| Pin | Function |
|---|---|
| 1 | 3V3 |
| 2 | DIO0 |
| 3 | DIO1 |
| 4 | DIO2 |
| 5 | DIO3 |
| 6 | DIO4 |
| 7 | DIO5 |
| 8 | DIO6 |
| 9 | DIO7 |
| 10 | GND |
Shared with the on-board SHT41 bus (pull-ups on board).
| Pin | Function |
|---|---|
| 1 | 3V3 |
| 2 | SCL |
| 3 | SDA |
| 4 | GND |
Commands are ASCII text terminated by \n or \r\n. Responses end with \n.
Headers are case-insensitive and accept both the short and the long form, for example MEAS:TEMP? and measure:temperature? are the same query.
Several commands can be sent on one line, separated by ;. Each command must be written out in full (MEAS:TEMP?;MEAS:HUM?); the responses come back on one line, also separated by ;.
Examples:
*IDN?
MEAS:TEMP?
DIG:PIN0 1| Command | Description |
|---|---|
*IDN? | Identification |
*RST | Reset: all GPIO pins back to input |
*CLS | Clear the error queue |
*OPC? | Always returns 1 |
*TST? | Self test: 0 = SHT41 found, 1 = not found |
SYSTem:ERRor[:NEXT]? | Read and remove the oldest error |
SYSTem:VERSion? | SCPI version, 1999.0 |
MEASure:TEMPerature? | Temperature in °C |
MEASure:HUMidity? | Relative humidity in %RH |
MEASure:ALL? | temperature,humidity |
DIGital:PIN<n>:MODE IN|OUT|OD | Set pin mode |
DIGital:PIN<n>:MODE? | Read pin mode |
DIGital:PIN<n> 0|1|OFF|ON | Set output level |
DIGital:PIN<n>? | Read pin level |
DIGital:PIN<n>:PWM <freq>[,<duty>] | Start PWM output |
DIGital:PIN<n>:PWM? | Actual frequency and duty |
DIGital:PORT? | Read all 8 pins |
<n> is 0–7.
*IDN?Example response:
Nacho.works,SCPI-TempIO v01,2038393741565017002D005E,0.3Format:
MANUFACTURER,MODEL,SERIAL,FIRMWARE_VERSIONEvery query starts a new high-precision measurement (~10 ms).
If the sensor does not respond, the value is returned as 9.91E37 (SCPI "not a number") and error -240 is queued.
MEAS:TEMP?Example response:
23.41Units:
°CMEAS:HUM?Example response:
45.72Units:
%RHMEAS:ALL?Example response:
23.41,45.72Format:
TEMPERATURE,HUMIDITYBoth values come from the same measurement.
DIG:PIN0:MODE INDIG:PIN0:MODE OUTDIG:PIN0:MODE ODDIG:PIN0:MODE?Example response:
OUTDIG:PIN0 1DIG:PIN0 0The level is remembered while a pin is an input, and is applied when the pin is switched to OUT or OD. This lets you set the level first and then enable the output without a glitch.
DIG:PIN0?Example response:
1This reads the actual pin level, in every mode.
Each DIO pin can output a hardware PWM signal, generated by a timer in the MCU. It is exact and jitter-free, and keeps running without further USB traffic.
DIG:PIN0:PWM 1000 1 kHz, 50 % duty
DIG:PIN0:PWM 2.5MHZ,25 2.5 MHz, 25 % duty
DIG:PIN4:PWM 0.5,10% 0.5 Hz, 10 % duty
DIG:PIN0:PWM? actual frequency,duty, e.g. 1000,50
DIG:PIN0:MODE OUT stop PWM, back to normal outputHZ, KHZ or MHZ (SCPI MHZ is megahertz).DIG:PIN<n>:MODE? returns PWM while PWM is running. DIG:PIN<n>:MODE IN|OUT|OD or *RST stops it.DIG:PIN<n>:PWM? returns what is actually generated. At high frequencies the duty resolution gets coarse: at 32 MHz only 0, 50 and 100 % are possible.Pins that share a timer also share the frequency:
| Timer | Pins | Shared |
|---|---|---|
| TIM2 | DIO0, DIO1, DIO5 | Frequency; DIO0 and DIO5 also share the duty (same channel) |
| TIM15 | DIO2, DIO3 | Frequency |
| TIM14 | DIO4 | — |
| TIM16 | DIO6 | — |
| TIM17 | DIO7 | — |
Setting a different frequency on a pin whose timer is already in use gives error -221; stop the other pin first or use the same frequency.
DIG:PORT?Example response:
10100110The first character is DIO7 and the last is DIO0. In the example above, DIO1, DIO2, DIO5 and DIO7 are high.
Errors are queued (up to 8) and read one at a time with SYST:ERR?. 0,"No error" means the queue is empty.
| Code | Meaning |
|---|---|
| -108 | Parameter not allowed |
| -109 | Missing parameter |
| -113 | Undefined header (unknown command) |
| -114 | Header suffix out of range (pin number not 0–7) |
| -120 | Numeric data error (number expected) |
| -131 | Invalid suffix (unit other than HZ, KHZ, MHZ) |
| -221 | Settings conflict (PWM timer shared with another pin) |
| -222 | Data out of range (PWM frequency or duty) |
| -223 | Too much data (response line too long) |
| -224 | Illegal parameter value |
| -240 | Hardware error (SHT41 not responding) |
| -350 | Queue overflow |
| -363 | Input buffer overrun (command line over 127 characters) |
| LED | Meaning |
|---|---|
| Blinking (2 Hz) | Not enumerated by a USB host |
| On | Enumerated, ready |
| Short off-flick | A command was received |
| Fast blink (2 s) | Identify request (USBTMC indicator pulse) |
The module includes a 10-pin 1.27 mm Cortex debug connector.
Signals:
| Signal | Description |
|---|---|
| SWDIO | Debug data |
| SWCLK | Debug clock |
| NRST | Reset |
| VTref | Target voltage |
| GND | Ground |
Compatible programmers:
Notes:
Toolchain:
firmware/tempio.ioc, toolchain set to CMake)firmware/lib/tinyusb)Source layout:
| Path | Contents |
|---|---|
firmware/App/ | Application code (SCPI, SHT41, DIO, USB CDC + USBTMC) |
firmware/App/Inc/version.h | Manufacturer, model and firmware version |
firmware/Src, firmware/Inc | CubeMX generated code |
Application code lives in App/ and is called from main.c inside the USER CODE sections, so regenerating from CubeMX keeps it.
USB is deliberately left disabled in CubeMX. TinyUSB drives the peripheral, and App/Src/usb_hw.c sets up the USB clock (HSI48 trimmed by the CRS, no crystal needed) and the interrupt handler.
git submodule update --init
cd firmware
cmake -S . -B build/Debug -G "Unix Makefiles" \
-DCMAKE_TOOLCHAIN_FILE=cmake/gcc-arm-none-eabi.cmake -DCMAKE_BUILD_TYPE=Debug
cmake --build build/Debugarm-none-eabi-gcc must be on the PATH. With Ninja installed, cmake --preset Debug also works.
STM32_Programmer_CLI -c port=SWD mode=UR -w build/Debug/tempio.elf -v -rst| Parameter | Value |
|---|---|
| USB input voltage | 5V |
| Logic voltage | 3.3V |
| GPIO voltage range | 0–3.3V |
| GPIO direction | Configurable |
| MCU | STM32G0B1KBTx |
| Sensor | SHT41 |
Do not:
For inductive loads:
examples/tempio_demo.py connects to the unit and runs every command once:
pip install pyserial
python3 examples/tempio_demo.py # auto-detect on Linux/macOS
python3 examples/tempio_demo.py COM5 # or give the portMinimal VISA version:
import pyvisa
rm = pyvisa.ResourceManager() # '@py' for pyvisa-py
print(rm.list_resources())
inst = rm.open_resource('USB0::0x1209::0x0001::2038393741565017002D005E::INSTR')
print(inst.query('*IDN?'))
print(inst.query('MEAS:ALL?'))
inst.write('DIG:PIN0:MODE OUT')
inst.write('DIG:PIN0 1')Minimal serial version:
import serial
s = serial.Serial('/dev/ttyACM0', timeout=1)
s.write(b'*IDN?\n')
print(s.readline().decode())
s.write(b'MEAS:TEMP?\n')
print(s.readline().decode())
s.write(b'DIG:PIN0:MODE OUT\n')
s.write(b'DIG:PIN0 1\n')| Revision | Description |
|---|---|
| 1.0 | Initial draft |
| 1.1 | Firmware 0.1: USB CDC SCPI, SHT41, GPIO; MCU corrected to STM32G0B1 |
| 1.2 | Firmware 0.2: added USBTMC/USB488 interface (VISA) next to CDC |
| 1.3 | Firmware 0.3: PWM output on all DIO pins; hardware v0.01 production warning |
| Qty | Value | Footprint | References |
|---|---|---|---|
| 8 | 330 | Resistor_SMD:R_0402_1005Metric | R14, R15, R16, R17, R18, R19, R20, R21 |
| 3 | 100n | Capacitor_SMD:C_0805_2012Metric | C5, C6, C9 |
| 2 | 10k | Resistor_SMD:R_0402_1005Metric | R23, R24 |
| 2 | 22 | Resistor_SMD:R_0402_1005Metric | R12, R13 |
| 2 | 5.1k | Resistor_SMD:R_0402_1005Metric | R10, R11 |
| 2 | Conn_01x04_Pin | Connector_PinSocket_1.00mm:PinSocket_1x04_P1.00mm_Vertical | J4, J5 |
| 1 | 1000 | Resistor_SMD:R_0402_1005Metric | R9 |
| 1 | 1u | Capacitor_SMD:C_0805_2012Metric | C7 |
| 1 | 4.7n | Capacitor_SMD:C_0805_2012Metric | C8 |
| 1 | AP2112K-3.3 | Package_TO_SOT_SMD:SOT-23-5 | U2 |
| 1 | Conn_02x05_Counter_Clockwise | Connector_IDC:IDC-Header_2x05_P2.54mm_Vertical | J2 |
| 1 | Conn_ARM_JTAG_SWD_10 | Connector_PinHeader_1.27mm:PinHeader_2x05_P1.27mm_Vertical_SMD | J1 |
| 1 | LED | LED_SMD:LED_0402_1005Metric | D1 |
| 1 | LOGO | LOGO | G*** |
| 1 | SHT4x | Sensor_Humidity:Sensirion_DFN-4_1.5x1.5mm_P0.8mm_SHT4x_NoCentralPad | U3 |
| 1 | STM32G070KBTx | Package_QFP:LQFP-32_7x7mm_P0.8mm | U1 |
| 1 | SW_SPST | Button_Switch_SMD:SW_Push_1P1T_NO_CK_KSC7xxJ | SW1 |
| 1 | USB_C_Receptacle_USB2.0_16P | Connector_USB:USB_C_Receptacle_G-Switch_GT-USB-7025 | J3 |

FrameworkComputer/ExpansionCards
Reference designs and documentation to create Expansion Cards for the Framework Laptop



DDeGonge/OS-ARM
This arm is not industrial and it will not be fast, but that is not my goal. But it will hopefully be a very nice looking arm fully capable of 6dof motion, cheap enough to keep it accessable but capable enough to…




It measures 42.6 × 22.2 mm and has 2 copper layers, 1.6 mm thick.
31 parts, built around the AP2112K-3.3. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.
From the kerstensrobin/scpi-tempio repository on GitHub, at the commit this page was made from: the board is hardware/SCPI_tempIO.kicad_pcb and its schematic hardware/SCPI_tempIO.kicad_sch. PCBKit opens the board in the browser, with nothing to install.
Its repository publishes it under the GPL-3.0 licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).