Skip to the content
2 layers74 × 63.2 mmRNG, the printed circuit board in 3D

A spicy little quantum TRNG that pushes out MQTT

Size
74 × 63.2 mm
Copper layers
2
Thickness
1.6 mm
Parts
30
Nets
66
Pads
152
Tracks, vias
154, 39
Pours
2
Routed
Yes
KiCad
KiCad 7 (file 20221018)
Created
4 Apr 2025
Updated
3 May 2025

Overview

RNG is an open-source printed circuit board by seanboyce, from the seanboyce/TRNG repository on GitHub. It is a 2-layer board of 74 × 63.2 mm with 30 parts on 66 nets, routed with 154 tracks and 39 vias.

It is built around the ATTINY261A-PU, MT3608 and SC0918. Its parts include 7 capacitors, 6 resistors, 3 ICs, 2 transistors and 2 connectors. It belongs with the home automation and IoT boards and the AVR (ATmega, ATtiny) boards of this library.

Main components

3

README

README.md

Function

This circuit is designed to output random bytes out MQTT, each as a message. It works at 8-10k bytes per second depending on system voltage and the fact that the bitrate of the entropy source is variable by nature.

What? Why? You could just use a seed phrase and standard cryptography

Yeah, that works fine and there's no real disadvantage.

I've been designing various quantum TRNGs for nearly 15 years as part of an elaborate practical joke. This is just the latest one. I won't tell you what the joke is. Perhaps I'll never tell anyone.

The world could do with a little more whimsy and playful mystery right now, and this is just my little bit that I can share with you.

How it works

The core entropy source is two transistors in an unusual configuration. This is an old technique analogous to the classic "zener diode" method. It has the advantage of producing a slower signal, easier to sample. It outputs avalanche noise with heavy DC bias. There's some nice summary here.

We remove the DC component wth a capacitor, then use two hex inverters for amplification and pulse-shaping. The first hex inverter is running at ~12V and is configured as two inverting amplifiers -- this is really power inefficient and it gets a bit warm due to the digital part working in linear modes. A little heat sink is recommended.

This unusual use of the hex inverter is to reduce the parts count and cost -- I have a lot of hex inverters lying around. If you needed better power efficiency (e.g. for battery-powered use), you could use an op-amp. OPA132 is pretty easy to use.

The next hex inverter operates more or less digitally, just shaping the signal into a clean square wave. This one does not get warm.

After that, an Attiny261A acts as a Von Neumann extractor to convert the square wave into usable, unbiased bits of entropy.

The bytes are read by a Pi Pico W and pushed out MQTT. Basic authentication works. I didn't bother adding TLS.

It would be possible to just use the PIO of the Pi Pico instead of an Attiny261A. However, most of the time I don't actually want the Pi Pico or Wi-Fi, and am just using the entropy locally. If you wanted to do this, you would simply not populate the Attiny261A, and solder a wire between pin 9 of the Attiny socket, and whatever pin you want on the Pi Pico. That will bypass the Attiny261A and push the raw entropy signal directly to the Pi Pico. I would recommend writing your own Von Neumann extractor with the PIO.

How to build it

Notes on surface mount components

This design makes extensive use of surface-mount components. I have limited budget and time to spend on my hobbies, so I generally use the smallest possible SMT components to save both (standardize my parts library). If you find 0402 difficult to work with, then it's very fast to open up the KiCAD files in this repo, and replace all the 0402 resistors with 0603 in the schematic. Then just pull up the board design, update from the schematic, and touch up the routing -- you should be good to go, 0603 is pretty easy to hand-solder even without a hot air rework station and solder paste. A normal iron, coil of solder, and some patience will suffice.

If you want to redesign everything as through-hole, this will require a bit of a redesign. I would recommend purchasing a USB boost converter, not populating the integrated boost converter, and using the passthrough I've left you (J2). Then switch the CD4069 to the DIP version, and add in through-hole resistors and capacitors. I vaguely recall that the DIP version of the CD4069 has better thermal dissipation, you might be able to get away with a smaller heat sink or none at all -- I've gotten away without one in older designs (give it a careful test though).

Building the current design

I recommend building the boost converter first, then give it some power and make sure the output voltage is sane. Should be between 12 and 13 volts. Note that the EN pin of the MT3608 should be connected to Vin -- else nothing will output at all. I just bridge the middle pin of J1 to Vin.

Once that's in, I put in the transistors (mind polarity!), the first hex inverter, and all the resistors and capacitors around them. Then I supply power again, for a short time, with a scope connected to the output of the first hex inverter. The scope is set to be AC coupled. I should see a pretty looking signal with a lot of noise. Then I cut power -- that first hex inverter can get sort of hot with no heat sink attached.

Then I get the buck converter / LM7803 in, as well as the final hex inverter. Then I test as above (scope can be AC or DC coupled), making sure the signal from the second hex inverter is a weird looking, but mostly clean square wave ranging from 0 to 3.3V.

If that's good, I flash the program (main.asm) to an Attiny261A (using AVR-ICE, STK500 or home-made programmer). For the first few boards, I put in a socket for the AVR, so I can pull it out and update the firmware. Then I quickly check again, specifically that the "new output" pin of the Attiny261A is pushing out 10 usec pusles, and that bits are coming out of the pins of PORTA.

At this point, I just load the program (main.py) into the Pi Pico, disconnect it from the USB cable, and plug it in. The onboard LED should light up if it's receiving power, and flicker slightly if it's pushing out MQTT. If it doesn't flicker, try turning it off and on again, sometimes it can fail to connect to Wi-Fi.

