MarcoMartines / GSM-GPRS-GPS-Shield

GSM/GPRS & GPS Shield Library for modules using SIM900/SIM908
GNU General Public License v2.0
207 stars 151 forks source link

This fixes the pins not being initialized before using them. #5

Closed madmaze closed 10 years ago

madmaze commented 10 years ago

Currently as far as I can tell GSM_RESET is not in use, but if we define it, we might as well initialize it.

This fixes issue mentioned here: https://code.google.com/p/gsm-shield-arduino/issues/detail?id=97

salvatiobueno commented 10 years ago

Hi Madmaze!

I have a doubt... With this library how I get a phone number from contact agenda of the SIM card? Is possible? I saw some files but I didn't found nothing...

Thanks so much and sorry for my english! Salva.

madmaze commented 10 years ago

Hi Salva,

What do you mean by contact agenda? Do you mean the contact name associated with a number? At the moment only retrieving of the number is possible, see SIM900.cpp line 776. Using the AT+CPBR command, you should be able to extend those functions to allow you to retrieve the text associated with a phonebook entry. SIM900 datasheet page 69. I have not tried this, but file an issue here and it'll get put on the enhancements list.

Thanks,

Matthias

salvatiobueno commented 10 years ago

Sorry Madmaze,

I need to number to the contact, not the their name. What is the function to get it?

Thank you so much! Salva.

madmaze commented 10 years ago

Hi Salva,

Have a look at the function I mentioned in my previous response. It allows you to retrieve a phone number based on it's position on the simcard. Currently only the retrieval of a phone number at a know position is implemented. Find a position of an entry on the simcard given a name has not yet been implemented. See the "AT+CPBF" section on page page 67 of the datasheet for more info. If you want this feature, file an issue and I will add it to the queue of enhancements.

Thanks, Matthias

salvatiobueno commented 10 years ago

Ahh ok!! I look it!! Thank you so much again! :-)

salvatiobueno commented 10 years ago

Hi Madmaze!!

I have a doubt... It's possible to power ON the GSM Shield trought Arduino code without press the POWER ON in the Shield? I'm looking this: https://github.com/MarcoMartines/GSM-GPRS-GPS-Shield/blob/GSMSHIELD/GSM.h It uses the PIN 8 to ON and PIN 9 to RESET... It works right?

Thank you so much!!

madmaze commented 10 years ago

Hi Salva,

Yes you should be able to, make sure you have the newest version of the code. I recently fixed an issue here: https://github.com/MarcoMartines/GSM-GPRS-GPS-Shield/commit/787e16826bf4447d29081a4abfb0dbc946f6eadd Also what kind of board do you have? you will likely have to adjust the GSM_ON pin.

Cheers, Matthias

salvatiobueno commented 10 years ago

Hi Matthias!

Thank you! I use the Arduino UNO board and GSM Shield Icomsat SIM900... How I can turn on the gsm shield? Sending a high output to the GSM_ON pin?

thanks for everything Matthias!

madmaze commented 10 years ago

Hi Salva,

As long as you have the right GSM_ON pin set, it should turn on by itself. If it does not, you can do it manually by setting the GSM_ON pin to HIGH for 1200ms-1500ms then LOW again.

Thanks, Matthias

salvatiobueno commented 10 years ago

Ok, thank you Matthias, I tried it! I need to turn on (from Arduino) the gsm shield to avoid having to press button ON in the GSM shield...

madmaze commented 10 years ago

Thats interesting, so with the board you have(icomsat sim900) the library does not manage to automatically power it on correct? What pin did you set GSM_ON to? Are you sure you are running the latest version of the code Release 3.07.2?

MarcoMartines commented 10 years ago

Unfortunately this library has been developed with the OpenElectronics/FuturaElettronica shield not for icomsat. However on the forum (www.gsmlib.org/forum) there are different users with your board. Maybe you can find some help there.

salvatiobueno commented 10 years ago

Sorry Matthias,

I didn't latest version of library... I just update, and tried it tomorrow! I will tell you!

PD: Marco, I using this library with my GSM Shield IcomSat and not have problems... Thanks!

Salva.

MarcoMartines commented 10 years ago

I mean the PowerOn problem.

salvatiobueno commented 10 years ago

Hi guys!

I use the latest version of library and I plug in power to Arduino, the LED power of GSM Shield turn ON, but... I need to press GSM Reset button on the shield to get NET status... I just want only plug in power to Arduino and everything starts without press any button in gsm shield... :-(

I start thinking that's impossible...

Moreover...

I tried to get IMEI using function in the library without success, this is the code:

void sendSMSlog(void){ char *text2 = " TEL: "; // Si devuelve el Nº IMEI y el nº de tel SIM OK, envía SMS de LOG if (1 == gsm.getIMEI(IMEI) && 1 == gsm.GetPhoneNumber(1, teluser)){ strcpy (SMStext, "ALARM ON! IMEI: "); strcat (SMStext, IMEI); strcat (SMStext, text2); strcat (SMStext, teluser); sms.SendSMS(telcentral, SMStext); Serial.println("\nSMS log sent OK"); } }

Can you help me? I'm doing something incorrect?

THANKS for everything guys!

madmaze commented 10 years ago

As a workaround for the power-on problem, You can set the GSM_ON pin of the library to something you are not using. like 80 or 100 or something. Then do this:

int pwrPin = 8; // set this to whatever is the correct pin for you.
pinMode(pwrPin, OUTPUT); 
void togglePower() {
    digitalWrite(pwrPin, HIGH);
    delay(1200);
    digitalWrite(pwrPin, LOW);
    delay(3000);  // This is relatively arbitrary, just some interval to give it time to power on and connect.
}

If with the above code, you still have to hit reset, then you can also toggle the reset pin in the same fashion. As for the SMS-snippet, I don't know why that doesn't work. I will look into it this evening.

Cheers,

Matthias

salvatiobueno commented 10 years ago

Thank you Matt,

I try to set GSM_RESET and turn on high pulse, I suspect that's the problem... I also will look in this evening... And will tell you!

Relative to SMS-snippet, basically the problem is with getIMEI(IMEI) function... I tried to remove it and the function works well and sending SMS... :-(

Thank you for everything Matt! PD: I owe a beer!