ECC608 Crypto Chip: Random Number Generator

Introduction

This tutorial explores how to use the ECC608 Crypto Chip on a NEXTuino BASE board to generate truly random numbers — useful in cryptographic operations, secure communications, or any application requiring unpredictability.

Prerequisites

  • Installed Arduino IDE
  • NEXTuino BASE board

Example Code

ECC608 Random Number Generator Example on GitHub

Code

#include <SPI.h>
#include <ArduinoECCX08.h>

void setup() {
  Serial.begin(115200);
  while (!Serial);
  delay(2000);

  Wire.setSDA(2);
  Wire.setSCL(3);

  if (!ECCX08.begin()) {
    Serial.println("Failed to communicate with ECC508/ECC608!");
    while (1);
  }

  if (!ECCX08.locked()) {
    Serial.println("The ECC508/ECC608 is not locked!");
    while (1);
  }
}

void loop() {
  Serial.print("Random number = ");
  Serial.println(ECCX08.random(65535));
  delay(1000);
}

Code Breakdown

  • Initialization: setup() initializes serial communication, sets up I2C with specific SDA/SCL pins (pins 2 and 3), and verifies the ECC608 chip is communicating and locked for secure operations.
  • Random Numbers: loop() continuously generates a random number using ECCX08.random(65535) and prints it to the Serial Monitor every second.

Step-by-Step Guide

  1. Connect your NEXTuino BASE to your computer
  2. Open Arduino IDE and select the appropriate board and port
  3. Copy the code into a new sketch
  4. Upload the sketch
  5. Open Tools > Serial Monitor to view the random numbers

Troubleshooting

  • If the Serial Monitor shows an error related to the ECC608 chip, ensure the chip is correctly configured and locked
  • For Arduino IDE or board issues, consult the official Arduino documentation

Conclusion

You have successfully used the ECC608 Crypto Chip to generate truly random numbers on your NEXTuino BASE, providing a secure RNG for cryptographic applications.