DO NOT plug a USB cable into the Pi Pico while it is connected to this circuit It is being powered by 3.3V. USB is 5V. Several components are likely to make sad electronic noises, fail violently, and lose their magic blue smoke.

As for what part goes where? It's all in the KiCAD schematic. I would recommend giving it a detailed look.

The Von Neumann Extractor

This just measures two time intervals between 2 sets of 2 independent events (it could probably use 3 events instead of 4 to calculate 2 intervals, but whatever. It's much faster than fast enough now). If t1>t2, it records a 0. If t1<t2, it records a 1. If they are equal, it tries again.

I originally wrote this firmware ages ago. It was quite an experience to look at my ham-fisted assembly from 15 years ago. I redid it with many optimizations, which increased performance about 50x. Also it consumes less power. Use main.asm, not old_von_neumann.asm. Seriously, the latter is pretty awful.

I include both files, so that one day I may look back and consider both attempts primitive and silly. Got to keep that ego in check!

Photo

Note the black "bodge wire" near the USB power input. This was necessary because of an error in the original design files. The version in this repository has been corrected, and you won't need to cut any traces / add weird wires and so on.

photo of the trng

Parts

30
QtyValueFootprintReferences
4MountingHoleMountingHole:MountingHole_3.2mm_M3H1, H2, H3, H4
30.1uFCapacitor_SMD:C_0603_1608MetricC1, C2, C7
2100kResistor_SMD:R_01005_0402MetricR2, R3
222pFCapacitor_SMD:C_0603_1608MetricC5, C6
22N5551Package_TO_SOT_THT:TO-92Q1, Q2
24069customsoic:SOIC-14 5.4mm,
2CCapacitor_SMD:C_1206_3216MetricC3, C4
2RResistor_SMD:R_0402_1005MetricR5, R6
11kResistor_SMD:R_01005_0402MetricR4
120kResistor_SMD:R_01005_0402MetricR1
1ATtiny261A-PPackage_DIP:DIP-20_W7.62mmU6
1Conn_01x02_PinConnector_JST:JST_EH_B2B-EH-A_1x02_P2.50mm_VerticalJ2
1Conn_01x03_PinConnector_JST:JST_EH_B3B-EH-A_1x03_P2.50mm_VerticalJ1
1CrystalCrystal:Crystal_HC49-U_VerticalY1
1D_SchottkyDiode_SMD:D_SMBD1
1Lfiles:cd32L1
1LM7805_TO220Package_TO_SOT_THT:TO-220-3_VerticalU3
1MT3608Package_TO_SOT_SMD:SOT-23-6U5
1SC0918PiPico:MODULE_SC0918A1

Similar boards

  • 2 layers99.8 × 99.8 mmMy Motorola IO, the printed circuit board in 3D

    My Motorola IO

    lenzjo/MECB-SYS-IO

    I have brought out all available outputs along the top of the PCB, however, the PS/2 clock and data signals are also on the connector (pins C11 and A12 repectively) as are TxD (A16), RxD (A17), RTS (C16) and CTS (C19).

    37 parts1
  • 2 layers87.9 × 98.7 mmBitdoglab smd, the printed circuit board in 3D

    Bitdoglab smd

    BitDogLab/BitDogLab

    Open-source educational hardware for embedded systems, programming, electronics, and physical computing.

    138 parts203
  • 2 layers47.2 × 55.5 mmTinta l2, the printed circuit board in 3D

    Tinta l2

    c0de111/tinta

    Battery-powered e-paper sign: room signage, sensor graphs, home automation, or anything over Wi-Fi. Wakes by real-time clock, NFC tap, or button. Raspberry Pi Pico W firmware, custom PCB, and 3D-printed case included.

    60 parts39Apache-2.0
  • 2 layers87 × 84.1 mmOpenACE V0.0.2, the printed circuit board in 3D

    OpenACE V0.0.2

    gatasConspicuity/gatas

    eConspicuity with support for ADS-L, OGN, FLARM, FANET for General Aviation

    80 parts26GPL-3.0
  • 2 layers41 × 82.1 mmWater Meter PCB, the printed circuit board in 3D

    Water Meter PCB

    dgomes/pico_w_water_meter

    Water Meter using Raspberry Pico W

    6 parts24
  • 2 layers182 × 105 mmPocketComputerUniversalInterface, the printed circuit board in 3D

    PocketComputerUniversalInterface

    N1UGK/PCUI_Public

    Collection of Programs and Utilities for the Pocket Computer Universal Interface

    161 parts15
  • 2 layersG2-pico kicad, the printed circuit board in 3D

    G2-pico kicad

    skmp/g2-pico

    can pio haz g2 interface?

    4 parts6BSD-3-Clause
  • 2 layers111.2 × 110.3 mmBadge24, the printed circuit board in 3D

    Badge24

    thestumbler/supercon24-badge-kicad-redrawn

    Redrawing the Hackaday Supercon 2024 Badge in KiCad

    23 parts5

Questions

How big is the RNG PCB?

It measures 74 × 63.2 mm and has 2 copper layers, 1.6 mm thick.

What parts does the RNG use?

30 parts, built around the ATTINY261A-PU, MT3608 and SC0918. 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 RNG KiCad files?

From the seanboyce/TRNG repository on GitHub, at the commit this page was made from: the board is KiCAD/RNG.kicad_pcb and its schematic KiCAD/RNG.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the RNG design in my own project?

Its repository states no licence, so its author keeps all rights: ask seanboyce before reusing the design.