0

Adafruit GPS + Arduino GSM = PROBLEM
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Adafruit GPS + Arduino GSM = PROBLEM

by dachtari on Mon Mar 30, 2015 10:57 am

Hello
I bought an Adafruit Ultimate GPS Breakout - 66 channel w/10 Hz updates - Version 3, to use with arduino GSM shield and arduino uno. When i compile the code

Code: Select all | TOGGLE FULL SIZE
#include <GSM.h>
#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(3, 2);
Adafruit_GPS GPS(&mySerial);
#define GPSECHO  true
boolean usingInterrupt = false;

#define PINNUMBER ""

#define GPRS_APN       "internet.open"
#define GPRS_LOGIN     "user"   
#define GPRS_PASSWORD  "pass"

GPRS gprs;
GSM gsmAccess;     
GSMServer server(80);

const unsigned long __TIMEOUT__ = 10*1000;

void useInterrupt(boolean);
int fsrPin = 0;
int fsrReading;
int fsrVoltage;
unsigned long fsrResistance;
unsigned long fsrConductance;
long fsrForce;
long totfsrForce;
long aakadoy;

void setup()
{
  // initialize serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
 
  // connection state
  boolean notConnected = true;
 
  // Start GSM shield
  // If your SIM has PIN, pass it as a parameter of begin() in quotes
  while(notConnected)
  {
    if((gsmAccess.begin(PINNUMBER)==GSM_READY) &
        (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))
      notConnected = false;
    else
    {
      Serial.println("Not connected");
      delay(1000);
    }
  }
 
  Serial.println("Connected to GPRS network");
 
  // start server
  server.begin();
 
  //Get IP.
  IPAddress LocalIP = gprs.getIPAddress();
  Serial.println("Server IP address=");
  Serial.println(LocalIP);
}

void loop() {
    fsrReading = analogRead(fsrPin);
    fsrVoltage = map(fsrReading, 0, 1023, 0, 5000);
    if (fsrReading < 10) {
    } else {
    aakadoy = aakadoy + 1;
    Serial.print("No OF WASTE BIN: ");
    Serial.println(aakadoy);
    fsrResistance = 5000 - fsrVoltage;
    fsrResistance *= 10000;
    fsrResistance /= fsrVoltage;
    fsrConductance = 1000000;
    fsrConductance /= fsrResistance;
    if (fsrConductance <= 1000) {
    fsrForce = fsrConductance / 80 * (1000 / 9.81);
    Serial.print("WEIGHT OF WASTE BIN in gr: ");
    Serial.println(fsrForce);
    } else {
    fsrForce = fsrConductance - 1000;
    fsrForce /= 30 * (1000 / 9.81);
    Serial.print("WEIGHT OF WASTE BIN in gr: ");
    Serial.println(fsrForce);
    }
    totfsrForce = totfsrForce + fsrForce;
    Serial.print("TOTAL NET WEIGHT OF GARBAGE TRUCK in gr: ");
    Serial.println(totfsrForce);
    Serial.println("PROJECT:GARBAGE TRUCK MANAGEMENT, MUNICIPALITY OF TYRNAVOS (6th EPAL, LARISA)");
    Serial.println("----------------------------------------");
    fsrReading = analogRead(fsrPin);
    if (fsrReading == 0) {
    }
    else {
    while (fsrReading > 0) { 
    delay(10);
    fsrReading = analogRead(fsrPin);
    }
    }
    }
    delay(1000);
 
  GSMClient client = server.available();

  if (client)
  { 
    while (client.connected())
    {
      if (client.available())
      {
        Serial.println("Receiving request!");
        bool sendResponse = false;
        while(char c=client.read()) {
          if (c == '\n') sendResponse = true;
        }

       if (sendResponse)
       {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          client.println("<html>");
          client.print("No OF WASTE BIN: ");
          client.println(aakadoy);
          client.println("<br />");       
          client.println("<br />");                 
          client.print("WEIGHT OF WASTE BIN in gr: ");
          client.println(fsrForce);
          client.println("<br />");                 
          client.println("<br />");       
          client.print("TOTAL NET WEIGHT OF GARBAGE TRUCK in gr: ");
          client.println(totfsrForce);
          client.println("<br />");                 
          client.println("<br />");       
          client.println("PROJECT:GARBAGE TRUCK MANAGEMENT, MUNICIPALITY OF TYRNAVOS (6th EPAL, LARISA)");
          client.println("</html>");
          delay(1000);
          client.stop();
        }
    }
    }
  }
}


