Automating AT Commands

Hi guys,

I’ve currently written a sequence of AT commands to connect my SODAQ R410M to the network and send a message. Yet it’s getting quite tedious to put all those AT commands in the serial monitor by hand. Is there any way of writing code to automatically send AT commands to the SARA module? I’ve seen some example code use the serial streams, yet I haven’t been succesfull in doing so myself.

Here’s an example of the sequence I want to send:

AT+USOST=0,“Server_IP”,PORT,ByteCount,“40 bytes of hex data”

I’m currently working in the Arduino IDE, so my prefered way of sending the commands is using a .c file.
Any of you who have experience with this?


You can write a function using Serial1.println() to send the AT-Commands to the R410M.
Before sending the next command, you should wait for a response.
The best way to do this is using

Ah, didn’t know I had to actually wait for a response. So I could use the following?

_While( != “OK”){
_While( != “OK”){

So send some command, wait untill I receive “OK”, then send the next one?


I tried working out the example.
Unfortunately I couldn’t get rid of the delay function.
When I replace delay(2000) with While( != “OK”){}, my application stops working.
This is what I have for now:

I put the commands in a String array and loop over it.

Thanks for thinking along! I’m definitely gonna try this for a couple of commands of which I know for sure they will return OK. Not quite sure on commands like AT+COPS which can take a little longer. Guess I’ll have to find a way to wait for any reply from the SARA. Thanks a lot though! :slight_smile:

We have NB-IoT library, it works on the R410 and N211.
Just for the R410 example, #define R4XX needs to be in the top of the sketch.