Entropy library

A new version (1.0.1) of the Entropy library is available.  You can obtain it from the Google Code site or for convenience you can download this zip file from here Entropy Library version 1.0.2

The new version includes a change from Paul Stoffregen that allows the library to run on his Teensy 3.x boards.

A library for AVR's or Arduino's that make use of the watchdog timer's natural jitter to produce a reliable stream of true random numbers.  Unlike other methods currently available, this library requires no external hardware and produces a considerably more random number stream than methods based upon the technique of reading an unconnected analog pin.


I first heard about the method on a thread at the Arduino forum.  The information on that thread caused me to begin experimenting with the method and finally conclude that it appears to be capable of producing cryptographically useful random numbers at best and the best source of unpredictable numbers on the Arduino platform at worst.

This library only works on those AVR chips that have a watchdog reset interrupt vector, as such this library will not work with an ATmega8 series of chips.  This library is a fully function integer based random number generator; however, if you only need to provide a good seed value to the internal random function a short example of how to use the same basic techniques as implemented in the library without the overhead inccurred can be found here.


This site will always contain the source for the latest version of the library in the Source tab as well as a zip file containing the most current tested version of the library in the Downloads tab.  The library is designed to be installed as a typical Arduino library (see Arduino reference manual for details) or included in a c++ project file for normal AVR development.

Test Sketch

#include <Entropy.h>

void setup()
  Serial.begin(115200);        // Speed doesn't really matter given the slow generation rate 8 bytes/sec

void loop()

Test Results

While testing is an ongoing (and much needed) activity, to date this generator has been tested on all major Arduino platforms, as well as several other AVR chips such as the ATtiny85, ATmega1284P, and the AT90USB1287.  Performance data is available on this site, in the Source/Entropy/tests directory,  to facilitate decisions on whether the library is suitable for a particular use.  A spreadsheet containing the results of the basic testing performed on a number of different chips is available