GPS Code not working

There's an error in void setup, TinyGPS++.begin. Anyone can help me?

Arduino_Lora_GPS_Tx.ino (2.51 KB)

Error.txt (696 Bytes)

Can anyone help me? I got this trouble

//Libraries for LoRa
#include <SPI.h>
#include <LoRa.h>
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
 
//rx tx dibalik pinnya
static const int RXPin = 3, TXPin = 4;
static const uint32_t GPSBaud = 9600;

#define TinyGPS++

// The TinyGPS++ object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);
 
//define the pins used by the LoRa transceiver module
#define cs  10
#define rst 8
#define irq 2
 
#define BAND 915E6    //433E6 for Asia, 866E6 for Europe, 915E6 for North America
 
//packet counter
int readingID = 0;
 
int counter = 0;
String LoRaMessage = "";
 
float Latitude = 0;
float Longitude = 0;
float Speed = 0;
 
 
 
//Initialize LoRa module
void startLoRA()
{
  LoRa.setPins(cs, rst, irq); //setup LoRa transceiver module
 
  while (!LoRa.begin(BAND) && counter < 10) {
    Serial.print(".");
    counter++;
    delay(500);
  }
  if (counter == 10) 
  {
    // Increment readingID on every new reading
    readingID++;
    Serial.println("Starting LoRa failed!"); 
  }
  Serial.println("LoRa Initialization OK!");
  delay(2000);
}
 
void startGPS()
{
  if (isnan(Latitude) || isnan(Longitude) || isnan(Speed))
  {
  Serial.println("Failed to read from DHT sensor!");
  return;
  }
}
 
void getReadings(){
  // This sketch displays information every time a new sentence is correctly encoded.
  while (ss.available() > 0){
    gps.encode(ss.read());
    if (gps.location.isUpdated()){
      
      Serial.print("Sending packet: ");
      Serial.println(counter);
  // Latitude in degrees (double)
      Serial.print("Latitude= "); 
      Serial.print(gps.location.lat(), 6);      
      // Longitude in degrees (double)
      Serial.print(" Longitude= "); 
      Serial.println(gps.location.lng(), 6); 
       // Speed in kilometers per hour (double)
      Serial.print("Speed in km/h = "); 
      Serial.println(gps.speed.kmph()); 
    }
}
}
 
void sendReadings() {
  LoRaMessage = String(readingID) + "/" + String(Latitude) + "&" + String(Longitude)  + "&" + String(Speed);
  //Send LoRa packet to receiver
  LoRa.beginPacket();
  LoRa.print(LoRaMessage);
  LoRa.endPacket();
  
  Serial.print("Sending packet: ");
  Serial.println(readingID);
  readingID++;
  Serial.println(LoRaMessage);
}
 
void setup() {
  //initialize Serial Monitor
  Serial.begin(9600);
  ss.begin(GPSBaud);
  TinyGPS++.begin();
  startGPS();
  startLoRA();
}
void loop() {
  getReadings();
  sendReadings();
  delay(5000);
}
Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"

C:\Users\ASUS\Documents\Arduino\Arduino_Lora_GPS_Tx\Arduino_Lora_GPS_Tx.ino: In function 'void setup()':

Arduino_Lora_GPS_Tx:105:12: error: expected primary-expression before '.' token

   TinyGPS++.begin();

            ^

Multiple libraries were found for "SoftwareSerial.h"

 Used: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial

 Not used: C:\Users\ASUS\Documents\Arduino\libraries\SoftwareSerial-master

exit status 1

expected primary-expression before '.' token



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

First off read the post General Guidance and How to use the Forum for details on how to post code so everyone can read it easily.

There's an error in void setup, TinyGPS++.begin. Anyone can help me?

You can help yourself with this sort of error.

The TinyGPS++ library you downloaded will have working example programs, do any of those examples use a
TinyGPS++.begin function ?

Topics merged