Sending SMS from Particle Electron using AT Commands

What SIM are you using? As far as I’m aware, the Particle SIM won’t support anything other than internet.

@bpr, I am reasonably sure that this is a restriction of the SIM card and not the U-Blox modules. They can certainly send and receive SMS, but if the provider blocks it then it won’t work. @krvarma, are you using the Particle SIM?

Aha! that would explain it as I’m using the Particle SIM

@Stevie, I am using my own SIM, not Particle SIM. I just update the post to reflect that.

Okay, that clarifies it. Very cool anyway!

It should be used pin RI (RING Indicator).
Pin from Ublox is connected to the microcontroller. It can be seen from the scheme.
But most likely it is able to receive and messages without using RI. The official Arduino GSM Shield does not use RI. It is based on Quectel M10. Also some Shield based on SIM900 do not use RI. Can most likely to perform the software without using an external interruption. But however the pin RI is already connected :slight_smile:


3 Likes

@krvarma I’m also using 3rd-party sim since the official sims are not working for me right now. It seems like my own sim gets connected to the cloud (blinking cyan) but it won’t take any command (Tinker App and terminal commands). Do you have any suggestion? I’m based in Thailand.

Thanks,
Jakk

@izeroman, are you sure Electron is online and is showing online in build.particle.io?

1 Like

As @krvarma implies, blinking cyan is only indicating the attempt to connect to the cloud. Active cloud connection would be indicated by breathing cyan.

@krvarma, @ScruffR

All my devices show up in both Build and Dashboard and the dashboard shows those Electron and ‘breathing cyan’.

Thanks for replying. :smile:

I

@izeroman, can you manually call digitalwrite function (Tinker Application) using CURL and see what error is returning?

Yes the iOS Tinker app just frozen as well as my own iOS app (Swift). The curl return ‘false’ and ‘timeout’.

This looks really cool. Thank you for posting this. I was planning on implementing my own SMS capability using AT commands. I got stuck on trying to figure out what library the Cellular class can be found. Looking t your code on GitHub I see no includes for a library that reference Cellular.

I can’t get your code to compile since it can’t find “Cellular”. What library are your including? Or how are you able to compile your code without referencing the library in which Cellular is defined?

hi @shiv

With any of the cloud compiler paths, you need to make sure your target is an Electron since Photon etc. don’t have the cellular class.

How are you compiling your code?

1 Like

@bko,
Thank you for the reply. Yes, my target is the Electron. I’m compiling the code online and then downloading the *.bin file and flashing it locally. Of course in this case, I can’t compile. I tried add an include for Cellular.h but that didn’t work either.

If you could use this to wake up the Electron, that would be awesome. I asked that question yesterday so I’m definitely going to be watching your post. Best of luck Krvarma!
[My Post][1]
[1]: Waking up an Electron remotely

1 Like

Hi @shiv

I still think you are not targeting an Electron since nothing else make sense to me. In the web IDE, the device that you are targeting must have the yellow star to left of its name.

I tried the followed test code (non-functional but compiles and based on @krvarma code above) in the web IDE and do not get any compile time errors with zero include files.

Can you try this (cut-and-paste into a new .ino file in the web IDE):

// TEST CODE DO NOT USE
char szPhoneNumber[] = "5551212";

#define MAX_PHONE_NUMBER    14
#define CTRL_Z 0x1A
#define TIMEOUT 10000

int callback(int type, const char* buf, int len, char* param){  
    Serial.print("Return: ");
    Serial.write((const uint8_t*)buf, len);
    Serial.println();
    
    return WAIT;
}

void setup() {

}

void loop() {
    sendMessage("testing");

}

int sendMessage(char* pMessage){
    char szCmd[64];
    
    sprintf(szCmd, "AT+CMGS=\"+%s\",145\r\n", szPhoneNumber);
    
    Serial.print("Sending command ");
    Serial.print(szCmd);
    Serial.println();
    
    char szReturn[32] = "";
    
    Cellular.command(callback, szReturn, TIMEOUT, "AT+CMGF=1\r\n");
    Cellular.command(callback, szReturn, TIMEOUT, szCmd);
    Cellular.command(callback, szReturn, TIMEOUT, pMessage);
    
    sprintf(szCmd, "%c", CTRL_Z);
    
    int retVal = Cellular.command(callback, szReturn, TIMEOUT, szCmd);
    
    if(RESP_OK == retVal){
        Serial.println("+OK, Message Send");
    }
    else{
        Serial.println("+ERROR, error sending message");
    }
    
    return retVal;
}

@bko,

Thanks for persisting! Yes, you’re correct. I didn’t realize that I had to click on the star to make the device “active”. Once I clicked on the star and it turned yellow I realized my error. Thank you!

Ok, I was able to compile and flash my Electron. Changed the szPhone to my cell phone number. At some point I see the “+OK, Message Sent” in my terminal program. But no SMS is received. FYI - I’m not using the Particle provided SIM but another SIM I use for a different device from which I am able send SMS messages.

@shiv, can you look at the serial output for any possible errors after sending the AT command? May be it will provide some clue.

1 Like

hey,

I’m new to electron but farly familiar to ARM and arduinos… I wanted to make some sort of access tool that checks if a CallerID is in a certain list and perform than a certain action…

Can anyone help me figuring out how I can get the caller ID and how to enable a Interrupt that is triggered when a call comes in?

Is there already a similar thread about this? This seems to me to be the best place working out AT commands… :stuck_out_tongue:

Is PB12 settable as a Interrupt pin?