Arduino GPS module doesn't work when LMiC is used

I’ve found strange problem. When I use temperature sensor with LMiC library everything goes fine, but as soon as I move to GPS sensor (I2C, version GY-GPS6MV2 with U-blox Neo-6m-0-001) data stop coming from GPS.

I add GPS acquire to the beginning of loop() but seems it is already not getting anything after LMiC os_init() function.

I’ve tried LMiC versions 1.50 and 1.51 and both Arduino Mega and Arduino Uno. Still doesn’t work.

Here’s my test code to make sure that data comes from GPS and it works: GPS_only.ino
Here’s the code taken from LMiC 1.51 ABP example where I’ve added code from ‘GPS only.ino’ : ABP_LoRaWAN_GPS.ino

It does send ‘Hello World’ by LoRaWAN but GPS doesn’t work =(

If I comment out LMIC code GPS data start coming again:

// LMIC init
os_init();
// Reset the MAC state. Session and pending data transfers will be discarded.
LMIC_reset();
// Set static session parameters. Instead of dynamically establishing a session
// by joining the network, precomputed session parameters are be provided.
LMIC_setSession (0x1, msbf4_read(DevAddr), (uint8_t*)NwkSkey, (uint8_t*)AppSkey);
// Disable data rate adaptation
LMIC_setAdrMode(0);
// Disable link check validation
LMIC_setLinkCheckMode(0);
// Disable beacon tracking
LMIC_disableTracking ();
// Stop listening for downstream data (periodical reception)
LMIC_stopPingable();
// Set data rate and transmit power (note: txpow seems to be ignored by the library)
LMIC_setDrTxpow(DR_SF7,14);

Looks like the LMiC library conflicts with TinyGPS++ library.
Did someone managed this somehow?
May be some other libraries should be used to make simple GPS tracker?

Thank you in advance for answers.

In your loop() function, you have:

      while(1) {
                os_runloop_once(); 
                delay(100);     
      } 

That will keep runnig forever, so the code will never reach the GPS code above it anymore (it will run only once, when the GPS has not had time to send anything yet).

I think you should read up a bit more on how programming works and try to actually understand the code you’re using, since it looks like you mostly copy-pasted code together without really understanding it (which might work, but really limits how far you’ll get…)

My stupid, thank you for pointing this to me! Looks like I’ve just had blind-spot on this loop =)

The problem was much deeper.
Pins 52,53 on Arduino Mega 2560 that I used was conflicted with SPI pins of LoRa shield (error comes from line SPI.begin from hal_init() function of os_init () function.

On Arduino Mega hardware Serial ports should be used for GPS module instead of SoftwareSerial.

Possible options are:
Serial0 is pins 0 (rx) & 1 (tx)
Serial1 is pins 18 (rx) & 19 (tx)
Serial2 is pins 16 (rx) & 17 (tx)
Serial3 is pins 14 (rx) & 15 (tx)

I’ve tried many pins with SoftwareSerial, but they are not working mostly.

Hi !
I am having the same problem right now with an Arduino Uno, did you make it work by any chance ? and thanks !!

did you READ this topic… ??

Yes of course, I am trying to send GPS coordinates using a Dragino LoRa GPS Sheild, the tinygps Library and the LMIC library for Arduino, however I am having the same issues as onlyselain. the GPS code executes perfectly but when I add the LMIC parts it doesnt execute anymore. Any help please ?

yes but he solved it using hardware serial from the arduino mega (instead of software serial) , something that’s not available in your uno

For Software Serial you need to use predefined Rx , Tx pins of Arduino rather than defining any other pins of it for Rx,Tx
for connecting those to Rx Tx of tempterature sensor.
For GPS try to define any 2 pins of Arduino as Rx Tx so that you can connect them to Rx Tx of GPS.Hope this helps you.

why did you use I2C? I couldn’t find any references to such a board
I only find that the board has serial I/O with 9600bps.
My equivalent one (PAM-7Q) runs with TinyGPS++ on SowftwareSerial on an Arduino Pro Mini, RFM95W

can you share the sketch with me . Im having problem of connecting my neo 6m gps connected to arduino Uno but it shows “Low memory available, stability problems may occur” as i need to connect 2 more sensor to the board

@ursm last posted in june 2019, so may not be around to answer.

If your using a UNO and are already getting low memory errors, then you might struggle to clear that and add two more sensors as well.

Might be time for a processor with more memory.

As @LoRaTracker says, time for an upgrade to a Nano Every (ATMega4809) with substantial more RAM (6k vs 2k).

Also, if you are using a u-Blox over I2C, they have some clock stretching issues with I2C that you may want to look at.