IOTA (ARTIC R2) Satellite Communication Module Hookup Guide

Pages
Contributors: PaulZC
Favorited Favorite 1

Arduino Example: Satellite Detection


Warning: Always connect a 401MHz antenna to your IOTA before connecting the power. Transmitting with no antenna attached will damage the RF power amplifier.

The SparkFun ARGOS ARTIC R2 Arduino Library contains a full set of tried and tested examples which will run on any Arduino board, but you will need to change the pin definitions in the code to match your board.

This guide assumes you already have the Arduino IDE and the ARGOS ARTIC R2 Library installed, and have selected the correct Arduino Board. If you need help with any of that, please check out the ARGOS ARTIC R2 Shield Hookup Guide.

The code below is a stripped-down version of Example4_SatelliteDetection. Copy and paste the code into a new window in the Arduino IDE:

language:c
#include <SPI.h>
#include "SparkFun_ARGOS_ARTIC_R2_Arduino_Library.h" // http://librarymanager/All#SparkFun_ARGOS_ARTIC_R2
ARTIC_R2 myARTIC;

// Pin assignments - change these if required
int CS_Pin = 24;
int GAIN8_Pin = 3;
int BOOT_Pin = 4;
int INT1_Pin = 5;
int INT2_Pin = 6;
int RESET_Pin = 7;
int IOTA_PWR_EN_Pin = 8;

void setup()
{
  Serial.begin(115200);
  Serial.println(F("ARGOS ARTIC R2 Example"));

  Serial.println(F("ARTIC R2 is booting..."));

  SPI.begin();

  //myARTIC.enableDebugging(); // Uncomment this line to enable debug messages on Serial

  // Begin the ARTIC: enable power and boot from flash
  if (myARTIC.beginIOTA(CS_Pin, RESET_Pin, BOOT_Pin, IOTA_PWR_EN_Pin, INT1_Pin, INT2_Pin, GAIN8_Pin) == false)
  {
    Serial.println("ARTIC R2 not detected. Freezing...");
    while (1)
      ; // Do nothing more
  }

  Serial.println(F("ARTIC R2 boot was successful."));

  // Read the Platform ID from flash memory
  uint32_t platformID = myARTIC.readPlatformID();
  if (platformID == 0)
  {
    Serial.println(F("You appear to have an early version of the SparkFun board."));
    Serial.println(F("For the transmit examples, you will need to use the Library Manager to select version 1.0.9 of this library."));
  }
  else
  {
    Serial.print(F("Your Platform ID is: 0x"));
    Serial.println(platformID, HEX);
  }

  myARTIC.setTCXOControl(1.8, true); // Set the TCXO voltage to 1.8V and autoDisable to 1

  myARTIC.setSatelliteDetectionTimeout(600); // Set the satellite detection timeout to 600 seconds

  Serial.println(F("Starting satellite detection..."));

  // Start satellite detection
  // The ARTIC will start looking for a satellite for the specified amount of time.
  myARTIC.sendMCUinstruction(INST_SATELLITE_DETECTION);
}

void loop()
{
  delay(1000);

  // Read the ARTIC R2 status register
  ARTIC_R2_Firmware_Status status;
  myARTIC.readStatusRegister(&status);

  // Check the interrupt 2 flag. This will go high if satellite detection times out
  if (status.STATUS_REGISTER_BITS.DSP2MCU_INT2)
  {
    Serial.println(F("INT2 pin is high. Satellite detection has timed out!"));
  }
  // Check the interrupt 1 flag. This will go high when a satellite is detected
  else if (status.STATUS_REGISTER_BITS.DSP2MCU_INT1)
  {
    Serial.println(F("INT1 pin is high. Satellite detected!"));
  }

  // Check the instruction progress
  // checkMCUinstructionProgress will return true if the instruction is complete
  ARTIC_R2_MCU_Instruction_Progress progress;
  boolean instructionComplete = myARTIC.checkMCUinstructionProgress(&progress);

  if (instructionComplete)
  {
    Serial.println(F("Satellite detection is complete! Freezing..."));
    while (1)
      ; // Do nothing more
  }
}

Save the file and click on the Upload button to upload the example onto your Arduino board. Open Tools\Serial Monitor to see the serial messages. Check that the baud rate is set to 115200:

Pictured is the Arduino I D E serial monitor

Once the ARTIC R2 has booted, the code will read the pre-programmed Platform ID from flash memory. If it does not find one, you will see a message reminding you to install v1.0.9 of the ARTIC R2 library.

The ARTIC R2 will try to detect a satellite for up to 10 minutes. You may wish to log into the ARGOS website and predict when the next satellite pass will take place before running this example.