Remote Garage Opener using phone calls (Arduino + SIM900 + relays)

I'm working on an open source project to make an automation to open a garage door.
The project uses a SIM900 module to be able to receive calls. When a call is received, the phone number is compared against an authorized phonebook, and if the number is in the list, a relay is fired.
The project as it is now is functional, but I' stuck with two problems that don't let me finish the project.

The main problem is that when I receive data from the serial port connected to the SIM900, sometimes some characters are missing. It rarelly happens if the data is small, like when I send commands that only return OK or ERROR or when the RING message and the caller identification is given; but if I ask for a list of SMS or similar, the data sent will have several single characters "eaten".
I tried with two Arduinos (Mega and One), and even tried shielding the RX and TX cables that go to the SIM900 module, to no avail.
Also, I looked if there's a way to change the serial speed for communicating whith the SIM900, but I can't find anything; it defaults to 19200bps, I want to lower the speed to check if its something related to the cable's realiability.

The second problem is that I can't get the SIM900 module to power on by the Arduino. It works if I fisically press the module's power button, but when I put that project to work, I don't want to need to push a button every time after there is a power outgage.
Anyway, this problem does not bother me; if I can't power on the module via a pin, I'll use another relay connected to the power button.

Example of the "eaten characters" problem: (I added the asterisks to obscure the four central numbers of my phone number)

Sending command: AT+CMGL="ALL"
Sent. Waiting response
AT+CMGL="ALL"
Receiving data

+CMGL: 1,"REC READ","679****39","","15/05/30,12:09:53+08"
000200650060020003003004D0010079020006D069005006E07400720610730020073007002006D00F0076006006C02000600730040061

+CML: 2,REC RED","69****3","","5/05/0,12:9:53+0"
0060061020006F0630050070061006006F

+CMG: 3,"EC REA","+3479***39","""15/0530,1:19:3708"
Hla

OK

The first line received is correct, but the second message has 8 characters missing in the first line alone!

I put the full project on Github so if anyone wants to check the code or help, it will be really appreciated.
This is the repository: GitHub - Spyd77/GorDO: GSM Garage Door Opener for Arduino

What does currently work and what does not on my project?
WORKING:

  • You can send commands via the Arduino's serial console
  • There is a phonebook for 64 entries (stored in the EEPROM)
  • Command to list the phonebook (result via Arduino's serial console)
  • Command to add entries to the phonebook
  • Command to delete entries from the phonebook
  • SIM900 is initialized and set to give caller ID when someone's calling
  • When there's a call, is compared to the phonebook; the relay is fired if the caller is on the list
  • Calls are never picked up, they are automatically dropped after getting the caller ID, so no phone charges for using the automation

NOT WORKING:

  • SIM900 module is not automatically powered on, you have to press the button manually
  • Long text received from SIM900's is missing some characters.
  • Commands via SMS are not implemented

Calls are never picked up, they are automatically dropped after getting the caller ID, so no phone charges for using the automation

That's neat. I'm still not sure how good an idea this is, but I thought it was stupid one until I saw that.

I have not put my SIM900 in to use yet, but there are two possible causes.

The module is a power hog and you may be already seeing evidence of that. I have just got a 5v 2A power supply just for the SIM900.

The module might be causing grief because it is on software serial, even at 19200, and in which event it should be moved to hardware serial.

+1 for Nick's suggestion to try a hardware serial port instead of softwareserial - Mega has 4 so there shouldnt be a conflict.

You could also try a simpler sketch to just read the SIM900 input and echo to your computer just to make sure your interrupts aren't getting lost during some other part of your sketch. This may help you determine if the comms problem is hardware or software related.

void loop() {
  if (SIM900.available()) {
    incoming_char = SIM900.read();
    Serial.print(incoming_char)
  }
}

Although I've always thought that the garage door openers that used bluetooth pairing for authentication were more convenient and secure. Its not that hard to spoof caller-id.

Try using a slower baud rate when talking to the SIM900. Set it when you issue the SoftwareSerial command?

And ditto what Nick said about the power, I use 5V 2A fed directly into the board. Some people advocate putting a diode across the Arduino voltage regulator if you do this.

Finally, at the risk of asking a stupid question, you are trying to turn on the SIM900 using the correct pin?

Thank you all for your replies. I'll try everything you suggested, but as this is a hobby project and I don't have too much free time, I'm not sure I'll be able to do it until the weekend. I'll keep updating this thread.

Nick_Pyner:
The module is a power hog and you may be already seeing evidence of that. I have just got a 5v 2A power supply just for the SIM900.

I'm using a dedicated 2250mAh for the SIM900, but until the project is installed, I'm using USB to power the Arduino board.

Nick_Pyner:
The module might be causing grief because it is on software serial, even at 19200, and in which event it should be moved to hardware serial.

I'll try hw serial to see if that fixes the problem, and I'll report back.

rw950431:
Although I've always thought that the garage door openers that used bluetooth pairing for authentication were more convenient and secure. Its not that hard to spoof caller-id.

I wanted it that way for simplicity to use, and for another situation: remote opening the garage door, for example if i'm not home.
I didn't know you can easily spoof caller-id. But to be able to do that, you need to know what number to dial, and what number you need to spoof, so I'm not particulary worried.

dannable:
Try using a slower baud rate when talking to the SIM900. Set it when you issue the SoftwareSerial command?

I thought you had to set both devices to the same connection params? I'm sorry, I'm a bit of a noob here.
I'll try it.

dannable:
Finally, at the risk of asking a stupid question, you are trying to turn on the SIM900 using the correct pin?

I tried the pins stated on the documentation, but it didn't work. This was when I started this project, so I left this bug apart and used all the resources I had to complete the core functionality. I'll try again when I have the serial communication with the SIM900 working, but I wanted to ask because maybe I was missing something.

Nick_Pyner:
That's neat. I'm still not sure how good an idea this is, but I thought it was stupid one until I saw that.

Well, it's good enough to be a commercial product.
The reason I'm doing it myself is because it's fun, and because I want to add more capabilities, like using more than one relay (to start lights, for example), logging who is entering, web-based reports, etc.

Updates:
Serial communication with the SIM900:
I changed from SoftwareSerial to hardware serial, so I used Serial1 (Pins 18 & 19) and pins 0 & 1 in the SIM900. Now, I don't have the missing characters from before, but now it seems like the data is cut. This is an example:

Sending command: AT+CMGL="ALL"
Sent. Waiting response
AT+CMGL="ALL"

+CMGL: 1,"REC READ","679XXXX39","","15/05/30,12:09:53+08"
003600370039003065006C002000330030004D006100790020006D00690065006E00740072006100720006F00630075007000610064006F

+CMGL: 3,"REC READ","+34679XXXX30380020006C00650020006800610020006C006C0061006D00610064006F0020006

Powering up the SIM900:
While still on software serial, I tried all pins on the SIM900 until I found that the pin for powering on the module is 6, and not 9 like stated on the documentation I got; so I got it working.
Then, I did the change to hardware serial, and now it does not work.

I commited the changes to GitHub, if anyone wants to look at the full code.