Skip to the content
2 layers42.6 × 22.2 mmScpi tempio, the printed circuit board in 3D

a simple SCPI compatible module containing some temperature and IO capabilities

Size
42.6 × 22.2 mm
Copper layers
2
Thickness
1.6 mm
Parts
31
Nets
52
Pads
137
Tracks, vias
281, 35
Pours
3
Routed
Yes
KiCad
KiCad 10.0 (file 20260206)
Created
26 May 2026
Updated
25 Sep 2026

Overview

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.

Main components

1

README

README.md

Nacho.works SCPI-TempIO

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:

  1. 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.
  2. 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.
  3. U1 symbol still named STM32G070KBTx in the schematic's symbol cache; the fitted part is the STM32G0B1KBT6.
  4. 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.


Repository Contents

PathContents
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)

Overview

This module is a small USB-connected development and test interface based on the STM32G0B1KBTx microcontroller.

It provides:

  • USB serial SCPI interface
  • Temperature measurement
  • Humidity measurement
  • 8 configurable GPIO pins
  • I2C expansion connectors
  • Breadboard-friendly operation
  • SWD programming/debug interface

The module is intended for:

  • breadboard prototyping
  • embedded testing
  • automation experiments
  • SCPI/VISA software integration
  • GPIO scripting from a PC

Features

Environmental sensing

Integrated sensor:

  • SHT41 temperature + humidity sensor (I2C1, address 0x44)

Typical measurements:

ParameterTypical Accuracy
Temperature±0.2 °C
Humidity±1.8 %RH

USB interface

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:

InterfaceUse it for
USBTMC (USB488)VISA / instrument software: USB0::0x1209::0x0001::<serial>::INSTR
CDC serial portTerminals, pyserial, anything without VISA; no driver needed

USB identification:

FieldValue
VID:PID1209:0001 (pid.codes test ID, dev only)
ManufacturerNacho.works
ProductSCPI-TempIO v01
Serial96-bit MCU unique ID, 24 hex characters

The device appears as:

  • COMx on Windows
  • /dev/ttyACMx on Linux, also as /dev/serial/by-id/usb-Nacho.works_SCPI-TempIO_v01_<serial>-if00
  • /dev/cu.usbmodem* on macOS

It is a native USB device, so the baud rate and other serial settings are ignored; any value works.

VISA (USBTMC)

VISA resource string:

text
USB0::0x1209::0x0001::<serial>::INSTR

The 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:

  • Found by VID/PID/serial, independent of COM port or ttyACM numbering
  • Explicit message boundaries, no line-termination guessing
  • Device clear (viClear): drops a half-sent command and any unread response
  • Status byte (viReadSTB): bit 4 MAV = response waiting, bit 2 EAV = error queue not empty
  • Indicator pulse ("identify" in NI MAX): the LED blinks fast for 2 s

Host 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:

    sh
    sudo cp examples/99-scpi-tempio.rules /etc/udev/rules.d/
    sudo udevadm control --reload

    Then 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.


GPIO Interface

The module exposes 8 configurable GPIO pins, DIO0–DIO7 (MCU pins PA0–PA7).

GPIO capabilities

Each pin can be configured as:

  • Digital input (default after power-up and *RST)
  • Digital output (push-pull)
  • Open-drain output
  • PWM output (hardware timer, 0.1 Hz to 32 MHz)

GPIO voltage levels

IMPORTANT:

text
GPIO pins are 3.3V logic only.

Do not apply voltages above 3.3V.

GPIO protection

Each GPIO pin includes a series protection resistor.

This improves tolerance against:

  • accidental shorts
  • output contention
  • breadboard wiring mistakes

Connector Pinout

GPIO Header (J2)

2×5 box header, 2.54 mm pitch. Top view, pin 1 top-left:

text
          ┌──────────────┐
  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.

PinFunction
13V3
2DIO0
3DIO1
4DIO2
5DIO3
6DIO4
7DIO5
8DIO6
9DIO7
10GND

I2C Expansion (J4, J5)

Shared with the on-board SHT41 bus (pull-ups on board).

PinFunction
13V3
2SCL
3SDA
4GND

SCPI Command Interface

General

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:

text
*IDN?
MEAS:TEMP?
DIG:PIN0 1

Supported Commands

CommandDescription
*IDN?Identification
*RSTReset: all GPIO pins back to input
*CLSClear 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|ODSet pin mode
DIGital:PIN<n>:MODE?Read pin mode
DIGital:PIN<n> 0|1|OFF|ONSet 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.


Identification

Query device identification

text
*IDN?

Example response:

text
Nacho.works,SCPI-TempIO v01,2038393741565017002D005E,0.3

Format:

text
MANUFACTURER,MODEL,SERIAL,FIRMWARE_VERSION

Environmental Measurements

Every 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.

Temperature measurement

text
MEAS:TEMP?

Example response:

text
23.41

Units:

text
°C

Humidity measurement

text
MEAS:HUM?

Example response:

text
45.72

Units:

text
%RH

Combined measurement

text
MEAS:ALL?

Example response:

text
23.41,45.72

Format:

text
TEMPERATURE,HUMIDITY

Both values come from the same measurement.


GPIO Commands

Configure GPIO mode

Input mode

text
DIG:PIN0:MODE IN

Output mode

text
DIG:PIN0:MODE OUT

Open-drain mode

text
DIG:PIN0:MODE OD

Read mode

text
DIG:PIN0:MODE?

Example response:

text
OUT

Set GPIO output state

Set HIGH

text
DIG:PIN0 1

Set LOW

text
DIG:PIN0 0

The 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.


Read GPIO state

text
DIG:PIN0?

Example response:

text
1

This reads the actual pin level, in every mode.


PWM output

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.

text
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 output
  • Frequency: 0.1 Hz to 32 MHz, as a plain number in Hz or with HZ, KHZ or MHZ (SCPI MHZ is megahertz).
  • Duty: 0 to 100 %, default 50 %.
  • DIG:PIN<n>:MODE? returns PWM while PWM is running. DIG:PIN<n>:MODE IN|OUT|OD or *RST stops it.
  • The timer rounds to the nearest reachable setting; 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.
  • Signal quality: the 330 Ω series resistor and the probe or cable capacitance round the edges. Expect a clean square wave up to roughly 5–10 MHz.

Pins that share a timer also share the frequency:

TimerPinsShared
TIM2DIO0, DIO1, DIO5Frequency; DIO0 and DIO5 also share the duty (same channel)
TIM15DIO2, DIO3Frequency
TIM14DIO4—
TIM16DIO6—
TIM17DIO7—

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.


Read all GPIO states

text
DIG:PORT?

Example response:

text
10100110

The first character is DIO7 and the last is DIO0. In the example above, DIO1, DIO2, DIO5 and DIO7 are high.


Errors

Errors are queued (up to 8) and read one at a time with SYST:ERR?. 0,"No error" means the queue is empty.

CodeMeaning
-108Parameter not allowed
-109Missing parameter
-113Undefined header (unknown command)
-114Header suffix out of range (pin number not 0–7)
-120Numeric data error (number expected)
-131Invalid suffix (unit other than HZ, KHZ, MHZ)
-221Settings conflict (PWM timer shared with another pin)
-222Data out of range (PWM frequency or duty)
-223Too much data (response line too long)
-224Illegal parameter value
-240Hardware error (SHT41 not responding)
-350Queue overflow
-363Input buffer overrun (command line over 127 characters)

Status LED

LEDMeaning
Blinking (2 Hz)Not enumerated by a USB host
OnEnumerated, ready
Short off-flickA command was received
Fast blink (2 s)Identify request (USBTMC indicator pulse)

Programming and Debugging

SWD Interface (J1)

The module includes a 10-pin 1.27 mm Cortex debug connector.

Signals:

SignalDescription
SWDIODebug data
SWCLKDebug clock
NRSTReset
VTrefTarget voltage
GNDGround

Compatible programmers:

  • ST-Link V2
  • ST-Link V3

Notes:

  • The SWD cable does not power the board. Power it from USB.
  • With a Treedix JTAG/SWD adapter board, install the VCC→VREF jumper. Otherwise the ST-Link reads about 1.7 V (floating VTref) and will not connect.
  • On v0.01 boards, VTref (J1 pin 1) is routed to VBUS (5 V) instead of 3V3; see the warning at the top. Unless the board has been bodged, the ST-Link reports about 5 V target voltage and may drive SWD at that level. Bodge J1 pin 1 to 3V3 before connecting a programmer, or flash a blank board over USB DFU instead.
  • Put the scope or multimeter ground on J2 pin 10 (GND), never on pin 1 (3V3). A bench scope's ground is mains earth, which the PC's USB ground is also tied to, so clipping it onto 3V3 shorts the regulator output. On one v0.01 board this destroyed U2 (AP2112K), leaving the MCU running on 5 V.

Firmware Development

Toolchain:

  • STM32CubeMX for pin and clock configuration (firmware/tempio.ioc, toolchain set to CMake)
  • CMake + arm-none-eabi-gcc (the one bundled with STM32CubeIDE works)
  • STM32 HAL
  • TinyUSB 0.21.0 (git submodule in firmware/lib/tinyusb)
  • STM32CubeProgrammer CLI or any SWD tool for flashing

Source layout:

PathContents
firmware/App/Application code (SCPI, SHT41, DIO, USB CDC + USBTMC)
firmware/App/Inc/version.hManufacturer, model and firmware version
firmware/Src, firmware/IncCubeMX 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.

