So far I have used various RTC clocks for clock projects or got the time from NTP servers. In this project I present another source to you: parsing from the NMEA string of GPS satellites around the world.
I was surprised how cheap a GPS receiver is today: get one (in my case the GY-GPS6Mv2 is used).
a.) a first - optional - test on a Windows PC: Install "u-center" as a download from U-Blox.
With the help of an FTDI adapter, the GPS breakout finds its way to the COM port of your PC and shows the fixing (the connection) to the orbit after about 1 minute. For this purpose, a red control lamp on the breakout flashes.
The automatically generated graphics make you want to experiment more with GPS. With F8 - Text Console in the View menu you get the various NMEA strings delivered.
b.) You can carry out a decoding test on free online services: https://rl.se/gprmc
Now that it is ensured that you have a functioning GPS receiver - make sure that there is a view of the sky - we can extract the desired information from the string for your own wishes.
We use an Adafruit library "Adafruit GPS Library" - if you have installed it in the Arduino IDE, you can try out a little with the examples.
c.) Circuit
Arduino A4 > Display SDA Arduino A5 > Display SCL
#include <Wire.h>#include <LiquidCrystal_I2C.h>LiquidCrystal_I2C lcd(0x3F, 20, 4); // set the LCD address > often 0x27 or 0x3F
> use a Display which is lay around, maybe a 16x2?
#include <Adafruit_GPS.h>#include <SoftwareSerial.h>
Connect the GPS Power pin to 5VConnect the GPS Ground pin to groundConnect the GPS TX (transmit) pin to Digital 8Connect the GPS RX (receive) pin to Digital 7// you can change the pin numbers to match your wiring:SoftwareSerial mySerial(8, 7);Adafruit_GPS GPS(&mySerial);
> the GPS-Receiver is 3.3 / 5V tolerant.
d.) Our watch should give the time, the date, an indication of the wind speed and let's say the altitude. We do not need a location because my watch will stop at the window.
An NMEA string supplies the time in the UTC standard. A conversion into the local time zone is up to us. As long as nobody makes a better proposal, I add +1 for my time zone (Europe Berlin).
int timezone = +1; // Europe/Berlin (UTC +0100) > NMEA is UTC oriented
Adjust the time zone to your liking. The variable hour is then used in the code for the output on the LCD display instead of GPS.hour - the UTC value.
// output to LCD Display
lcd.setCursor(5,0); // ,0 = first line
int hour = (GPS.hour) + timezone; // format GPS.hour UTC to your individual timezone
if (hour < 10) { lcd.print('0'); }
lcd.print(hour, DEC); lcd.print(':');
In Europe we use "km/h" instead of knots for wind speed. So I first converted the value from knots to km/h using a constant and then grouped it.> 1 knots = 1.852 Kilometer per hour
float speed = (GPS.speed) * 1.852; // Switch from Speed/Knoten > Speed/km/h
Evaluation according to Wikipedia:
if (speed <= 1) {lcd.print(" Windstille");}
else if ((speed > 1) && (speed <= 9)) {lcd.print(" leiser Zug");}
else if ((speed > 9) && (speed <= 46)) {lcd.print(" Brise");}
else if ((speed > 46) && (speed <= 56)) {lcd.print(" starker Wind");}
else if ((speed > 56) && (speed <= 74)) {lcd.print(" stuerm. Wind");}
else if ((speed > 74) && (speed <= 83)) {lcd.print(" Sturm");}
else if ((speed > 83) && (speed <= 102)) {lcd.print(" schwerer Sturm");}
else if (speed > 102) {lcd.print(" Orkan");}
else {lcd.print(" ohne Bewertung");}
The result is shown on the display as follows and can of course be adapted to your own wishes:
I left the update frequency at 2 seconds within the loop.I even tend to forego the seconds and the heights in favor of a 16x2 display.
Have fun exploring the diverse GPS options!
In Europe we also have the evaluation of a DCF77 radio signal available. However, this is significantly more expensive and its handling is said to be very sensitive.
Comments
Please log in or sign up to comment.