Go Down

Topic: Speedometer using UNO and GPS (Read 819 times) previous topic - next topic

Railroader

Hi!

I wish to measure speed when driving real trains. On one train the built in speed indikator gets stuck at 20 mph. Trying to drive 30 mph resulted in a speed of 40 mph. Another unit shows 40 mph when the actual speed is only 30 mph. Yes, I'm driving veteran trains.

I tested a number of speedometers using my smartphone (Sony) but they all suffered from the same illness. They hang up, get froozen, for long period of time.

Using a Garmin Zumo 550 on a railroad gave very strange Readings, half the real speed. It wants to follow a country road, not a railroad track.

Would it be possible to create a speedometer using an UNO and GPS boards that will work better? What kind of GPS hardware would be needed?
I have no knowledge yet about what's needed in the respect of number of satelites needed, number of channels etc.

Regards,
Railroader


 

groundFungus

I have had good results using an Uno and Ublox NEO-6M GPS Module for measuring speed.  There are several libraries available to read and parse GPS information  (TinyGPS, TinyGPS++ and NeoGPS).   And lots of tutorials if you Google "arduino neo6m gps".

Railroader

Thanks a lot gF!

Exactly the kind of help I hoped for. Some loose end to start pulling...
Checked Your link but got the message that that board is sold out, not available and no knowledge when or if it will be available again.

Do You know any similar board?

Regards,
Railroader

groundFungus

Just Google "Ublox neo6m".  It is a very popular module.  I just put up that link cause it was at the top of my search.  Sorry that I did not notice out of stock.

Here is another from Amazon.

And they can be found on Ebay for less money if you are willing to wait for shipping from China.

Railroader

I did Google "Ublox neo6m" and got lots of information, way beyond what I can handle. They have intelligent circuits but I prefer a ready board that can be connected to an UNO.
NEO-8Q u-blox 8 GNSS module looks like possible but I feel I need a complete board.

Following Your next tip, to check Amazon, was good. I f1ound the board You tipped me in the first place. I ordered it on the spot. Shipping costs are 67% of the value of the product.... Delivered by a white gloved servant? I'm joking. Never mind, I am most thankful for Your help.

I will see if I can find enough documentation about the board so I can connect it to an UNO. The libraries You suggested I think will be very valuable.


Thank You very much for Your help!

Regards,
Stefan

Railroader

Hi groundFungus,

Today I received an envelope containing the GPS module and its antenna. The antenna metall shield has a bend almost parallell to one of the sides. One corner, near the bend, is soldered to the pcb, the other corner is like standing on the pcb.

Did Your modules look like this?

I ask You because it will take me quite some time before I can wire it up, test and verify that the circuits are all ok. eBay will not accepts any complains comming that late.

Tine GPS library is downloaded and the wiring also. I read about the need for better SoftwareSerial…. The project is advancing.

Regards,



groundFungus

My Neo 6M has the antenna separate from the GPS module connected by a little cable approximately 20mm long.  Mine looks just like the photo in reply #3.

Railroader


Thanks a lot!
The picture is very light but it looks flat. My one is physicaly modified.
It was bought from Amazon, not eBay so now I found a link to the seller..


Railroader

Hi again gF!

I got upset and missed an observation and a one piece of information. Your picture shows the front side and that is okey. What I am looking at is the back side, the shielding metall can, that looks like taking a punch.


Railroader

Hi!

1) How do I define the UNO pins for RX/TX running Tiny GPS++?
2) How do I find answers given to me on other, earlier questions?


1) I got help from the seller of the GPS and now I have got hold of the library TinyGPS++ and succesfully compiled the example file "Basic".


2) Earlier I got help from Forum regarding a question about the serial ports. Looking through 15 pages I can't find the answer I got then.




groundFungus

#10
Jun 21, 2018, 10:36 pm Last Edit: Jun 21, 2018, 10:42 pm by groundFungus
You don't need to connect the Uno TX to the GPS RX for initial testing.  If you do connect Uno TX to GPS RX make sure that the GPS RX can tolerate 5V, otherwise you need to drop the voltage to 3.3V or less.

A TinyGPS++ tutorial page.
You create an instance of SoftwareSerial and set the pins in the constructor.

Code: [Select]
#include <SoftwareSerial.h>
SoftwareSerial mySerial(RX, TX);  // pick any 2 unused digital pins (not pins 0 or 1)


Don't forget the begin in setup()

Code: [Select]
mySerial.begin(9600);  // 9600 is the default baud rate for my Neo6m units

See the above linked tutorial and the examples from the library to see how to feed TinyGPS with the serial input. 

Railroader

Thanks a lot gF!

I bought the Ublox NEO-6M GPS Module with EEPROM for MWC/AeroQuad with Antenna for Flight Control and Aircraft just as You tipped me.

 Description:
 GPS modules NEO-6M, 3V-5V power supply Universal.

That tells me that 5V logic works well.


I suffor from an earlier mental overload at work. That makes me have big trouble with scanning large amounts of information and finding the gold in it. I have looked into the tutorial You advise. Maybe I can find some more keeping on.

The following code compiles OK.

SORRY, I CAN NOt FIND THE CODE TAG TOOLS IN THIS MOMENT. Sending a file in the first question works but adding code later... I have failed before.

#include <TinyGPS++.h>
/*
   This sample sketch should be the first you try out when you are testing a TinyGPS++
   (TinyGPSPlus) installation.  In normal use, you feed TinyGPS++ objects characters from
   a serial NMEA GPS device, but this example uses static strings for simplicity.
*/

