Resend my activation email : Register : Log in 
BCF: Bike Chat Forums


Arduino GPS Speedo

Reply to topic
Bike Chat Forums Index -> The Geek Zone Goto page Previous  1, 2
View previous topic : View next topic  
Author Message

WD Forte
World Chat Champion



Joined: 17 Jun 2010
Karma :

PostPosted: 18:42 - 12 May 2020    Post subject: Reply with quote

After a lot of kerfuffle,dummy spitting and toy throwing
I got the gps and display to play together and update gps data
(sorry about the hastily grabbed shitty fone pic.)

https://imgur.com/jQmnKz2.jpg



At last I have working base I can develop further.
Woo hoo!
The SSD1306 libraries are only working in 128x32 mode on my SH1106 display at the mo
but they are light on RAM, while using the SH1106 libraries as in the pic, sucks up way too much
of the Nanos weeny 2K of RAM

No matter, I can develop/finesse/optimise it from here
I'm just relieved to get the sod working after the muddle I got in.

Mistakes:
how long have you got?
to name a few.
I grabbed/copied far too many code samples and utterly confused myself
I mullered up the library locations
I'd set the IDE to 'save code on compile' which was stoopid
as you should only save what works
plus others like not RTFM

Clearing garbage, resetting stuff and going back to basics helped me get on track.
I did notice the initial TTFF took a couple of minutes while subsequent ones were very fast.
Maybe cos indoors on a desk?
____________________
bikers smell of wee
 Back to top
View user's profile Send private message You must be logged in to rate posts

WD Forte
World Chat Champion



Joined: 17 Jun 2010
Karma :

PostPosted: 16:28 - 13 May 2020    Post subject: Reply with quote

I made some changes and tested the thing on th car dashboard and it worked pretty well
and displayed local speeds up to 30mph just fine

https://imgur.com/wvqzRpN.jpg

Ribena.

AFAIK the GT-U7 sends out NMEA data just like the Neo6
so should work fine
I modded a sketch to run on a 128x32 oled (hopefully) so try that
on your Uno
I hope it might look summat like this
time adjusted to BST and the small figure after the 'MPH' is the satellites found
( moar shitty pix)
https://imgur.com/1VGZSQD.jpg





-------------------------------------
Electrical connections
GPS to UNO

VSS-5V
gnd - gnd
u7 TX to Uno D3 (digital pin 3)
u7 RX to Uno D4 (digital pin 4)
Ignore pps/pss connection

OLED to Uno on IIC bus

VSS - 5V
Gnd - GND
SDA - A4 (Analog pin A4)
SCL - A5 (Analog pin A5)
--------------------------------------
Install the Tinygps library
you probably have the others needed already
Tinygpsplus might work as it's a newer version of this
but best KIS and start with tinygps.h

Start a new sketch in the Arduino IDE
Select and delete the setup and loop stuff plus any braces it initially offers, to clear the screen

Copy the code below and past it into the new/cleared arduino prog space
and click compile
If it compiles OK, upload it to the Uno.

If it works for you, leave it alone and make a copy
using save as 'My_128x32gps-2.ino' for instance and so on
and feck about err 'develop' copies not the master file.



Here's the code, try it


Code:




#include <SPI.h>                      //Serial Peripheral Interface (SPI) library for synchronous serial data protocol
#include <Wire.h>                     //Wire library used for I2C communication: Arduino Pro Mini pins used = A4 (SDA) and A5 (SCL)
#include <Adafruit_SSD1306.h>         //Adafruit driver for OLED
 #include <SoftwareSerial.h>           //SoftwareSerial library used to allow serial communication on other digital pins
#include <TinyGPS.h>                  //GPS Library used to read the data from GPS Module
//
#define OLED_RESET 5
Adafruit_SSD1306 display(OLED_RESET);

TinyGPS gps;                          //Create the TinyGPS object, giving it a name of your choice (here we use the name gps)
SoftwareSerial nss(3, 4);             //set sotfware serial communications to arduino ports 3 and 4 (TX = D3 and RX = D4)
                                      //
void setup()   {                 
   nss.begin(9600);
 
  unsigned long age, date, time, chars = 0;

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize the OLED and set the I2C address to 0x3C (for the 128x64 OLED)
 
  display.clearDisplay();             //Clear display buffer.

  display.setCursor(0,0); 
  display.setTextSize(1);             
  display.setTextColor(WHITE);
  // display.print("INITIALISING .....");//print "INITIALISING ....." to display
  display.setCursor(0,0);            //set text start position to column=0 and row=40
  display.setTextColor(WHITE);        //
  display.print("Locating satellites");  //print "Trying to locate GPS satellites ..." to display
 
  display.setCursor(0,20);            //set text start position to column=0 and row=57
  display.print("Please Wait");       //print "Please Wait" to display
 
  display.display();                  //update OLED with new display data
  delay(1000);                        //short delay
  display.clearDisplay();             //clear display
}


//MAIN PROGRAMME LOOP
void loop() {

bool newdata = false;
  unsigned long start = millis();
  while(millis() - start < 1000){    // Every 1 seconds we print an update
    if (feedgps())
      newdata = true;
  }
  if (newdata)
  {
    gpsdump(gps);
  }
}
 
 
//PRINT GPS DATA TO OLED DISPLAY
void gpsdump(TinyGPS &gps)

  print_date(gps);                  //print date and time at top of OLED display
 
  display.clearDisplay();
 
  display.setTextSize(1);           //set text size to 1
  display.setTextColor(WHITE);      //
  display.setCursor(0,0);           //set text start position for date and time (row = 0, column =0)
  print_date(gps);                  //prints date and time on top line to OLED
 
 
  display.setTextSize(2);
   display.setCursor(16,16);       // Col 16  row 24
  display.println(gps.f_speed_mph(),1);//print speed(mph) data to display
                                   
    display.setTextSize(2);
  display.setCursor(56,16);        //set text start position to column=56 and row=24
  display.println(" Mph");             //print "MPH" to display
 

  display.setCursor(112,16);
  display.setTextSize(1);       
  display.println(gps.satellites());//print number of satellites detected to display

  display.display();                //update OLED display
}


//TEST FOR NEW DATA FROM THE GPS MODULE
bool feedgps()
{
  while (nss.available())
  {
    if (gps.encode(nss.read()))    //Each byte of NEMA data must be giving to TinyGPS by using encode(). True is returned when new data has been fully decoded and can be used
      return true;
  }
  return false;
}


//GET DATE AND TIME FOR DISPLAY
static void print_date(TinyGPS &gps)
{
  int year;
  byte month, day, hour, minute, second, hundredths;
  unsigned long age;
  gps.crack_datetime(&year, &month, &day, &hour, &minute, &second);
  {
    char sz[32];
    sprintf(sz, "%02d/%02d/%02d  %02d:%02d:%02d",
        day, month, year, (hour+1), minute, second);
        // NOTE ! changed hour to (hour+1) to allow for BST
        // remove brackets and +1 to reset   
    display.print(sz);                      //Print date and time to OLED
  }

}


____________________
bikers smell of wee
 Back to top
View user's profile Send private message You must be logged in to rate posts

Ribenapigeon
Super Spammer



Joined: 20 Feb 2012
Karma :

PostPosted: 13:46 - 14 May 2020    Post subject: Reply with quote

Brilliant! It works. It does display to my 128x32 but with the bottom of the display cutoff. I looked in the example library and fund the line:-
[code]


#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels

[code]

Ill try that later but might go with the larger Oled for the moment as the bigger the speed font can be made the better for the purpose of the optics side of things.
 Back to top
View user's profile Send private message You must be logged in to rate posts

Ribenapigeon
Super Spammer



Joined: 20 Feb 2012
Karma :

PostPosted: 13:59 - 14 May 2020    Post subject: Reply with quote

[img.]https://www.flickr.com/photos/186400071@N04/49893529618/in/album-72157714299457786/[/img.]
 Back to top
View user's profile Send private message You must be logged in to rate posts

WD Forte
World Chat Champion



Joined: 17 Jun 2010
Karma :

PostPosted: 15:15 - 14 May 2020    Post subject: Reply with quote

Good, you've got somthing to play with now

WORK ON COPIES !!!!!

I did think of putting
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
in the header files but as I don't have a 128x32 I couldn't test that.

I haven't explored all the text and font stuff yet but reckon
basic text is 7 pixels high so allowing a 1 pixel line space for clarity
that gives you a 24 pixel text height to play with
I'd experiment by changing the part of the code after

//gps.f_get_position(&flat, &flon); //retrieves latitude and longditude data


to sumpin like this
Code:

   //gps.f_get_position(&flat, &flon); //retrieves latitude and longditude data
 
  display.setTextSize(4);
   display.setCursor(28,12);       // Col 28  row 12
  display.println(gps.f_speed_mph(),1);
  //print speed(mph) data to display
                                   
    display.setTextSize(1);
  display.setCursor(104,16);        //set text start position to 104,16
  display.println(" Mph");             //print smaller "Mph" to display
 

  display.setCursor(112,26);
  display.setTextSize(1);             // found satellites in small font
  display.println(gps.satellites());
