Using a Teal OneChip eSIM with a Particle Electron or Boron device is a great way to enable robust connectivity options while saving money. We think it is a no-brainer, especially since the cost per MB is $0.40 when using the default Particle connectivity, vs $0.01 per MB when upgrading to Teal connectivity.


In order to configure your Particle device to connect with a Teal eSIM, you can follow these steps on their website, while copying the below code or downloading the attached file when it is time to write the Program responsible for setting the APN on your device.


Contents of 3rdPartySIM.cpp:


#include "Particle.h"

#include "dct.h"

SYSTEM_MODE(SEMI_AUTOMATIC);

// setActiveSim and setCredentials must be in STARTUP to take effect immediately
STARTUP({
  Cellular.setActiveSim(EXTERNAL_SIM);
  Cellular.setCredentials("teal");
});    // The order here is important because the APN needs to be set only after the SIM switch

int at_ret_val = 1;

void setup() {
  Cellular.on();
  int retry_count = 3;

  while(at_ret_val != RESP_OK && retry_count)
  {
    delay(5000);
    // not resetting after UMNOPROF setting because in Gen3,
    // we reset as a part of putting the second/actual app firmware
    at_ret_val = Cellular.command(10000,"AT+UMNOPROF=1\r\n");
    retry_count--;
  }

   // This clears the setup done flag on brand new devices so it won't stay in listening mode
   const uint8_t val = 0x01;
   dct_write_app_data(&val, DCT_SETUP_DONE_OFFSET, 1);

    // This is just so you know the operation is complete
    pinMode(D7, OUTPUT);
    digitalWrite(D7, HIGH);
}

void loop() {
  // If setting the UMNOPROF (mobile network profile) was unsuccessful, LED blinks every 1 sec
  if (at_ret_val != RESP_OK)
  {
    digitalWrite(D7, HIGH);
    delay(1000);
    digitalWrite(D7, LOW);
    delay(1000);
  }
}