Auto resend incomming SMS to a list of people (SIM900)

Hello from Norway :slight_smile:

I want to take an incoming SMS message and send it out to a bunch of people from a phone list. I have not come up with a good idea on how to go around this in a somewhat easy way.

I manage to send and receive messages. But not sure about how to go around the rest of my quest.

The system is meant to be used for colleagues to be able to alert other colleagues about closed roads or other problems on the road like avalanches or closed mountain passes for long distance drivers in Norway.

So the usage will be.
I send an SMS to a phone number. and it will automatically resend the incoming message out to a numerous other drivers that is on a telephone list.

I have done some tests but ended up scrapping them all :-p

An easy way to update the phone list would be preferable also. But not mandatory. i can always update the code with hard coded phone numbers.

HW: I am using an Arduino UNO R3 with a SIM900 shield.

All ideas and code welcome :slight_smile:

This is what i come up with this time. It receives my messages just fine. But it only reply with a blank message back to me. Best i have managed this far is get it to send back the first letter from the message. The worst is to receive a bunch of blank messages. I have tried to figure out serial usage but no luck. Tested a lot of ways doing this now. Found a lot on YouTube and here. But for some reason there is something I’m not getting. I’m feeling stupid as this should be the easy part of it :smiley: I managed to fix a system to control computers, amplifiers, lights, fans based on temperature and alarms. Safety shutdowns of systems + + + + in a complex carputer project i am doing in my Chevy Starcraft. But i cant seem to manage this… Frustrating af. But still funn. Learning new stuff every day :slight_smile:

/*
 SMS distribution system
*/

#include <GSM.h>

#define PINNUMBER "1005"

GSM gsmAccess;
GSM_SMS sms;

// Array to hold the number a SMS is retreived from
char senderNumber[20];

void setup() {
  
  // initialize serial communications
  Serial.begin(9600);
  Serial.println("SMS Message System");

  // connection state
  boolean notConnected = true;

  // Start GSM connection
  while (notConnected) {
    if (gsmAccess.begin(PINNUMBER) == GSM_READY) {
      notConnected = false;
    } else {
      Serial.println("Not connected");
      delay(10000);
    }
  }

  Serial.println("GSM initialized");
  Serial.println("Waiting for message");
}

void loop() {
  
  char inSMS;
  
  // If SMS available
  if (sms.available()) {
    Serial.println("Recieved from:");

    // Get senders number
    sms.remoteNumber(senderNumber, 20);
    Serial.println(senderNumber);

    // Read and print recieved message
    while (inSMS = sms.read()) {
      Serial.println(inSMS);
    }
  
    // send the recieved message
    Serial.println();
    Serial.println("Sending recieved message");
    sms.beginSMS(senderNumber); //Need to figure out how to send to multiple users
    while (inSMS = sms.read()){
      sms.print(inSMS);
    }
    sms.endSMS();
    Serial.println("\nEND OF MESSAGE PROSESSING\n");

    // Delete message from memory
    sms.flush();
    Serial.println("RECIEVED MESSAGE DELETED");
  }

  delay(1000);

}
    // Read and print recieved message
    while (inSMS = sms.read()) {
      Serial.println(inSMS);
    }

Do you understand that you failed to save the incoming message anywhere?

    // send the recieved message

How can you possibly do that, when the message went in one ear and out the other?

What you are doing in the while loop is pointless. You've already emptied the incoming text message buffer, so the next time you try to read from the buffer, of course it will be empty.

Thank you for replying on this PaulS

PaulS:
Do you understand that you failed to save the incoming message anywhere?

No. Ass i managed to read it several times with Serial.print i didn't know i needed to store it somewhere else? But it makes sense somewhat for me as i only get the first letter in return if i get something back. Serial usage is not something i done before.

PaulS:
What you are doing in the while loop is pointless. You've already emptied the incoming text message buffer, so the next time you try to read from the buffer, of course it will be empty.

the text stays until i use sms.flush(); ? The while loop is something i tried since this works for Serial.print to the serial monitor for me. and i found it in a gsm receive example.

So i need to fetch it from sms.read and store it somewhere before i can use it for sms.print. got it :slight_smile: Google next hehe.

As by now serial usage like this is a mystery for me :-p hehe Sorry :slight_smile:

again. tnx for the reply. As you have already helped me clarifying this :slight_smile:

you might want to point your search in the direction of "AT+CMGW"

scrumfled:
you might want to point your search in the direction of "AT+CMGW"

tnx. Found good info thru this. Gonna work on this project later tonight now that i got more knowledge here.