This project is about USB port base true hardware random number generator and it is design around the avalanche noise which occurred in reversed biased P-N junction.

This random number generator is design using commonly available electronic components. The core component of this system is Microchip’s PIC18F2550 microcontroller. The noise source is 2N3904 (Q1) transistor and LM386 low voltage power amplifier is used to amplify the incoming noise signals. This peripheral is design to work as a self-powered USB HID device.

Cumulative distribution graph of random number sample

In this design we use 2N3904 as a noise source because it give more noise amplitude than any another transistors which we tested. Theoretically this transistor (Q1) can be replaced with any other suitable NPN transistor like BC548, BC107, 2SC945, etc.

The control software of this system is available for Linux and it’s compiled as x86 - 32bit binary file. This controller application required libusb driver and it can be obtain from The control software of this system is available for Linux and it is tested with Ubuntu 13.04 - i686 distribution. This software can be executed with or without command line parameters. If end user specifies the command line parameters then it operates in silent mode and generates the output.

Command line syntax:
randgen <number of samples>

Example 1:
sudo randgen 500

The above example may generate 500 random numbers in silent mode.

Example 2:
sudo randgen 6000 > output.csv

Above example may generate 6000 random numbers and write them into "output.csv" file.

Interactive mode command line syntax:

Example 3:
sudo randgen
Enter the amount of random numbers: 500

After the above user input application may generate 500 random numbers.

The valid output range of this random number generator is around 10000 to 41000. This output range is fixed and its distribution graph is available with the project package.

This USB random number generator is design as an open hardware project. All the electronic designs of this project are licensed under the Creative Commons Attribution 3.0 Unported License. To view a copy of this license, visit All the software source codes are licensed under the terms of MIT license.

Project Related Downloads

Complete schematics, source codes and data files of USB Random Number Generator


PIC18F2550 - High-Performance, Enhanced Flash, USB Microcontrollers with nanoWatt Technology
MC34063 - Step-Up/Down/Inverting Switching Regulator
LM386 - Low Voltage Audio Power Amplifier
2N3904 - Small Singal NPN Transistor
libusb - C library to access USB devices on many different operating systems