Build

sh
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/Debug

arm-none-eabi-gcc must be on the PATH. With Ninja installed, cmake --preset Debug also works.

Flash

sh
STM32_Programmer_CLI -c port=SWD mode=UR -w build/Debug/tempio.elf -v -rst

Electrical Specifications

ParameterValue
USB input voltage5V
Logic voltage3.3V
GPIO voltage range0–3.3V
GPIO directionConfigurable
MCUSTM32G0B1KBTx
SensorSHT41

Safety Notes

IMPORTANT

Do not:

  • connect GPIO pins directly to mains voltage
  • exceed 3.3V on GPIO pins
  • drive motors directly from GPIO pins
  • short outputs together intentionally

For inductive loads:

  • use transistors or MOSFETs
  • use flyback diodes

Example Python Usage

examples/tempio_demo.py connects to the unit and runs every command once:

sh
pip install pyserial
python3 examples/tempio_demo.py            # auto-detect on Linux/macOS
python3 examples/tempio_demo.py COM5       # or give the port

Minimal VISA version:

python
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:

python
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

RevisionDescription
1.0Initial draft
1.1Firmware 0.1: USB CDC SCPI, SHT41, GPIO; MCU corrected to STM32G0B1
1.2Firmware 0.2: added USBTMC/USB488 interface (VISA) next to CDC
1.3Firmware 0.3: PWM output on all DIO pins; hardware v0.01 production warning

Parts

31
QtyValueFootprintReferences
8330Resistor_SMD:R_0402_1005MetricR14, R15, R16, R17, R18, R19, R20, R21
3100nCapacitor_SMD:C_0805_2012MetricC5, C6, C9
210kResistor_SMD:R_0402_1005MetricR23, R24
222Resistor_SMD:R_0402_1005MetricR12, R13
25.1kResistor_SMD:R_0402_1005MetricR10, R11
2Conn_01x04_PinConnector_PinSocket_1.00mm:PinSocket_1x04_P1.00mm_VerticalJ4, J5
11000Resistor_SMD:R_0402_1005MetricR9
11uCapacitor_SMD:C_0805_2012MetricC7
14.7nCapacitor_SMD:C_0805_2012MetricC8
1AP2112K-3.3Package_TO_SOT_SMD:SOT-23-5U2
1Conn_02x05_Counter_ClockwiseConnector_IDC:IDC-Header_2x05_P2.54mm_VerticalJ2
1Conn_ARM_JTAG_SWD_10Connector_PinHeader_1.27mm:PinHeader_2x05_P1.27mm_Vertical_SMDJ1
1LEDLED_SMD:LED_0402_1005MetricD1
1LOGOLOGOG***
1SHT4xSensor_Humidity:Sensirion_DFN-4_1.5x1.5mm_P0.8mm_SHT4x_NoCentralPadU3
1STM32G070KBTxPackage_QFP:LQFP-32_7x7mm_P0.8mmU1
1SW_SPSTButton_Switch_SMD:SW_Push_1P1T_NO_CK_KSC7xxJSW1
1USB_C_Receptacle_USB2.0_16PConnector_USB:USB_C_Receptacle_G-Switch_GT-USB-7025J3

Similar boards

  • 2 layers26 × 30 mmMicrocontroller, the printed circuit board in 3D

    Microcontroller

    FrameworkComputer/ExpansionCards

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

    34 parts1.1kCC-BY-4.0
  • 2 layers53.2 × 24.8 mmPicoLink, the printed circuit board in 3D

    PicoLink

    ErichStyger/mcuoneclipse

    McuOnEclipse projects and examples

    46 parts765
  • 2 layers36 × 20 mmCombined, the printed circuit board in 3D

    Combined

    adamb314/ServoProject

    Getting the most out of your hobby servo

    24 parts545
  • 2 layers25 × 25 mmSmallEncoder, the printed circuit board in 3D

    SmallEncoder

    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…

    17 parts498MIT
  • 4 layers70 × 72 mmSPINC AA Charger, the printed circuit board in 3D

    SPINC AA Charger

    CoretechR/SPINC

    DIY Automatic Battery Charger Using RP2040

    101 parts467GPL-3.0
  • 4 layers60.8 × 61.3 mmOS3M Mouse, the printed circuit board in 3D

    OS3M Mouse

    spoter368/os3m-hardware

    All the hardware needed to build your own OS3M Mouse!

    51 parts399
  • 4 layers74 × 104 mmBeepy, the printed circuit board in 3D

    Beepy

    sqfmi/beepy-hardware

    Beepy Hardware

    160 parts348MIT

Questions

How big is the Scpi tempio PCB?

It measures 42.6 × 22.2 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Scpi tempio use?

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.

Where can I download the Scpi tempio KiCad files?

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.

Can I use the Scpi tempio design in my own project?

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).