i have error message at the compilation. The error message is

Code: Select all | TOGGLE FULL SIZE
Arduino: 1.6.1 (Windows XP), Board: "Arduino Uno"

SoftwareSerial\SoftwareSerial.cpp.o: In function `__vector_3':
C:\Program Files\Arduino\hardware\arduino\avr\libraries\SoftwareSerial/SoftwareSerial.cpp:227: multiple definition of `__vector_3'
GSM\GSM3SoftSerial.cpp.o:C:\Program Files\Arduino\libraries\GSM\src/GSM3SoftSerial.cpp:499: first defined here
SoftwareSerial\SoftwareSerial.cpp.o: In function `SoftwareSerial::read()':
C:\Program Files\Arduino\hardware\arduino\avr\libraries\SoftwareSerial/SoftwareSerial.cpp:392: multiple definition of `__vector_4'
GSM\GSM3SoftSerial.cpp.o:C:\Program Files\Arduino\libraries\GSM\src/GSM3SoftSerial.cpp:487: first defined here
SoftwareSerial\SoftwareSerial.cpp.o: In function `SoftwareSerial::read()':
C:\Program Files\Arduino\hardware\arduino\avr\libraries\SoftwareSerial/SoftwareSerial.cpp:392: multiple definition of `__vector_5'
GSM\GSM3SoftSerial.cpp.o:C:\Program Files\Arduino\libraries\GSM\src/GSM3SoftSerial.cpp:487: first defined here
collect2.exe: error: ld returned 1 exit status
Error compiling.

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.


If i comment adafruit libraries compilation is ok. What's going wrong?

dachtari
 
Posts: 15
Joined: Sat Nov 15, 2014 6:48 am

Re: Adafruit GPS + Arduino GSM = PROBLEM

by adafruit_support_rick on Mon Mar 30, 2015 11:34 am

The GSM library is incompatible with SoftwareSerial. Please see this post for instructions on how to fix the problem:
viewtopic.php?f=25&t=38764&hilit=altsoftserial&start=15#p212305

This version of the Adafruit GPS library has been modified to work with the AltSoftSerial library:
Adafruit_GPS_Alt.zip
(16 KiB) Downloaded 86 times

In your sketch, remove all references to SoftwareSerial and replace them with AltSoftSerial. Also, replace references to Adafruit_GPS with references to Adafruit_GPS_Alt

adafruit_support_rick
 
Posts: 35095
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Adafruit GPS + Arduino GSM = PROBLEM

by dachtari on Sun Apr 19, 2015 4:15 pm

I made what you say. Althought compilation of the code now is ok, the project don't work. The serial monitor after loading the code is EMPTY. I use the example GsmWebServer with example parsing. Here is the code:
Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_GPS_Alt.h>
#include <AltSoftSerial.h>
AltSoftSerial mySerial;
Adafruit_GPS_Alt GPS(&mySerial);
#define GPSECHO  true
boolean usingInterrupt = false;
void useInterrupt(boolean);


// libraries
#include <GSM.h>

// PIN Number
#define PINNUMBER ""

#define GPRS_APN       "internet.open"
#define GPRS_LOGIN     "user"   
#define GPRS_PASSWORD  "pass"

// initialize the library instance
GPRS gprs;
GSM gsmAccess;     // include a 'true' parameter for debug enabled
GSMServer server(80); // port 80 (http default)

// timeout
const unsigned long __TIMEOUT__ = 10*1000;

void setup()
{
  // initialize serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
 
  // connection state
  boolean notConnected = true;
 
  // Start GSM shield
  // If your SIM has PIN, pass it as a parameter of begin() in quotes
  while(notConnected)
  {
    if((gsmAccess.begin(PINNUMBER)==GSM_READY) &
        (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))
      notConnected = false;
    else
    {
      Serial.println("Not connected");
      delay(1000);
    }
  }
 
  Serial.println("Connected to GPRS network");
 
  // start server
  server.begin();
 
  //Get IP.
  IPAddress LocalIP = gprs.getIPAddress();
  Serial.println("Server IP address=");
  Serial.println(LocalIP);

  GPS.begin(9600);
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);   // 1 Hz update rate
  GPS.sendCommand(PGCMD_ANTENNA);
  useInterrupt(true);
  delay(1000);
  mySerial.println(PMTK_Q_RELEASE);

}

