problem with gps :( only 0.0000 instead of real data:(

Post here first, or if you can't find a relevant section!
therion
Posts: 13
Joined: Sun Jan 14, 2018 5:47 am

problem with gps :( only 0.0000 instead of real data:(

Post by therion » Sun Jan 14, 2018 6:29 am

Hello
I have very big problem with GPS(NEO-6M) and STM32 (STM32F103C8T6).
I try to recieve gps data, latitude and longtitude, but it dont work.
I have allways only "0.00000" value on screen:( - GPS module is working, led is blinking (when it was blinking on arduino, i had a correct coordinates)
Did anyone of You connect gps module to stm32??

If anyone know how to connect, and can, paste simplest code (and describe pin connection). I am beginner - if i had an working example i could learn how to do what i want. Simplest code, latitude on serial port or something...

Below i paste my code, where is mistake about gps?? Any ideas?
Sorry for my english, i am begginer in stm32 and language skills:)

Code: Select all

#include <TinyGPS++.h> 
#include <SoftSerialIntAP.h>

#include <Adafruit_GFX_AS.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library

#define TFT_CS     PA2
#define TFT_RST    PA4    
#define TFT_DC     PA3
#define TFT_SCK    PA5
#define TFT_SDA    PA7
#define LCDROTATION 2
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS,  TFT_DC, TFT_RST);

// -----------------gps
TinyGPSPlus gps;
static const int RXPin = PB10, TXPin = PB11;
static const uint32_t GPSBaud = 9600;
SoftSerialIntAP ss(15, 16, 3);              //  (15, 16, 3)???
// -----------------gps

// -----------------lcd screen heading
void wyswietlaniegps()
{
tft.setTextSize(2);
tft.setTextColor(ST7735_GREEN,0x0292);
tft.setCursor(16,1);
tft.print("GPS DATA");
tft.drawLine(0,17,127,17,ST7735_GREEN);
}
// -----------------lcd screen heading

void setup() 
{
  Serial.begin(9600);

  ss.begin(GPSBaud);
  while (ss.available() > 0)
    gps.encode(ss.read());
 
  tft.initR(INITR_BLACKTAB);    // start ekranu
  tft.setRotation(LCDROTATION);  // ustawienie obrotu ekranu
  tft.fillScreen(0x0292); // wypelnienie kolorem RGB565
  wyswietlaniegps();}

void loop() 
{

Serial.println("TEST");
Serial.println("-----");
Serial.println(gps.location.lat(),6);
Serial.println("_____");
delay(1000);

tft.setTextSize(2);
tft.setTextColor(ST7735_GREEN,0x0292);
tft.setCursor(10,30);
tft.print(gps.location.lat(),5);
  
tft.setTextSize(2);
tft.setTextColor(ST7735_GREEN,0x0292);
tft.setCursor(10,60);
tft.print(gps.location.lng(),6);

tft.setTextSize(1);
tft.setTextColor(ST7735_GREEN,0x0292);
tft.setCursor(30,90);
tft.print("**TEST**"); 
}

fpiSTM
Posts: 315
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: problem with gps :( only 0.0000 instead of real data:(

Post by fpiSTM » Sun Jan 14, 2018 7:39 am

Hi, assuming you use this lib:
https://github.com/mikalhart/TinyGPSPlus

Have you try first the basic example provided with the lib?

Also have you made some search on the forum. ex:
http://stm32duino.com/viewtopic.php?f=1 ... it=tinyGPS

therion
Posts: 13
Joined: Sun Jan 14, 2018 5:47 am

Re: problem with gps :( only 0.0000 instead of real data:(

Post by therion » Sun Jan 14, 2018 8:20 am

i tried different libraries. On arduino i try basic and full example and it was ok, but not on stm32:(

Yes i was searching on forum, http://stm32duino.com/viewtopic.php?f=1 ... it=tinyGPS - too, but i dont understand it, maybe weak english maybe weak c++.
I was looking on other pages, but after whole day didnt find solution:(
Thats why i asking on forum, maybe i doing something wrong with pinouts? i dont know:(

Working simple code would be best fo learn it...
Arduino examples dont work, only "0.00000" instead of real data.
And i dont have idea why.
What is wrong with my code??

stevestrong
Posts: 2063
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany
Contact:

Re: problem with gps :( only 0.0000 instead of real data:(

Post by stevestrong » Sun Jan 14, 2018 9:05 am

You should try first this example: https://github.com/mikalhart/TinyGPSPlu ... xample.ino
Also, be aware that STM32F103C8 is actually working with 3.3V, not 5V.

Instead of SoftwareSerial you could use a hardware serial interface, the STM32F103C8 has 3 UART ports.
If you do this, then line 2 of the example can be deleted.

Code: Select all

// The serial connection to the GPS device
#define ss SERIAL1 // SoftwareSerial ss(RXPin, TXPin);
...
ss.begin(GPSBaud); // this will use UART1 pins PA9/PA10
In general for STM32, instead of raw numbers (15, 3,...) please use PXY (ex. PA9, PA10) notation for pins.

therion
Posts: 13
Joined: Sun Jan 14, 2018 5:47 am

Re: problem with gps :( only 0.0000 instead of real data:(

Post by therion » Sun Jan 14, 2018 10:40 am

You should try first this example:
i made my code by experimenting on "FullExample" and "Device Example" it not working:(

As You can see in my first code i change tx,rx pins, RXPin = PB10, TXPin = PB11;

STM32 have 3 tx/rx ports.
1: PA9/PA10 - I using it to connect programator
2: PA2/PA3 - lcd tft screen
3: PB10/PB11 - i want to use it to GPS
But i dont know how to do it

I dont know how to use hardware port in gps signal:( i dont know C++, i am hobbyst, and all i can find is too dificult for me:(

Could You change this shortest i can built code, to working code??:

Code: Select all

#include <TinyGPS++.h> 

// -----------------gps
TinyGPSPlus gps;
#define ss3 Serial3
static const uint32_t GPSBaud = 9600;
// -----------------gps

void setup() 
{
  Serial.begin(9600);
  ss3.begin(GPSBaud);
  while (ss3.available() > 0)
  gps.encode(ss3.read());
}
void loop() 
{
Serial.println("TEST");
Serial.println(gps.location.lat(),6);
Serial.println("_____");
delay(1000);
}

stevestrong
Posts: 2063
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany
Contact:

Re: problem with gps :( only 0.0000 instead of real data:(

Post by stevestrong » Sun Jan 14, 2018 10:52 am

I have adapted in your post. Try it.
Serial3 Tx = PB10, Rx = PB11. Check your connection (exchange Rx/Tx) if still not working.
Or use different Baudrate.

therion
Posts: 13
Joined: Sun Jan 14, 2018 5:47 am

Re: problem with gps :( only 0.0000 instead of real data:(

Post by therion » Sun Jan 14, 2018 11:04 am

compilation error:(

exit status 1
'SERIAL3' was not declared in this scope

stevestrong
Posts: 2063
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany
Contact:

Re: problem with gps :( only 0.0000 instead of real data:(

Post by stevestrong » Sun Jan 14, 2018 11:07 am

Yes, sorry, it should be Serial3.
And you should include the GPS data read in the main loop, like this:

Code: Select all

uint32_t time;
void loop() 
{
  if ( (millis()-time)<1000 )
  {
    if (ss3.available())
      gps.encode(ss3.read());
  }
  time = millis();
Serial.println("TEST");
Serial.println(gps.location.lat(),6);
Serial.println("_____");
}

therion
Posts: 13
Joined: Sun Jan 14, 2018 5:47 am

Re: problem with gps :( only 0.0000 instead of real data:(

Post by therion » Sun Jan 14, 2018 11:33 am

still the same error:(
exit status 1
'Serial3' was not declared in this scope

Code: Select all

#include <TinyGPS++.h> 

// -----------------gps
TinyGPSPlus gps;
#define ss3 Serial3
static const uint32_t GPSBaud = 9600;
// -----------------gps

void setup() 
{
  Serial.begin(9600);
  ss3.begin(GPSBaud);
}
uint32_t time;
void loop() 
{
  if ( (millis()-time)<1000 )
  {
    if (ss3.available())
      gps.encode(ss3.read());
  }
  time = millis();
Serial.println("TEST");
Serial.println(gps.location.lat(),6);
Serial.println("_____");
}

stevestrong
Posts: 2063
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany
Contact:

Re: problem with gps :( only 0.0000 instead of real data:(

Post by stevestrong » Sun Jan 14, 2018 11:49 am

Do you use Arduino IDE? Which version?
Which board? Maple mini or "blue pill"?
Do you use the libmaple core (https://github.com/rogerclarkmelbourne/Arduino_STM32) ?
Add

Code: Select all

#include <Arduino.h>

Post Reply