Intro
MicroRNG is a hardware true random number generator that can be used in embedded systems as a reliable entropy source. It connects to microcontrollers and single-board computers through a mikroBUS socket using SPI or a 2-wire UART interface, and generates random numbers at up to 1 Mbps in SPI mode and up to 1.5 Mbps in UART mode.
Hardware requirements
- Raspberry Pi 3+ or 4
- An expansion board with a mikroBUS socket, such as the ‘PI2 Click Shield’ or similar, as shown in the picture below

Operating system requirements
- Ubuntu Server 18.04 (32-bit or 64-bit) for Raspberry Pi
- or Ubuntu Server 20.04 (32-bit or 64-bit) for Raspberry Pi
- or Raspbian
Downloading the software kit
The MicroRNG software kit does not include binaries for Linux, so you will need to download the source code and build the utilities and components. Download the latest release, or clone the repository with git:
git clone https://github.com/tectrolabs/microrng.git
Change to the source code directory:
cd microrng/mcrng
Prerequisites
Make sure make and g++ are installed before running the build.
On Ubuntu, run the following commands to install the required dependencies:
sudo apt-get update
sudo apt-get install make
sudo apt-get install g++
Building utilities and components
To build and install the utilities, run the following commands:
make
sudo make install
Verifying communication with the MicroRNG
Connect the MicroRNG to the target board through the SPI interface, then verify device connectivity with the following command (you may need to use a device path specific to your target board):
sudo mcdiag /dev/spidev0.0
The output should look similar to this:
~/microrng/mcrng$ sudo mcdiag /dev/spidev0.0
-------------------------------------------------------------------
--- TectroLabs - mcdiag - MicroRNG diagnostics utility Ver 1.0 ---
--- Use with RPI 3+ or other Linux-based single-board computers ---
-------------------------------------------------------------------
Opening device /dev/spidev0.0 ----------------------------- Success
Identifying device /dev/spidev0.0 -------------- MicroRNG detected
Identifying maximum SPI clock frequency --------------- 31000000 Hz
New SPI clock frequency ------------------------------- 31000000 Hz
Retrieving 32000 random bytes ----------------------------- Success
Retrieving 32000 RAW random bytes ------------------------- Success
Retrieving 32000 random bytes ----------------------------- Success
Shutting down RNG ----------------------------------------- Success
Starting RNG up ------------------------------------------- Success
Computing SPI transfer speed ---------------------------- 497 kbps
Validating MicroRNG internal status ---------------------- Healthy
Downloading random numbers from the MicroRNG
Random numbers are retrieved with the provided mcrng utility. For example, to retrieve 120000 true random bytes from the MicroRNG into the file rnd.bin at an SPI clock frequency of 20000 kHz, run the following command:
sudo mcrng -dd -fn rnd.bin -nb 120000 -cf 20000