New Homepage Forums Sensor Shields Empty Latitude and Longtitude GPS values

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by avatar xryuji 1 year, 7 months ago. This post has been viewed 328 times

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #122776
    avatarxryuji
    Participant

    Hi. im trying to use the GPS shield of 1sheeld but in the 1sheeld terminal it giving me an empty values. please help. heres my codes:

    #define CUSTOM_SETTINGS
    #define INCLUDE_SMS_SHIELD
    #define INCLUDE_GPS_SHIELD
    #define INCLUDE_PHONE_SHIELD /* Key to Open Phone Shield so you can use it*/
    #define INCLUDE_TERMINAL_SHIELD
    #include <OneSheeld.h>
    const int buttonPin = 2; // the number of the pushbutton pin
    boolean isMessageSent=false;
    int buttonState = 0;
    float lat ;
    float lon ;
    char charlat [30];
    char charlon [30];
    char readings [100];

    void setup() {
    OneSheeld.begin();

    }

    void loop() {

    //buttonState = digitalRead(buttonPin);

    // if (buttonState == HIGH) {
    //Serial.println(readings);// turn LED on:
    //SMS.send(“09350871743″, readings);
    lat = GPS.getLatitude(); lon = GPS.getLongitude();
    dtostrf(lat, 7, 3, charlat); dtostrf(lon, 7, 3, charlon);
    strcat(readings,”GPS Coordinates : \n”);
    strcat(readings,”latitude is : “); strcat (readings,charlat);
    strcat(readings,”\nLongitude is : “); strcat (readings,charlon);
    Terminal.println(readings);
    //Terminal.println(charlon);
    OneSheeld.delay(1000);

    // } else {

    // }

    // // change number with your own here

    }

    #122872
    avatarAmr
    Keymaster

    Hi,

    I have made some change to your code to get it to work properly, here is it:

    Give it a try and let me know if you got it working 🙂

    And one good thing to do with the terminal shield is to use the Terminal.println(); for printing on new line OR Terminal.print(); for printing on the same line instead of using ‘\n’ and strings concatenation.

    #123915
    avatarxryuji
    Participant

    Thank you!! It works!!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.