SIGNAL(TIMER0_COMPA_vect) {
  char c = GPS.read();
#ifdef UDR0
  if (GPSECHO)
    if (c) UDR0 = c; 
#endif
}

void useInterrupt(boolean v) {
  if (v) {
    OCR0A = 0xAF;
    TIMSK0 |= _BV(OCIE0A);
    usingInterrupt = true;
  } else {
    TIMSK0 &= ~_BV(OCIE0A);
    usingInterrupt = false;
  }
}
uint32_t timer = millis();



void loop() {
  if (! usingInterrupt) {
    char c = GPS.read();
    if (GPSECHO)
      if (c) Serial.print(c);
  }
  if (GPS.newNMEAreceived()) {
    if (!GPS.parse(GPS.lastNMEA()))   
      return; 
  }
  if (timer > millis())  timer = millis();
  if (millis() - timer > 2000) {
    timer = millis();
   
    Serial.print("\nTime: ");
    Serial.print(GPS.hour, DEC); Serial.print(':');
    Serial.print(GPS.minute, DEC); Serial.print(':');
    Serial.print(GPS.seconds, DEC); Serial.print('.');
    Serial.println(GPS.milliseconds);
    Serial.print("Date: ");
    Serial.print(GPS.day, DEC); Serial.print('/');
    Serial.print(GPS.month, DEC); Serial.print("/20");
    Serial.println(GPS.year, DEC);
    Serial.print("Fix: "); Serial.print((int)GPS.fix);
    Serial.print(" quality: "); Serial.println((int)GPS.fixquality);
    if (GPS.fix) {
      Serial.print("Location: ");
      Serial.print(GPS.latitude, 4); Serial.print(GPS.lat);
      Serial.print(", ");
      Serial.print(GPS.longitude, 4); Serial.println(GPS.lon);
      Serial.print("Speed (knots): "); Serial.println(GPS.speed);
      Serial.print("Angle: "); Serial.println(GPS.angle);
      Serial.print("Altitude: "); Serial.println(GPS.altitude);
      Serial.print("Satellites: "); Serial.println((int)GPS.satellites);
    }
  }


  // listen for incoming clients
  GSMClient client = server.available();



  if (client)
  { 
    while (client.connected())
    {
      if (client.available())
      {
        Serial.println("Receiving request!");
        bool sendResponse = false;
        while(char c=client.read()) {
          if (c == '\n') sendResponse = true;
        }

     // if you've gotten to the end of the line (received a newline
     // character)
       if (sendResponse)
       {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          client.println("<html>");
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(analogRead(analogChannel));
            client.println("<br />");       
          }
          client.println("</html>");
          //necessary delay
          delay(1000);
          client.stop();
        }
      }
    }
  }
}

Why?

dachtari
 
Posts: 15
Joined: Sat Nov 15, 2014 6:48 am

Re: Adafruit GPS + Arduino GSM = PROBLEM

by adafruit_support_rick on Sun Apr 19, 2015 4:36 pm

Have you tried running a simple GPS sketch, without the GSM stuff? Do you get anything from that?

How is the GPS wired to the Arduino? Can you post a picture of your wiring?

adafruit_support_rick
 
Posts: 35095
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Adafruit GPS + Arduino GSM = PROBLEM

by dachtari on Mon Apr 20, 2015 2:00 am

The simple GPS sketch ("parsing" - example of the library Adafruit_GPS_Alt) runs perfectly. The same for the simple GSM sketch ("GsmWebServer" - example of the library GSM) which runs perfectly too.
Wiring: the GPS TX (transmit) pin is connecting to Digital 8 and the GPS RX (receive) pin is connecting to Digital 9. I'll try to send you a picture.

dachtari
 
Posts: 15
Joined: Sat Nov 15, 2014 6:48 am

Re: Adafruit GPS + Arduino GSM = PROBLEM

by dachtari on Mon Apr 20, 2015 2:05 am

Here is the picture.
Attachments
IMG.jpg
Wiring
IMG.jpg (34.4 KiB) Viewed 1004 times

dachtari
 
Posts: 15
Joined: Sat Nov 15, 2014 6:48 am

Re: Adafruit GPS + Arduino GSM = PROBLEM

by adafruit_support_rick on Mon Apr 20, 2015 8:34 am

And with the combined sketch you get nothing at all on Serial Monitor? Not even the bit about "Connected to GPRS network"? Hmmm...

