Go Down

Topic: Arduino GSM shield not compatible with Leonardo board. (Read 5608 times) previous topic - next topic

Peter_n

Oct 09, 2014, 11:29 am Last Edit: Oct 09, 2014, 11:32 am by Peter_n Reason: 1
The Arduino GSM Shield is not very compatible with the Leonardo, and the library uses interrupts different for the Leonardo.
There is a guide for it: http://arduino.cc/en/Guide/GSMShieldLeonardoMega
But that still uses pin 3 for TX. However, pin 3 is also SCL for the I2C bus.

It would better if the GSM shield could be used and still keep the Serial1 and I2C available.
The solution is simple, use RX to pin 8 (as described in the Guide) and TX to pin 9.
The RXINT should not be used, since pin 8 supports PCINT change interrupt for the normal SoftwareSerial library.

In the library GSM3SoftSerial, the interrupt for the Leonardo is not very well implemented. It seems to be a work in progress. As it is implemented at the moment, I would call it a bug.
I suggest to remove the interrupt number for the Leonardo, and make it possible to use a pin as described for the SoftwareSerial library.
The library and the guide should be changed.

In this post I suggested to make __RXINT__ value 100, to disable it.
http://forum.arduino.cc/index.php?topic=269816.msg1913883#msg1913883
I don't know if __RXPIN__ value 8 will use the PCINT change interrupt without further change.

http://arduino.cc/en/Reference/softwareSerial
http://arduino.cc/en/Main/arduinoBoardLeonardo
http://arduino.cc/en/Main/ArduinoGSMShield

chrisazzopardi

I know this is an old thread but I hope it is the current one.

I am trying to connect the Mega 2560 to the GSM shield and have followed this post and your guide but am now at a loss.

The only 'proof of life' I got from the GSM shield is when I used HW Serial using the AltSoftSerial library. This required connections to pins 0 and 1 on shield to be connected to the mega on 48 and 46 with 44 and 45 to be taken up for interrupts. I followed the instructions in https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html. My shield looks like the image in the link below.

http://www.elecrow.com/wiki/index.php?title=File:GPRS_Shield_interface.png

But as I set the jumpers to sw serial mode and used jp 7 and 8, or even using hw serial mode on jp 0,1 on the shield, i could not communicate to 9,8 on the Mega using the GSM3 library. I did set to 9,8,100 the tx,rx,rxint in GSM3IO.h.

I would appreciate your help.

thanks
chris

PaulS

Quote
I would appreciate your help.
First, you need to clarify some stuff.

Quote
The only 'proof of life' I got from the GSM shield is when I used HW Serial using the AltSoftSerial library.
Hardware serial is NOT done using AltSoftSerial. What are you actually doing?

Quote
i could not communicate to 9,8 on the Mega using the GSM3 library.
Pins 8 and 9 on the Mega do not support pin change interrupts. That is what is needed for the GSM3 library to work.

chrisazzopardi

Apologies for the delay in replying but I am missing my email alerts on updates - Will try to fix.

The HWserial (i believe) is being set through my jumper settings on the GSM shield and I'm using jumpers 0,1 on the shield. The AltSoftSerial is being used to have 2 serial sessions- one between the modem and the mega and the other replicating comms to the serial between the mega and pc.

...


I thought I had to use 8,9. I also tried 14,15 but am at a loss what going on.

thanks
Chris



dannable

Take a look at the page on my signature. It covers connecting a shield like this to the Mega2560.
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

PaulS

Quote
The AltSoftSerial is being used to have 2 serial sessions- one between the modem and the mega and the other replicating comms to the serial between the mega and pc.
You have 4 hardware serial ports. You have not adequately explained why you need a second software serial port (besides the one that the moronic GSM library insists on using).

chrisazzopardi

Thanks to all for your contribution.


The following are my test results:
- I learnt I got clones and not the real deal :-( and probably hence the issues (pics included)
- For instance as you can see from the pictures, the GSM Shield has the jumpers reversed for D7/D8 (the pic are for setting them in this manner. I tested with a meter). Hence the confusion when I though I was using HWSerial. My SwSerial setting is to set the jumper to be close to the antenna.
- I could not make the serial1 connection work to the gsm shield as per dannable's link on pins 18/19 but managed to make it work on pins 50/51 with SoftwareSerial.h and AltSoftSerial.h on pins 46/48

The pictures show he pins connected to 50/51 when it was tested successfully with SoftwareSerial.

The tests were confirmed to be successful as commands were returned by the modem to the serial monitor.

The question now remains as to how to make use of the GSM3 library. I figured that the settings are in GSM3IO.h and changed it as follows (extract). Note that I want to use 50/51 as these are confirmed to work with SoftwareSerial but I could not connect to 14-19.


#if defined(__AVR_ATmega328P__)
#ifdef TTOPEN_V1
#define __TXPIN__ 3
#define __RXPIN__ 4
#define __RXINT__ 3
#else
#define __TXPIN__ 3
#define __RXPIN__ 2
#define __RXINT__ 3
#endif
#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__)
#define __TXPIN__ 51 //WAS 3
#define __RXPIN__ 50 //was 10
#define __RXINT__ 50 //was 4
#elif defined(__AVR_ATmega32U4__)
#define __TXPIN__ 3
#define __RXPIN__ 8
#define __RXINT__ 3
#endif


I also tried disabling RXINT to 100 as per Peter_n's post but this did not work.

Any clues welcome. Hope it is clearer now.

thanks
Chris

chrisazzopardi

#7
Jul 31, 2015, 08:10 pm Last Edit: Jul 31, 2015, 08:35 pm by chrisazzopardi
apologies but the pics could not be loaded due to size restrictions.

I am reloading  the Arduino IDE for the library changes to be taken into consideration. I'm unsure as to whether this is the way to do it.

chrisazzopardi

It worked! RXINT can be disabled and I should wait longer for initialisation!


Great forum! Keep it up!

q2dg

If there are inconsistencies in online documentation, I think the best option is to notice it to Github guys via opening an issue

Go Up