|
Author |
Message |
WD Forte |
This post is not being displayed .
|
WD Forte World Chat Champion
Joined: 17 Jun 2010 Karma :
|
Posted: 18:42 - 12 May 2020 Post subject: |
|
|
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 |
|
You must be logged in to rate posts |
|
|
WD Forte |
This post is not being displayed .
|
WD Forte World Chat Champion
Joined: 17 Jun 2010 Karma :
|
Posted: 16:28 - 13 May 2020 Post subject: |
|
|
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 |
|
You must be logged in to rate posts |
|
|
Ribenapigeon |
This post is not being displayed .
|
Ribenapigeon Super Spammer
Joined: 20 Feb 2012 Karma :
|
|
Back to top |
|
You must be logged in to rate posts |
|
|
Ribenapigeon |
This post is not being displayed .
|
Ribenapigeon Super Spammer
Joined: 20 Feb 2012 Karma :
|
|
Back to top |
|
You must be logged in to rate posts |
|
|
WD Forte |
This post is not being displayed .
|
WD Forte World Chat Champion
Joined: 17 Jun 2010 Karma :
|
Posted: 15:15 - 14 May 2020 Post subject: |
|
|
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 |
|
You must be logged in to rate posts |
|
|
WD Forte |
This post is not being displayed .
|
WD Forte World Chat Champion
Joined: 17 Jun 2010 Karma :
|
Posted: 15:28 - 14 May 2020 Post subject: |
|
|
[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 |
|
You must be logged in to rate posts |
|
|
Ribenapigeon |
This post is not being displayed .
|
Ribenapigeon Super Spammer
Joined: 20 Feb 2012 Karma :
|
|
Back to top |
|
You must be logged in to rate posts |
|
|
Ribenapigeon |
This post is not being displayed .
|
Ribenapigeon Super Spammer
Joined: 20 Feb 2012 Karma :
|
|
Back to top |
|
You must be logged in to rate posts |
|
|
WD Forte |
This post is not being displayed .
|
WD Forte World Chat Champion
Joined: 17 Jun 2010 Karma :
|
Posted: 16:07 - 20 May 2020 Post subject: |
|
|
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 |
|
You must be logged in to rate posts |
|
|
Easy-X |
This post is not being displayed .
|
Easy-X Super Spammer
Joined: 08 Mar 2019 Karma :
|
|
Back to top |
|
You must be logged in to rate posts |
|
|
WD Forte |
This post is not being displayed .
|
WD Forte World Chat Champion
Joined: 17 Jun 2010 Karma :
|
|
Back to top |
|
You must be logged in to rate posts |
|
|
WD Forte |
This post is not being displayed .
|
WD Forte World Chat Champion
Joined: 17 Jun 2010 Karma :
|
Posted: 20:28 - 22 May 2020 Post subject: |
|
|
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 |
|
You must be logged in to rate posts |
|
|
GettinBetter |
This post is not being displayed .
|
GettinBetter Crazy Courier
Joined: 20 Jun 2019 Karma :
|
Posted: 16:05 - 08 Aug 2020 Post subject: |
|
|
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 |
|
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? |
|
|
|