Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Random Number Generator with NRF24LE1 (Part 8/14)

By Amanpreet Singh November 14, 2021

Random Number Generator with NRF24LE1

Random number sometimes plays an important role in our life. Think of a lottery ticket you have purchased. Now what if a random number taken out of lottery lot matches your ticket number? We will be glad if that happens. Random number generators are also used in making games more puzzling and non-deterministic. Do you know microcontrollers too can generate random number? Today we are going to discuss an interesting feature of NRF24LE1 which is Random Number Generator (RNG). 
The NRF24LE1 contains a thermal noise based Random Number Generator which produces non-deterministic sequence. For making it more powerful and random we can use a digital corrector algorithm which removes any bias towards 0 or 1. This is also an inbuilt feature. RNG generates an 8-bit number which is stored in 8-bit register. So the range of number will be 0 – 255.
Some features of RNG are:
• Number generation rate up to 10 kilobytes per second
• Non-repeating sequence
• Works even when NRF is in standby mode
• No initial input vale required for generation (Self generation)
• Thermal noise based non-deterministic architecture
The RNG is controlled by two registers:
1. RNGCTL (Random Number Generator Control) register- It is an 8-bit register. The purpose of various bits are:
• Bit 7 – used to power up RNG
• Bit 6 – used to enable bias corrector
• Bit 5 – generation completed flag. 1 : Data Ready
• Bit 4:0 – not used
2. RNGDAT (Random Number Generator Data) register – It is an 8-bit register which sores the generated number.
Prototype of NRF24LE1 Module based Random Number Generator
Fig. 1: Prototype of NRF24LE1 Module based Random Number Generator
We will now cover the process of RNG in simple steps.
• First we have to start the generator. For that we have to write 1 to bit 7 of RNGCTL.
• If we want to enable bias corrector we can write 1 to bit 6 of RNGCTL.
• We can check if the number has been generated by reading bit 5 RNGCTL.  An interrupt RNGIRQ is also produced after successful generation. It takes about 0.1 mS to generate a number when bias corrector is disabled and four times as long when corrector is enabled. Also it takes about 0.25 ms for the first time generation after RNG is powered up.
• The generated one byte data can be accessed through RNGDAT register.
We can also use functions provided by Nordic libraries:
Table Listing Functions of NRF24LE1 Wireless Module
Fig. 2: Table Listing Functions of NRF24LE1 Wireless Module
Function Input Parameter Output Description
hal_rng_power_up() 0/1 – To power the RNG
0:OFF
1:ON
hal_rng_bias_corr_enable() 0/1 – To use bias corrector
0:Disable
1:Enable
hal_rng_read() – 8-bit data To read the generated number
hal_rng_data_ready() – 0/1 To check the status of RNG
0:Data not ready
1:Data ready
Image of NRF24LE1 Module based Random Number Generator
Fig. 3: Image of NRF24LE1 Module based Random Number Generator
We have written a code to make users understand its working. The generated 1 byte number has been output to Port0 where LEDs are connected. As the number generated is random, these LEDs will blink in a random fashion.

You may also like:


  • What are EMS/EMC immunity lab tests?
  • beginners guide
    Basic Electronics 01 – Beginners guide to setting up an…

  • What is Wireless Electric Vehicle Charging System (WEVCS)?

  • What’s a protective relay and what does it protect?

  • What are the different types of electric vehicles?

  • What is MicroPython?

Project Source Code

###

//Program to 

#include"reg24le1.h" // I/O header file for NRF24LE1

#include"hal_delay.h" // header file containing delay functions
 
// main function
void main()
{
RNGCTL = 0xC0; // enable random number generator
P0DIR = 0; // Port 0 as output
 
// infinite loop
while(1)
{
while(!(RNGCTL & 0x20)); // check if random number is generated or not
P0 = RNGDAT; // output the number to Port 0
delay_ms(500); // delay of 500 ms
}
}

###

 


Circuit Diagrams

Circuit-Diagram-NRF24LE1-Module-Random-Number-Generator

Project Video


Filed Under: Tutorials

 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Input impedance matching network
  • High Side current sensing
  • The comparison of different Tcl script checkers
  • Voltage mode pushpull is a nonsense SMPS?
  • Reducing "shoot-through" in offline Full Bridge SMPS?

RSS Electro-Tech-Online.com Discussions

  • Back to the old BASIC days
  • Parts required for a personal project
  • PIC KIT 3 not able to program dsPIC
  • Failure of polypropylene motor-run capacitors
  • Siemens large industrial PLC parts

Featured – RPi Python Programming (27 Part)

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol
  • RPi Python Programming 26 – Interfacing ADXL345 accelerometer sensor with Raspberry Pi

Recent Articles

  • What is AWS IoT Core and when should you use it?
  • AC-DC power supply extends voltage range to 800 V DC
  • Infineon’s inductive sensor integrates coil system driver, signal conditioning circuits and DSP
  • Arm Cortex-M23 MCU delivers 87.5 µA/MHz active mode
  • STMicroelectronics releases automotive amplifiers with in-play open-load detection

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe