Calling a phone number on boot up - Electron


I have been searching high and low but not having much luck. I have check the Doc’s and examples but still not working. Maybe its not possible. I dont even have a sample code to show because I’m not even close.

I am using a Particle with a relay attached and using SMS to turn the relay on and off. All is working well.

What I want to do now is have a “alert phone number” (the users phone number) stored in EEPROM so that several units can run the same software.

The particle when powered up sends a SMS to the alert number to sat it has booted up. (currently working with a phone number defined in the code)

I want to be able to send a SMS to change the alert number in the EEPROM effectively setting up the device so so i can hand it over to another person with out the need to re-flash the device and hard code their number in.

Any help would be appreciated.

I am not running a coin cell battery and therefore the SRAM is not an option at the moment.

So your now using a 3rd part SIM to receive and send SMS messages successfully.

Now you just want to write code to store a new phone number in EEPROM when received via SMS message?

Kind of. I want to be able to change the phone number of the alert number via sms and have it stored in the EEPROM

You’re already able to receive SMS messages right?

If so you just need to store that incoming SMS data into EEPROM.

Have you tried to do that yet?

1 Like

What is your prime issue - receiving SMS or storing the number in EEPROM?

For the former there are several threads available and I’ve done it, so it is possible

For the latter, the EEPROM docs should be comprehensive.

1 Like

Yes. Sending and receiving sms I’m all over.
I’ve looked at the put and get but can’t work it out.
Currently the code has a

String alertNumber = “+614xxxxxxxx”

at the start.

in setup it send a sms

sendSMS(“This device has been Powered Up”, alertNumber);

I want to call the alertNumber from EEPROM.

I also want to be able to change that phone number in the EEPROM by say sending a sms changenumber,614xxxxxxxx


int addr = 10;
uint16_t value1;
EEPROM.get(addr, value);
if(value == 0xFFFF) {
  // EEPROM was empty -> initialize value1
  value1 = +614xxxxxxxx;
string alertNumber = value1 

sendSMS("This device has been Powered Up", alertNumber);

in the loop I have this code;

if (smsProvided_Command == "newnumber")
    if (smsProvided_Command_Option.length() != 12)
      sendSMS("Error: Alert number must be 12 digits and in this format: +614xxxxxxxx", phoneReturn);
      return 0;
    if (smsProvided_Command_Option.startsWith("+61"))
      sendSMS("Mobile alert number changed to: " + smsProvided_Command_Option, alertNumber);

      int addr = 10;
      uint16_t value1 = + smsProvided_Command_Option;
      EEPROM.put(addr, value1);

      sendSMS("Mobile number changed to: " + smsProvided_Command_Option, phoneReturn);
      return 1;

      sendSMS("Error: Mobile number must start with  +614 --only Australian numbers are supported. e.g. 0488.. becomes +61488..", phoneReturn);
      return 0;
    return 0;

String objects are not well supported with EEPROM.put() and EEPROM.get() since a String object doesn’t actually hold the string inside the object but only a pointer to the heap location.
So I’d suggest using a character array (char alertNumber[32]) to hold your string. This should work without issue.

BTW, you also can’t use uint16_t to store a telephone number unless you have very short ones :wink: