|
Author |
Message |
Ribenapigeon |
This post is not being displayed .
|
Ribenapigeon Super Spammer
Joined: 20 Feb 2012 Karma :
|
Posted: 12:08 - 29 Apr 2020 Post subject: Arduino GPS Speedo |
|
|
Anyone here a dab hand with Arduino?
Ive started making a GPS Speedo HUD. Ive got the optics worked out basically using an old objective lens from a cheap pair of binoculars and some semi reflective film. Ive managed to get a GT-u7 GPS working hooked up to a Arduino UNO R3 and I've also got a small Oled i2C working with an example script. IM struggling to write a script to take the speed output from the GPS and then put that value to output to the Oled but I'm lost. The library I'm using for the GPS is TinyGPS++ and the Oled is SSD1306_128x32_i2C
I would prefer to output to seven segment display really as that would be clearer for projecting the number onto the HUD but i only have an Oled display.
Cheers.
BTW I've tried the Arduino forums but they're more anally retentive than Mumsnet |
|
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: 19:41 - 29 Apr 2020 Post subject: |
|
|
Interesting, how are you projecting it on a visor? any pics?
(Could it perhaps wash the visor and save lives while its at it?
Just asking)
Cant help with code I'm afraid as I'm very very rusty and only recently dug out
my Arduino stuff after such a long time that I'm having to do all the basic stuff
all over again just to refresh my brain.
I have some 7 seg common cathode led displays and they'd need a lot of pins, multiplexing or shift register circuits,so serial displays score there for me.
Having said that, I see Sparkfun offer a 41x23mm serial type 4x7 segment display which would cut down on pin/cable use.
https://www.sparkfun.com/products/11629
As for code, I usually shamelessly grab other peoples and butcher/feck about with it to get it to do what I want it to.
Edit
A quick google got me this based on a pro mini
but it may have some handy snippets you can borrow
to get it functional then deal with the method of display/HUD as a seperate project
https://create.arduino.cc/projecthub/fanatic-series/gps-speedometer-using-arduino-pro-micro-0a8fde ____________________ bikers smell of wee
Last edited by WD Forte on 20:04 - 29 Apr 2020; edited 1 time in total |
|
Back to top |
|
You must be logged in to rate posts |
|
|
The Shaggy D.A. |
This post is not being displayed .
|
The Shaggy D.A. Super Spammer
Joined: 12 Sep 2008 Karma :
|
Posted: 19:53 - 29 Apr 2020 Post subject: |
|
|
Some time back I found a post showing how to use PWM and a cheap digital voltmeter as a cheap display :-
https://picaxeforum.co.uk/threads/1-digital-voltmeter-becomes-one-pin-led-display.27594/ ____________________ Chances are quite high you are not in my Monkeysphere, and I don't care about you. Don't take it personally.
Currently : Royal Enfield 350 Meteor
Previously : CB100N > CB250RS > XJ900F > GT550 > GPZ750R/1000RX > AJS M16 > R100RT > Bullet 500 > CB500 > LS650P > Bullet Electra X & YBR125 > Bullet 350 "Superstar" & YBR125 Custom > Royal Enfield Classic 500 Despatch Limited Edition (28 of 200) & CB Two-Fifty Nighthawk > ER5 |
|
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 :
|
Posted: 20:14 - 29 Apr 2020 Post subject: |
|
|
I thought of going down that route as I've a box full of those volt meters but coding transferring GPS speed data to voltage or PWM would severely tax my little artistic brain. |
|
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 :
|
Posted: 13:22 - 30 Apr 2020 Post subject: |
|
|
Best to break these projects into stages. I dunno what sort of Arduino you have but it helps if you have one (most I think) that has serial console I/O. You then have a simple way of outputting data.
For example: Step 1 might be to just get a speed output from your GPS module. Spit out the results to the console. Start with getting raw data out, they do some calculations to get lat/long, and so on.
Step 2 might be to take input, e.g. a number and show it on your display. There should be some standardised libraries to magic up the console operations to save you some work.
Also, if you get frustrated with the GPS you can just switch over to the display side for a bit of a rest. ____________________ Husqvarna Vitpilen 401, Yamaha XSR700, Honda Rebel, Yamaha DT175, Suzuki SV650 (loan) Fazer 600, Keeway Superlight 125, 50cc turd scooter |
|
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 |
|
|
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 |
|
|
Easy-X |
This post is not being displayed .
|
Easy-X Super Spammer
Joined: 08 Mar 2019 Karma :
|
Posted: 11:46 - 02 May 2020 Post subject: |
|
|
Dunno if the display library handles automatic number to text conversion...
Code: | char buf[10];
sprintf(buf, "%d mph" , speed);
display.println(buf); |
____________________ Husqvarna Vitpilen 401, Yamaha XSR700, Honda Rebel, Yamaha DT175, Suzuki SV650 (loan) Fazer 600, Keeway Superlight 125, 50cc turd scooter |
|
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: 01:15 - 05 May 2020 Post subject: |
|
|
Got one o them wee displays today and had feck about with it tonight
running it from a Nano.
Handheld Sat knavery
https://imgur.com/SVGBdwY.jpg
Hooked up an LM35 temp sensor and displaying a variable was easy enough, just like any other display.
https://imgur.com/3U2OAmV.jpg
will look into fonts,formatting and graphics in more detail later ____________________ bikers smell of wee |
|
Back to top |
|
You must be logged in to rate posts |
|
|
Im-a-Ridah |
This post is not being displayed .
|
Im-a-Ridah World Chat Champion
Joined: 20 Oct 2006 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 |
|
|
Ribenapigeon |
This post is not being displayed .
|
Ribenapigeon Super Spammer
Joined: 20 Feb 2012 Karma :
|
Posted: 13:30 - 07 May 2020 Post subject: |
|
|
OK I have this script for the GPS Speed Data.
#include <SoftwareSerial.h>
SoftwareSerial ssPort(4, -1);
const byte numChars = 64;
char receivedChars[numChars]; // an array to store the received data
char rmcLine[64];
boolean newData = false;
char *strings[16];
char *ptr = NULL;
float knots2MPH = 1.1507794;
float speed = 0;
boolean speedIsValid = false;
void setup()
{
Serial.begin(115200);
ssPort.begin(9600);
Serial.println("<Arduino is ready>");
}
void loop()
{
recvWithEndMarker();
getRMCdata();
}
void recvWithEndMarker()
{
static byte ndx = 0;
char endMarker = '\n';
char rc;
while (ssPort.available() > 0 && newData == false)
{
rc = ssPort.read();
if (rc != endMarker)
{
receivedChars[ndx] = rc;
ndx++;
if (ndx >= numChars)
{
ndx = numChars - 1;
}
}
else
{
receivedChars[ndx] = '\0'; // terminate the string
ndx = 0;
newData = true;
}
}
}
void getRMCdata()
{
if (newData == true)
{
if (strstr(receivedChars, "$GPRMC") )
{
strcpy(rmcLine, receivedChars);
//Serial.print("This just in ... ");
//Serial.println(rmcLine);
byte index = 0;
ptr = strtok(rmcLine, ",");
while (ptr != NULL)
{
strings[index] = ptr;
index++;
ptr = strtok(NULL, ",");
}
if (*strings[2] == 'A') // if the fix is valid print speed
{
speed = atof(strings[7]) * knots2MPH;
speedIsValid = true;
Serial.print("Speed = ");
Serial.print(speed);
Serial.println(" MPH");
}
else
{
Serial.println("Speed not valid");
speedIsValid = false;
}
}
newData = false;
}
}
I have this for running the oled. It gets the error "serial does not name a type" when i try to compile. I don't understand this of course but i don't understand much of it anyway, I just cut out all the nonsense stuff in an example script for the old and left what i think is the bit i need to take the speed variable from the above GPS script (speed). How do i combine these two scripts? Im guessing W D Forte has basically done something simerler with his temp display?
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
Serial.begin(9600); //This gets the compiling error "serial does not name a type"
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
Serial.println(F("SSD1306 allocation failed"));
for(;; // Don't proceed, loop forever
}
void testdrawchar(void) {
display.clearDisplay();
display.setTextSize(1); // Normal 1:1 pixel scale
display.setTextColor(SSD1306_WHITE); // Draw white text
display.setCursor(0, 0); // Start at top-left corner
display.cp437(true); // Use full 256 char 'Code Page 437' font
// Not all the characters will fit on the display. This is normal.
// Library will draw what it can and the rest will be clipped.
for(int16_t i=0; i<256; i++) {
if(i == '\n') display.write(' ');
else display.write(i);
}
display.display();
delay(2000);
}
void testdrawstyles(void) {
display.clearDisplay();
display.setTextSize(1); // Normal 1:1 pixel scale
display.setTextColor(SSD1306_WHITE); // Draw white text
display.setCursor(0,0); // Start at top-left corner
display.println(F("Hello, world!"));
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE); // Draw 'inverse' text
display.println(3.141592);
display.setTextSize(2); // Draw 2X-scale text
display.setTextColor(SSD1306_WHITE);
display.print(F("0x")); display.println(0xDEADBEEF, HEX);
display.display();
delay(2000);
}
}
}
}
}
This is making my brain hurt. I could go the year long route of learning arduino form scratch but ya know...... |
|
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:49 - 07 May 2020 Post subject: |
|
|
It looks like you're trying to run the oled and serial monitor
at the same time?.
what if you comment out the spi.h - wire.h and 'serial begin' lines
and just use the Oled?
As I'm so rusty and never was an expert anyway K.I.S.S. helps.
I copy paste/butcher code to the absolute minimum to help myself
get my head around it all and this is what I used to get the oled running and display the temp sensor values
The idea is to start simple and get all elegant and fancy as I learn
Tip:
Select Arduino code and use Edit/'Copy for forum' to paste it here
Code: |
// ssd1306 uses the Nano Analog pins A4( SDA) and A5(SDL)
//
// same pins as the Uno btw
//Libraries to load
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
int analogInPin = A0; //lm35 temp sensor input on analog pin 0
int sensorvalue = 0; //
int tempc; // variable for temp sensor reading
void setup()
{
//Initialize display by providing the display type and its I2C address.
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
//Set the text size and color.
display.setTextSize(1);
display.setTextColor(WHITE);
}
void loop()
{
//Clear previous image.
display.clearDisplay();
display.setTextSize(1);
// 24 in top row
display.setCursor(30, 0);
display.print("TEMPERATURE");
int sensorvalue = analogRead(analogInPin);
tempc = (sensorvalue*475/1023);
//sensorValue*475/1023 gives a more accurate reading
// according to my IR themometer
//and 22C to 23C for a 22.5C reading.
//which is close enough
display.setTextSize(3);
display.setCursor(20,12);
display.print(tempc);
display.setCursor(35, 12);
display.print(" C");
delay (4000);
//Display changes if any were made.
display.display();
delay(1);
}
|
that gives me this
accurate to within degree I find
I got that neo6 gps module yesterday and but havent played with it yet
shitty fone pic:
https://imgur.com/1RUnyPo.jpg ____________________ 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 :
|
Posted: 16:18 - 07 May 2020 Post subject: |
|
|
On the second piece of code: sorry, never gonna work
You've missed off the setup() and/or loop() functions. Yer basic Arduino is looking for those in the same way a Windows Command Prompt program is looking for main()
void setup()
{
//Code here run on "boot up"
}
void loop()
{
//Code here run over and over
//Need to sleep at end if there aren't any blocking functions
} ____________________ Husqvarna Vitpilen 401, Yamaha XSR700, Honda Rebel, Yamaha DT175, Suzuki SV650 (loan) Fazer 600, Keeway Superlight 125, 50cc turd scooter |
|
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 :
|
Posted: 20:24 - 07 May 2020 Post subject: |
|
|
Easy-X wrote: | On the second piece of code: sorry, never gonna work
You've missed off the setup() and/or loop() functions. Yer basic Arduino is looking for those in the same way a Windows Command Prompt program is looking for main()
void setup()
{
//Code here run on "boot up"
}
void loop()
{
//Code here run over and over
//Need to sleep at end if there aren't any blocking functions
} |
so more like;
Code: |
void setup()
{
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
void loop()
{
Serial.begin(9600);
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
void testdrawchar(void) {
display.clearDisplay();
display.setTextSize(1); // Normal 1:1 pixel scale
display.setTextColor(SSD1306_WHITE); // Draw white text
display.setCursor(0, 0); // Start at top-left corner
display.cp437(true); // Use full 256 char 'Code Page 437' font
// Not all the characters will fit on the display. This is normal.
// Library will draw what it can and the rest will be clipped.
for(int16_t i=0; i<256; i++) {
if(i == '\n') display.write(' ');
else display.write(i);
}
display.display();
delay(2000);
}
void testdrawstyles(void) {
display.clearDisplay();
display.setTextSize(1); // Normal 1:1 pixel scale
display.setTextColor(SSD1306_WHITE); // Draw white text
display.setCursor(0,0); // Start at top-left corner
display.println(F("Hello, world!"));
display.setTextColor(SSD1306_BLACK, SSD1306_WHITE); // Draw 'inverse' text
display.println(3.141592);
display.setTextSize(2); // Draw 2X-scale text
display.setTextColor(SSD1306_WHITE);
display.print(F("0x")); display.println(0xDEADBEEF, HEX);
display.display();
delay(2000);
}
}
}
}
}
|
|
|
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 |
|
|
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 :
|
|
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 :
|
|
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 |
|
|
Ribenapigeon |
This post is not being displayed .
|
Ribenapigeon Super Spammer
Joined: 20 Feb 2012 Karma :
|
Posted: 17:56 - 12 May 2020 Post subject: |
|
|
Im usnig a GT-u7 which i think is an update of the Neo6. Theres another one called a Grove but its three times the price and not worth it unless you know what your doing, which i clearly don't. Ive gone off to do something i understand better, digging the garden. |
|
Back to top |
|
You must be logged in to rate posts |
|
|
Old Thread Alert!
The last post was made 3 years, 346 days ago. Instead of replying here, would creating a new thread be more useful? |
|
|
|