Go Down

Topic: GPS speedometer for motorcycle (Read 10425 times) previous topic - next topic

torvic

Hi all,

I'm a product designer and I'm fairly new to the Arduino and coding environment.

My project is to make a tiny GPS speedometer for a motorcycle.
I use NEO6MV2 GPS module to receive the data, Arduino Uno board (will be replaced by a tinier board if possible) and 7 segment/3 digits as a display.

Here is a very rough first draft of the "final product"(it will be mounted on motorcycle handlebars:


Below is the code I use, which is working (ie: I can retrieve data from the GPS module and display them on the 7 segment display)
Code: [Select]
#include <SoftwareSerial.h>
#include <SevSeg.h>
#include <TinyGPS++.h>
static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;
SoftwareSerial ss(RXPin, TXPin);
SevSeg sevseg;
TinyGPSPlus gps;
int f=0;

String speedinkmh;

void setup() {
byte numDigits = 3;
  byte digitPins[] = {5, 6, 7};
  byte segmentPins[] = {8, 9, 10, 11, 12, 13, 2};
  bool resistorsOnSegments = false; // 'false' means resistors are on digit pins
  byte hardwareConfig = COMMON_CATHODE; // See README.md for options
  bool updateWithDelays = false; // Default 'false' is Recommended
  bool leadingZeros = false; // Use 'true' if you'd like to keep the leading zeros
  bool disableDecPoint = true; // Use 'true' if your decimal point doesn't exist or isn't connected. Then, you only need to specify 7 segmentPins[]

  sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments,
  updateWithDelays, leadingZeros, disableDecPoint);

Serial.begin(9600);
ss.begin(GPSBaud);
Serial.println(F("Compteur test"));

}

void loop()
{

while (ss.available() > 0)
gps.encode(ss.read());
if (gps.speed.isValid())
  Serial.println(gps.speed.kmph());
  Serial.println(gps.satellites.value());
 
 f=round(gps.speed.kmph());
 if (f<5)
 f=0;
 else
 f=f;
 sevseg.setBrightness(60);
 sevseg.setNumber(f);
 sevseg.refreshDisplay();


  if (millis() > 5000 && gps.charsProcessed() < 10)
  Serial.println(F("No GPS data received: check wiring"));
}


I have several issues/questions:

-  My display is very flickery, you can see that each segment is lit one after another. I think it's linked to the refresh rate of the display but all the methods I tried led to the same result or buggy display.
How can I improve the code to steady my display?

- I would love to optimize wiring by using TM1637 with 7 segment display, but I can't find a suitable 3 digit version. Are there other options?

- To optimize size and weight, I would like to switch the Board for a smaller version, should I go with the Nano or micro? It will be hooked to a 12V motorcycle battery.

Thank you for your help!



DKenp

I'm trying to do the same thing but then display the speed in a bud. I'm failing miserably well done to get some kind of code working

Stevonator

#2
Jun 24, 2020, 07:43 pm Last Edit: Jun 24, 2020, 07:52 pm by Stevonator
https://youtu.be/Wk6hUOiKGQk

Here is a short video of how I did what your doing!
I'm using my phone to securely turn on my electric motorcycle and then the phone becomes my dash board.
The Arduino code is used in conjunction with the Android Virtuino App. found on Google Playstore

Here is a link to the ElMoto.net thread regarding dashboards for electric motorcycle conversions:
http://elmoto.net/showthread.php?t=4585

Go Up