//print number of satellites detected to display

  display.display();                //update OLED display

and see what happens
____________________
bikers smell of wee


Last edited by WD Forte on 15:49 - 14 May 2020; edited 2 times in total
 Back to top
View user's profile Send private message You must be logged in to rate posts

WD Forte
World Chat Champion



Joined: 17 Jun 2010
Karma :

PostPosted: 15:28 - 14 May 2020    Post subject: Reply with quote

[img.]https://www.flickr.com/photos/186400071@N04/49893529618/in/album-72157714299457786/[/img.]

didnt work for me
so I screen grabbed, cropped and jpg'ed it
https://imgur.com/n4C3vmu.jpg
____________________
bikers smell of wee
 Back to top
View user's profile Send private message You must be logged in to rate posts

Ribenapigeon
Super Spammer



Joined: 20 Feb 2012
Karma :

PostPosted: 18:35 - 14 May 2020    Post subject: Reply with quote

I think I need to get one of those them there imgur accounts.
 Back to top
View user's profile Send private message You must be logged in to rate posts

Ribenapigeon
Super Spammer



Joined: 20 Feb 2012
Karma :

PostPosted: 18:35 - 14 May 2020    Post subject: Reply with quote

I think I need to get one of those them there imgur accounts.

https://i.imgur.com/EgeNNUd.jpg?1
 Back to top
View user's profile Send private message You must be logged in to rate posts

WD Forte
World Chat Champion



Joined: 17 Jun 2010
Karma :

PostPosted: 16:07 - 20 May 2020    Post subject: Reply with quote

Right then,
some more fiddling
I removed the date cos don't care and found a layout that allowed the MPH and sats found to
roll over to double figures ( with a decimal point) that didn't need me to find me glarses to see what's what.
Still sticking with plain text and no fonts/graphics to keep progmem and RAM usage down
Here's the layout with a 128x32 display along side.

https://imgur.com/pT5vh97.jpg



With the code running on a Nano the way I wanted, I decided to run it on a 5V 16Mhz Promini
as I had couple knocking about and didn't mind dedicating on of those to a hand held gps project.
Prominis don't have USB and I fecked about for ages trying to upload it using an old Cp2102
USB to serial thingy which was a frustrating PITA until I found I could use my Uno board to do it easily, nae bother.
shittyfone pic
https://imgur.com/VU6bAD9.jpg


It worked fine using an el cheapo Poundshop power pack to run the lot for about 3hrs quite happily
until I disconnected it.Not sure how long it will ultimately last, but 3 hrs is a good start.
I'll check actual current consumption later.


These power packs are convenient in that they use a small pcb to take in 5V from a mini usb phone charge cable
to charge a ( usually cheap shit )3.7V Li-ion 18650 battery and put out 5V on a standard USB port.
By desoldering the output port I can lay in cables plus switch to power the project while still having
an easy and convenient charge option.This will help make it light and compact.

Here's one we did earlier..
https://imgur.com/mJ2grog.jpg

As regarding a motorcycle HUD project , using a Pro mini or Nano, you'd only need to run out 4 small cables to the display
on say CAT-5 cable, the rest could easily fit in your pocket.

Incidentally
the cold start TTFF can take a while so I get this for a few minutes while indoors

https://imgur.com/FYFPBFh.jpg

I spose it's all you can expect from these cheap modules and the more
expensive ones are faster with high gain antennas and such

EDIT:
Just tried it outdoors on the car dash.
According to the car clock it took about 2 minutes to get a fix
from a cold start.
Seems longer when you sit there staring at it
____________________
bikers smell of wee
 Back to top
View user's profile Send private message You must be logged in to rate posts

Easy-X
Super Spammer



Joined: 08 Mar 2019
Karma :

PostPosted: 13:01 - 21 May 2020    Post subject: Reply with quote

2 minutes sounds like a stone cold TTFF. IIRC correctly the "cheat" is to tell the GPS module where it last was as 9 times out of 10 the GPS is in the same locale to when it was powered off.

Either that or see if there's a sleep mode for the module and trickle it so it's always warm-starting.
____________________
Husqvarna Vitpilen 401, Yamaha XSR700, Honda Rebel, Yamaha DT175, Suzuki SV650 (loan) Fazer 600, Keeway Superlight 125, 50cc turd scooter
 Back to top
View user's profile Send private message You must be logged in to rate posts

WD Forte
World Chat Champion



