Random numbers are very important to us in this computer age, being used for all sorts of security and cryptographic tasks. [Theory to Thing] recently built a device to generate random numbers using nothing more complicated than simple camera noise.
The heart of the build is an ESP32 microcontroller, which [Theory to Thing] first paired with a temperature sensor as a source of randomness. However, it was quickly obvious that a thermocouple in a cup of tea wasn’t going to produce nice, jittery, noisy data that would make for good random numbers. Then, inspiration struck, when looking at vision from a camera with the lens cap on. Particularly at higher temperatures, speckles of noise were visible in the blackness—thermal noise, which was just what the doctor ordered.
Thus, the ESP32 was instead hooked up to an OV3660 camera, which was then covered up with a piece of black electrical tape. By looking at the least significant bits of the pixels in the image, it was possible to pick up noise when the camera should have been reporting all black pixels. [Theory to Thing] then had the ESP32 collate the noisy data and report it via a web app that offers up randomly-generated answers to yes-or-no questions.
[Theory to Thing] offers up a basic statistical exploration of bias in the system, and shows how it can be mitigated to some degree, but we’d love a deeper dive into the maths to truly quantify how good this system is when it comes to randomness. We’ve featured deep dives on the topic before. Video after the break.

This is more or less how Lavarand (both the original SGI version and the current Cloudflare version) work – the amount of entropy from the lava lamp images is minimal compared to the amount of entropy that comes from the low-level sensor noise, and in the case of the SGI original it didn’t even look at anything more than the least-significant bit anyway.
I did this a while back with the raw data from the sensor in an optical mouse, although any gradient in the surface skewed the randomness in a particular direction, when preforming a random walk based on the data.
if you have a esp32 use one of the many random functions that use the wifi noise for random bits. It’s been shown to pass the NIST test, is cheap and easy to do and is random enough for just about anything.
ie https://ieeexplore.ieee.org/document/10809333 was testing one such implementation.
And yes, testing for randomness is hard.
Cool idea. I guess someone could wrap the mcu in copper tape or blast it to saturation though to bypass it. Unless some of the process involves internal noise on the board itself. I should probably just read the paper.
It likely uses the noise from the WiFi antenna which would include components on the board like amplifiers, filters, even just traces, etc.
“pass the NIST test” means very little – counter fed into SHA1 will pass NIST test (heck even into MD5) but is not random at all
one key feature for RNGs with physical entropy source is also if it can be influenced from the outside and if it can detect such influence, or any other failure mode – for example what happens if the HW entropy source fails in a way that instead of noise it start to output constant value
very good source of information about design of RNGs if you don’t have reliable hardware entropy source is here https://www.chronox.de/lrng/releases/v54/lrng-v54.pdf (Stephan Müller – Linux /dev/random – A New Approach)
in the end, RNGs are cryptography – and rule #1 of cryptography applies here as well (you should never program the encryption algorithms yourself – unless you actually really know what you are doing)
Noise is one of those weird things. I bet for 99% of hobby applications this is a perfectly reasonable entropy source. the noise likely has some dependence on temperature so it’s smart to lean in on the lsb but I don’t know if this is a fair distribution to draw from. So if someone dunked your ccd into a dewer of liquid nitrogen, or more easily plucked the tape off and shined their cellphones flashlight on it they could get all 0s or all 1s. I guess at that point there’s easier things they could do too.
I’ve seen a lot of elaborate suggestions to generating random numbers. My personal favorite is the diode. At the breakdown voltage they, by the laws of physics, generate truly random numbers. Some microcontrollers even offer this as an entropy source. Maybe they are backdoored or something, but if your source isn’t connecting to the Internet or Bluetooth, at the hardware level, you are probably good to go. Unless your OS is owned, then you need an anti interdiction delivery of a clean air gapped device.
Random numbers fascinate me
“However, it was quickly obvious that a thermocouple in a cup of tea wasn’t going to produce nice, jittery, noisy data that would make for good random numbers”
“The principle of generating small amounts of finite improbability by simply hooking the logic circuits of a Bambleweeny 57 Sub-Meson Brain to an atomic vector plotter suspended in a strong Brownian Motion producer (say a nice hot cup of tea) were well understood.”
I guess random numbers are not improbable, or at least not finitely improbable.
I guess you don’t get invited to that kind of party either! 🤓
There is a huge security risk, with time and heat the tape will fell off, and I’m sure it will die in a few years, you can do a lot better with specialised HW.
How about using Coal-tar pitch instead of tape. And maybe mix in a bit of potassium chloride (lo-salt) to randomly hit pixels with gamma rays at 1461 keV.
I’m guessing this will come into use during “What’s that sound”
You are not the only person who thought this! :)
Couldn’t randomness be significantly improved, if a laser with a small air gap (Laserspeckle) is pointed at it?
It’s harder to do it that way. Laser diodes slowly die over time, and drift with temperature. Also only the shortest exposures and duty cycles would not completely saturate the detector.
Although scattering from rough surfaces is a stochastic process you might be surprised at how there is still structure to most hobby attempts. Again this is probably fine for 99% of home use cases, there could be patterns over time depending on what the scattering element is.
I would love to see an attempt at it with a rigorous analysis. It might be possible if the rng process is derived from spatial considerations moreso than intensity.