I wonder if you've got a memory problem. Seems unlikely, but let's check. Add this function, call it right after Serial.begin, and print out the result:
Code: Select all | TOGGLE FULL SIZE
int freeRam ()
{
  extern int __heap_start, *__brkval;
  int v;
  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}


Code: Select all | TOGGLE FULL SIZE
  // initialize serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  Serial.print(F("free ram ")); Serial.println(freeRam());

adafruit_support_rick
 
Posts: 35095
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Adafruit GPS + Arduino GSM = PROBLEM

by dachtari on Mon Apr 20, 2015 9:24 am

"free ram 108" is the result.
Attachments
IMG.jpg
IMG.jpg (235.63 KiB) Viewed 987 times

dachtari
 
Posts: 15
Joined: Sat Nov 15, 2014 6:48 am

Re: Adafruit GPS + Arduino GSM = PROBLEM

by dachtari on Mon Apr 20, 2015 9:36 am

Notice that the IDE (till now) is 1.0.5-r2.


When i compile the sketch at IDE 1.0.6 i get the following:
"This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Arduino: 1.0.6 (Windows XP), Board: "Arduino Uno"
C:\Program Files\Arduino\libraries\GSM\GSM3ShieldV1ModemVerification.cpp: In member function 'String GSM3ShieldV1ModemVerification::getIMEI()':
C:\Program Files\Arduino\libraries\GSM\GSM3ShieldV1ModemVerification.cpp:72: error: conversion from 'int' to 'String' is ambiguous
C:\Program Files\Arduino\hardware\arduino\cores\arduino/WString.h:61: note: candidates are: String::String(const __FlashStringHelper*)
C:\Program Files\Arduino\hardware\arduino\cores\arduino/WString.h:59: note: String::String(const char*)"

dachtari
 
Posts: 15
Joined: Sat Nov 15, 2014 6:48 am

Re: Adafruit GPS + Arduino GSM = PROBLEM

by adafruit_support_rick on Mon Apr 20, 2015 10:39 am

OK, you're running out of SRAM. 108 is not enough free ram to run. You can see that the processor is restarting over and over again - that's because it's crashing due to lack of memory. You'll have to move to another processor, like a Leonardo or a Mega. The Leonardo has an extra 512 bytes of SRAM - I don't know if that will be enough for you. You're probably better off with a Mega.

The error you're seeing is in the GSM library. I don't know how to fix that.

adafruit_support_rick
 
Posts: 35095
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Adafruit GPS + Arduino GSM = PROBLEM

by dachtari on Fri Apr 24, 2015 2:33 am

The project as you see is simple. Is it better to buy fona or sim900 as gsm shield? This will solve the problem? I saw posts with similar projects that work ok.

dachtari
 
Posts: 15
Joined: Sat Nov 15, 2014 6:48 am

Re: Adafruit GPS + Arduino GSM = PROBLEM

by adafruit_support_rick on Fri Apr 24, 2015 10:34 am

I don't know if FONA will use any less memory.

Before you do any of that, you're got a lot of literal strings in there. The compiler puts those in SRAM, even through they are static and never change. Apply the F() macro to all of your literal strings. That should free up a lot of SRAM, maybe enough for your sketch to run:

https://learn.adafruit.com/memories-of- ... se-strings

adafruit_support_rick
 
Posts: 35095
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Adafruit GPS + Arduino GSM = PROBLEM

by dachtari on Sat Apr 25, 2015 4:16 am

Ok i tried F() macro and i have free ram 250. But i need more code. Is it a solution to buy your fram 1595 or 1597 products?

dachtari
 
Posts: 15
Joined: Sat Nov 15, 2014 6:48 am

Re: Adafruit GPS + Arduino GSM = PROBLEM

by adafruit_support_rick on Sat Apr 25, 2015 10:39 am

Does it work with 250 bytes of free SRAM? More code won't necessarily use up more SRAM.

The FRAM products are for external storage. They won't expand your SRAM. Your only option to get more SRAM is to go with a Leonardo or a Mega or a Due.

adafruit_support_rick
 
Posts: 35095
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Adafruit GPS + Arduino GSM = PROBLEM

by dachtari on Sat Apr 25, 2015 12:07 pm

Do you know if there are other products that expand SRAM?

Till now it works. If the only solution is to change shield i'll buy a mega arduino.

dachtari
 
Posts: 15
Joined: Sat Nov 15, 2014 6:48 am

Please be positive and constructive with your questions and comments.