Joined: 17 Jun 2010
Karma :

PostPosted: 15:39 - 21 May 2020    Post subject: Reply with quote

The blurb says

"The module is equipped with an HK24C32 two wire serial EEPROM. It is 4KB in size and connected to the NEO-6M chip via I2C.

The module also contains a rechargeable button battery which acts as a super-capacitor.

An EEPROM together with battery helps retain the battery backed RAM (BBR). The BBR contains clock data, latest position data(GNSS orbit data) and module configuration. But it’s not meant for permanent data storage.

As the battery retains clock and last position, time to first fix (TTFF) significantly reduces to 1s. This allows much faster position locks.

Without the battery the GPS always cold-start so the initial GPS lock takes more time.

The battery is automatically charged when power is applied and maintains data for up to two weeks without power."

I'm assuming the batt is fooked on mine, but as its just an exercise rather than serious project, I'll maybe look into that later
____________________
bikers smell of wee
 Back to top
View user's profile Send private message You must be logged in to rate posts

WD Forte
World Chat Champion



Joined: 17 Jun 2010
Karma :

PostPosted: 20:28 - 22 May 2020    Post subject: Reply with quote

I did a quick and ugly and stuffed all the gubbins in a plastic box
butchered down to 100x60x30mm and it's all working.

https://imgur.com/ibng7Ok.jpg

https://imgur.com/wRbm8vG.jpg


The wiring isn't tidy
I soldered pins on the vero board and used DuPont Female to Female hook up connectors
on the gps and display because I dont intend to keep it so kept hard wiring to a minimum.

Like this, I can easily disassemble it and use the components for other projects,
I just wanted to do a proof of concept type thing.

The backup battery is knackered and I wouldn't bother changing like for like
just remove the bad 'un and solder tails to the pads and use a cheaper, easier to source
'off board' 3v rechargeable coin cell.

In use it does seem to give fairly accurate speeds which seem to stay 1-2mph below the car speedo
which were tested to around 60MPH
Actual calibration is a rabbit hole I've no interest in going down.

The cheapo power supply works well.
The Red led comes on when charging and the blue led when working on battery alone
and it flashes when battery level is low.

I'm not in love with it
No fan of digital speedos, I like a nice, smoothly sweeping analogue needle I only have to glance at to know
my speed within a mile or so of actual MPH.
Reading numbers seems to take up more attention.
The refresh rate seems to take a second or two and could jump maybe +/- 5 mph as I accelerated
or slowed down and this got a bit irritating pretty quickly.
Code tweaking and faster polling of the gps would probably solve this, but I've lost interest now.
____________________
bikers smell of wee
 Back to top
View user's profile Send private message You must be logged in to rate posts

GettinBetter
Crazy Courier



Joined: 20 Jun 2019
Karma :

PostPosted: 16:05 - 08 Aug 2020    Post subject: Reply with quote

Brilliant thread, enjoyed reading that thanks for sharing.

It made me google search for other HUD's out there, and it seems a reasonably new product, and still in it's infancy. Lots of crap from china but nothing that strikes me as being ideal.

This looks good but seems the makers are struggling to get it to market https://www.crosshelmet.com/ 2 grand for the package, so might be a bit steep for some (including me), but it seems to do the business.

I'd quite like a dimmable HUD that shone on my windshield and gave me speed, SATNAV and indicator on warning plus other indicator lamps from the bike.

IMO the speed needs to be augmented with the bikes speedo, so that any instant changes are transferred to the GPS calculated speed, making it update more instantly/smoothly.

My indicator warning lamp in too low and out of peripheral vision (in fact below the bottom edge of my helmet) as is all the dials etc on the fuel tank. So I need to make a conscious effort to look down regularly which IMO is bad design. So having those on the windshield would be a bonus.
 Back to top
View user's profile Send private message You must be logged in to rate posts
Old Thread Alert!

The last post was made 3 years, 260 days ago. Instead of replying here, would creating a new thread be more useful?
  Display posts from previous:   
This page may contain affiliate links, which means we may earn a small commission if a visitor clicks through and makes a purchase. By clicking on an affiliate link, you accept that third-party cookies will be set.

Post new topic   Reply to topic    Bike Chat Forums Index -> The Geek Zone All times are GMT + 1 Hour
Goto page Previous  1, 2
Page 2 of 2

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Read the Terms of Use! - Powered by phpBB © phpBB Group
 

Debug Mode: ON - Server: birks (www) - Page Generation Time: 0.82 Sec - Server Load: 1.08 - MySQL Queries: 17 - Page Size: 95.37 Kb