// A sample NMEA stream.
const char *gpsStream =
  "$GPRMC,045103.000,A,3014.1984,N,09749.2872,W,0.67,161.46,030913,,,A*7C\r\n"
  "$GPGGA,045104.000,3014.1985,N,09749.2873,W,1,09,1.2,211.6,M,-22.5,M,,0000*62\r\n"
  "$GPRMC,045200.000,A,3014.3820,N,09748.9514,W,36.88,65.02,030913,,,A*77\r\n"
  "$GPGGA,045201.000,3014.3864,N,09748.9411,W,1,10,1.2,200.8,M,-22.5,M,,0000*6C\r\n"
  "$GPRMC,045251.000,A,3014.4275,N,09749.0626,W,0.51,217.94,030913,,,A*7D\r\n"
  "$GPGGA,045252.000,3014.4273,N,09749.0628,W,1,09,1.3,206.9,M,-22.5,M,,0000*6F\r\n";

// The TinyGPS++ object
TinyGPSPlus gps;

#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3);  // pick any 2 unused digital pins (not pins 0 or 1)
void setup()
{

  mySerial.begin(9600);  // 9600 is the default baud rate for my Neo6m units 
//  Serial.begin(115200);

  mySerial.println(F("BasicExample.ino"));
  mySerial.println(F("Basic demonstration of TinyGPS++ (no device needed)"));
  mySerial.print(F("Testing TinyGPS++ library v. ")); Serial.println(TinyGPSPlus::libraryVersion());
  mySerial.println(F("by Mikal Hart"));
  mySerial.println();

  while (*gpsStream)
    if (gps.encode(*gpsStream++))
      displayInfo();

  mySerial.println();
  mySerial.println(F("Done."));
}

void loop()
{
}

void displayInfo()
{
  mySerial.print(F("Location: "));
  if (gps.location.isValid())
  {
    mySerial.print(gps.location.lat(), 6);
    mySerial.print(F(","));
    mySerial.print(gps.location.lng(), 6);
  }
  else
  {
    mySerial.print(F("INVALID"));
  }

  mySerial.print(F("  Date/Time: "));
  if (gps.date.isValid())
  {
    mySerial.print(gps.date.month());
    mySerial.print(F("/"));
    mySerial.print(gps.date.day());
    mySerial.print(F("/"));
    mySerial.print(gps.date.year());
  }
  else
  {
    mySerial.print(F("INVALID"));
  }

  mySerial.print(F(" "));
  if (gps.time.isValid())
  {
    if (gps.time.hour() < 10) mySerial.print(F("0"));
    mySerial.print(gps.time.hour());
    mySerial.print(F(":"));
    if (gps.time.minute() < 10) mySerial.print(F("0"));
    mySerial.print(gps.time.minute());
    mySerial.print(F(":"));
    if (gps.time.second() < 10) mySerial.print(F("0"));
    mySerial.print(gps.time.second());
    mySerial.print(F("."));
    if (gps.time.centisecond() < 10) mySerial.print(F("0"));
    mySerial.print(gps.time.centisecond());
  }
  else
  {
    mySerial.print(F("INVALID"));
  }

  mySerial.println();

I am very, very thankful for Your help!

Railroader

Can some system administrator erase my last previous writing? It's of no good, brainless.
Ralroader.

Railroader

More work, new attempts and thanks for the help given earlier.

I worked throgh the example file "Basic" ok. There I added some debug printing of GPS parameters and got some figures that where not correct. Possible, but not correct. Lat, long, Date, time. I tried "Valid" and I tried "Updated". Only ALTITUDE was updated, the others where valid.

I proceeded testing the example file "Device example" and got the message "No GPS detected: check wiring".
The GPS module rests some 5 feet from a window.

I would like to attach the two test files but I can't find the code window makers  and that would fill pages.

Do You, Forum, have Power to another round?


groundFungus


First can we just get the GPS module talking?  For that you do not need any library except SoftwareSerial.  The following sketch works with my Neo6M.  Connect Vcc to 5V, gnd to gnd and GPS TX to Uno soft serial RX (pin 4 in the sketch).  No need for GPS RX to be connected.  Note baud rate for soft serial is 9600, the default for Neo6M.  The baud rate for serial monitor to 115200.   Load and run the code.

Code: [Select]
#include <SoftwareSerial.h>

SoftwareSerial mySerial(4, 7); // RX, TX
// do not connect GPS RX to Uno TX, there is no need yet, if ever.

void setup()
{
   Serial.begin(115200);
   Serial.println("GPS basic input test");
  
   mySerial.begin(9600);
}

void loop()   // run over and over
{
   if (mySerial.available())
   {
      Serial.write(mySerial.read());
   }
}


The GPS spits out a series of sentences every second.  You should see in the serial monitor something very like the following:

Quote
GPS basic input test
$GPRMC,175020.00,V,,,,,,,230618,,,N*72
$GPVTG,,,,,,,,,N*30
$GPGGA,175020.00,,,,,0,00,99.99,,,,,,*67
$GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30
$GPGSV,1,1,03,17,,,32,19,,,30,28,,,27*79
$GPGLL,,,,,175020.00,V,N*4B
$GPRMC,175021.00,V,,,,,,,230618,,,N*73
$GPVTG,,,,,,,,,N*30
$GPGGA,175021.00,,,,,0,00,99.99,,,,,,*66
$GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30
$GPGSV,1,1,03,17,,,32,19,,,30,28,,,26*78
$GPGLL,,,,,175021.00,V,N*4A
$GPRMC,175022.00,V,,,,,,,230618,,,N*70
$GPVTG,,,,,,,,,N*30
This is the GPS output without any satellite lock.

Is this what you see?  

Go Up