Arduino Zero with SaraR4 NB-IoT Shield (Communication Device)

This README provides instructions for setting up and using the Arduino Zero with the SaraR4 NB-IoT Shield. This guide assumes that you have the necessary dependencies installed, including Git, the Arduino IDE, VSCode, Python, and Bash.

Dependencies

  • Git
  • Repository
  • Arduino IDE
  • VSCode
  • Python
  • Bash
  • Arduino CLi (https://arduino.github.io/arduino-cli/0.21/installation/)

Hardware

  • Arduino Zero
  • SaraR4 NB-IoT Shield

Setup Steps

  1. Clone the Repository:
    git clone `git@github.com:BCIT-Reseach-Long-Term-ISSP/device-firmware-refactor.git`
    
  2. Install Arduino CLI:
    Refrence: Official Arduino CLI Installation Docuemnt

  3. Update Arduino Core:
    arduino-cli core update-index --additional-urls https://adafruit.github.io/arduino-board-index/package_adafruit_index.json
    
  4. Connect Arduino Zero and SaraR4 NB-IoT Shield:
    Ensure that the shield is mounted on top of the Arduino Zero, and HardwareSerial serial1 is used for communication.

  5. Setup NB-IoT Shield:
    • Set switches on the shield to HardwareSerial and ArduinoPower.
    • Connect your laptop to the Arduino Zero via the programmer’s port.
    • Open a serial monitor in the IDE with “Both NL & CR” and baudrate 115200.
    • Run the following Arduino sketches:
      • zero/setup/register_operator/register_operator.ino
      • zero/setup/serial_passthrough/serial_passthrough.ino
  6. Setup Shield Certificates:
    • Navigate to AWS IoT: AWS IoT → Manage → All devices → Things
    • If the thing already exists, create a new certificate and download all the generated certificates. Otherwise, go to Create Thing and create a new thing.
    • For Configure device certificate, choose Auto-generate a new certificate (recommended)
    • Download the certificates and keys, move them to the zero/setup/certificates folder, and rename as follows:
      • Device certificate: certificate.pem.crt
      • Public key file: public.pem.key
      • Private key file: private.pem.key
      • AmazonRootCA1.pem
      • AmazonRootCA3.pem
    • setup Virtual Environment:
      • Open a terminal window
      • cd zero/setup/certificates
      • Depending on how your python executable is set up, run one of the following commands:
            python -m venv venv
        

        or

            python3 -m venv venv
        

        or

            python3.11 -m venv venv
        
      • Activate virtual environment
        Windows:
            .\venv\Scripts\activate
        

        For macOS and Linux:

            source venv/bin/activate
        
      • Install dependecies:
            pip install -r requirements.txt
        
    • Close Arduino IDE before you run this command:
          python nbiot_cert_upload.py --port [port number of Arduino] --cert-dir [directory to your certificates]
      

      Example:

          python nbiot_cert_upload.py --port /dev/ttyACM0
      
  7. Upload Code:
    • Please use git bash for this.
    • cd zero/
    •     chmod +x arduino_upload.sh
      
    • For help:
          ./arduino_uplaod.sh -h
      
    • To install core, burn bootloader, compile and upload code:
          ./arduino_upload.sh -i -b -c -u PORT=[Arduino port]
      

      Example:

          ./arduino_upload.sh -i -b -c -u PORT="dev/ttyACM0"
      

Now your Arduino Zero with SaraR4 NB-IoT Shield is set up and ready for NB-IoT communication.