DIY Altimeter using a NEO UBLOX GPS module, a Color OLED and Arduino
- Nick Koumaris
- http://educ8s.tv
- info@educ8s.tv
- 15.438 Views
- moderate
- Tested
GPS technology plays an important role in our everyday life. From easy human navigation to navigation of aircraft, it helps solving different location-related problems. However, aside from providing location details, the NMEA data obtained from satellites by GPS modules also carry information for other parameters like altitude, pressure, date and time etc. The implication of this is that GPS modules can be used also in projects where these other parameters are needed.
For today’s tutorial, we will use the UBLOX NEO-6M GPS module to determine the altitude of our place. A good application for this project would be a drone setup where the altitude is required as feedback to the IMU or other similar scenarios. While diverse kind of Arduino compatible GPS modules exists, they are often bulky and come with other constraints like high power requirements which put limitations on the project in which they can be used. This is where the UBLOX NEO 6M GPS Module comes in.
The module is compact and about the same size of small Arduino boards and this enable them to be easily fitted into any small Arduino project. The NEO-6M GPS module is a high-performing GPS receiver with a built-in 25 x 25 x 4mm ceramic antenna, which equips the module with a strong satellite search capability. The module communicates with connected microcontroller via serial protocol and operates on a voltage level between 3-5V.
We will use the GPS module to obtain altitude data and display them on an OLED display. At the end of the tutorial, you would know how to obtain diverse kind of information from a GPS module using NMEA protocol.
Required components
The following components are required to build this project;
As usual, all the components listed above can be bought via the links attached to them. It is also important to note that, the power bank is only needed for those who may want to test the project, in standalone mode.
Schematics
The schematic for this project is fairly simple. Asides the Arduino, we have two other major components, the GPS Module and the OLED display. The GPS module communicates over serial so it will be connected to serial pins of the Arduino. However, we will use software serial-based communication to avoid interference on the hardware serial line, since it is what the Arduino uses to communicate with the PC.
Connect the components as shown in the schematics below.
To make the connections easier to follow, a pin map showing how each of the components connects to the Arduino is shown below.
Arduino – OLED Display
GND – GND 3.3V – VCC D13 – SCL D11 – SDA D9 – RES D8 – DC D10 – CS
Arduino – GPS
GND – GND 5v – VCC D3 – RX D4 – TX
Go over the connections once again to be sure everything is as it should be.
Code
As mentioned earlier, we will use the GPS module not to obtain location information, like longitude and latitude, but to show how other parameters like altitude can be derived from the GPS output.
GPS modules as soon as they connect to satellites they pull a bunch of information which are referred to as NMEA data. This data contains useful information like location, altitude, pressure etc. Typical NMEA data are shown in the image below.
Making sense of this information and extracting the needed data can be quite a task. To make things easy for us, we will use the tinyGPS++ library which already has all the functions required to extract specific information from the NMEA data. The Library can be downloaded via the link attached. In addition to tinyGPS++ library, we will use the Adafruit GFX library. The GFX library will make it easy to interact with the OLED display.
To do a quick breakdown of the code, as usual, we will start by including the libraries required for the project after which we define the pins of the Arduino to which the OLED is connected.
// writtern by Nick Koumaris //Info@educ8s.tv #include <SoftwareSerial.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1331.h> #include <SPI.h> #include "TinyGPS++.h" #define sclk 13 #define mosi 11 #define cs 10 #define rst 9 #define dc
Next we specify the variables to represent the hex number of the colors to be used by the project and also create an instance of the tinyGPS++ library. This instance will be used to refer to the module which pass through the code.
#define BLACK 0x0000 #define BLUE 0x001F #define RED 0xF800 #define GREEN 0x07E0 #define CYAN 0x07FF #define MAGENTA 0xF81F #define YELLOW 0xFFE0 #define WHITE 0xFFFF TinyGPSPlus gps;
To make the data display more user friendly, a splach screen and icons were created so the information can be displayed in a neat and cool way. The char code representing the UI and the icons are declared below. To learn how to generate your own code to encode an image, you can check past tutorials.
static const unsigned char PROGMEM title[] = { 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0,0x3f,0xc0,0xff,0xc0,0xf,0xe0,0x0,0x0,0x0,0x0,0x0, 0x0,0xff,0xe0,0xff,0xf0,0x3f,0xf0,0x0,0x0,0x0,0x0,0x0, 0x3,0xff,0xe0,0xff,0xf8,0x7f,0xf0,0x0,0x0,0x0,0x0,0x0, 0x7,0xff,0xe0,0xf0,0xfc,0xff,0xf0,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 0x0,0xe0,0x0,0x0, 0x1,0xf0,0x0,0x0, 0x3,0xf8,0x0,0x0, 0x3,0x98,0x0,0x0, 0xe,0x7,0x0,0x0, 0xe,0x7,0x80,0x0, 0xe,0x3,0x80,0x0, 0x3,0x81,0xfc,0x0, 0x3,0xc1,0xfc,0x0, 0x1,0xc1,0xfe,0x0, 0x0,0xf7,0xfe,0x0, 0x0,0x3f,0xfc,0x0, 0x0,0x3f,0xfc,0x0, 0x0,0x1f,0xff,0x80, 0x0,0x1f,0xfb,0x80, 0xcc,0x1f,0xe1,0xc0, 0xce,0x1f,0xe0,0x70, 0xce,0xf,0xe0,0x70, 0x6e,0x7,0x60,0x38, 0x67,0x0,0x78,0xc, 0x63,0x0,0x1c,0x1c, 0x73,0x80,0x1c,0x3c, 0x71,0xf0,0x7,0x70, 0x30,0xf8,0x7,0xf0, 0x1c,0x3e,0x3,0xc0, 0xf,0x0,0x0,0x80, 0xf,0x80,0x0,0x0, 0x3,0xf0,0x0,0x0, 0x0,0xfe,0x0,0x0, 0x0,0xe,0x0,0x0 };
Next, we initialize the software serial library stating with the pins of the arduino to be used as the software TX and RX pins. We also create an instance of the OLED Library and move from there to the void setup() function.
SoftwareSerial SoftSerial(4, 3); //RX, TX Adafruit_SSD1331 display = Adafruit_SSD1331(cs, dc, rst);
Under the void setup() function, we initialize the display and serial communications declaring the baud rate at which we want the devices to communicate. The preset baud rate for the particular GPS module used for this project is 9600bps. Ensure it is the same for your module or modify accordingly. To round things off, we display the UI, getting the OLED ready to display altitude data. Next is the void loop() function.
void setup() { display.begin(); display.fillScreen(BLACK); printSplashScreen(); SoftSerial.begin(9600); // the SoftSerial baud rate delay(1000); Serial.begin(9600); // the Serial port of Arduino baud rate. delay(2000); printUI(); }
Under the void loop function, we check if data is being received by the GPS module and we use the gps.altitude.meters() function to extract altitude information from the module. The code also shows examples of how location information, can be obtained from the NMEA data, using the gps.location.lat() and the gps.location.lng() functions to get longitude and latitude information.
void loop() { String altitude ; while (SoftSerial.available() > 0) gps.encode(SoftSerial.read()); if (gps.location.isUpdated()) { Serial.print("LAT="); Serial.print(gps.location.lat(), 6); Serial.print(" LNG="); Serial.println(gps.location.lng(), 6); } if (gps.altitude.isUpdated()) { Serial.print("Altitude:"); Serial.println(gps.altitude.meters()); altitude = String((int)gps.altitude.meters())+" m"; display.setCursor(18,35); display.print(altitude); } }
The complete code for this project is attached below and under the download section of this tutorial.
//Written by Nick Koumaris //info@educ8s.tv #include <SoftwareSerial.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1331.h> #include <SPI.h> #include "TinyGPS++.h" #define sclk 13 #define mosi 11 #define cs 10 #define rst 9 #define dc 8 // Color definitions #define BLACK 0x0000 #define BLUE 0x001F #define RED 0xF800 #define GREEN 0x07E0 #define CYAN 0x07FF #define MAGENTA 0xF81F #define YELLOW 0xFFE0 #define WHITE 0xFFFF TinyGPSPlus gps; static const unsigned char PROGMEM title[] = { 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0,0x3f,0xc0,0xff,0xc0,0xf,0xe0,0x0,0x0,0x0,0x0,0x0, 0x0,0xff,0xe0,0xff,0xf0,0x3f,0xf0,0x0,0x0,0x0,0x0,0x0, 0x3,0xff,0xe0,0xff,0xf8,0x7f,0xf0,0x0,0x0,0x0,0x0,0x0, 0x7,0xff,0xe0,0xf0,0xfc,0xff,0xf0,0x0,0x0,0x0,0x0,0x0, 0x7,0xe0,0x20,0xf0,0x3c,0xf8,0x10,0x0,0x0,0x0,0x0,0x0, 0xf,0x80,0x0,0xf0,0x3c,0xf0,0x0,0x0,0x0,0x0,0x0,0x0, 0xf,0x0,0x0,0xf0,0x3c,0xf0,0x0,0x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 0x1,0xc1,0xfe,0x0, 0x0,0xf7,0xfe,0x0, 0x0,0x3f,0xfc,0x0, 0x0,0x3f,0xfc,0x0, 0x0,0x1f,0xff,0x80, 0x0,0x1f,0xfb,0x80, 0xcc,0x1f,0xe1,0xc0, 0xce,0x1f,0xe0,0x70, 0xce,0xf,0xe0,0x70, 0x6e,0x7,0x60,0x38, 0x67,0x0,0x78,0xc, 0x63,0x0,0x1c,0x1c, 0x73,0x80,0x1c,0x3c, 0x71,0xf0,0x7,0x70, 0x30,0xf8,0x7,0xf0, 0x1c,0x3e,0x3,0xc0, 0xf,0x0,0x0,0x80, 0xf,0x80,0x0,0x0, 0x3,0xf0,0x0,0x0, 0x0,0xfe,0x0,0x0, 0x0,0xe,0x0,0x0 }; SoftwareSerial SoftSerial(4, 3); //RX, TX Adafruit_SSD1331 display = Adafruit_SSD1331(cs, dc, rst); void setup() { display.begin(); display.fillScreen(BLACK); printSplashScreen(); SoftSerial.begin(9600); // the SoftSerial baud rate delay(1000); Serial.begin(9600); // the Serial port of Arduino baud rate. delay(2000); printUI(); } void loop() { String altitude ; while (SoftSerial.available() > 0) gps.encode(SoftSerial.read()); if (gps.location.isUpdated()) { Serial.print("LAT="); Serial.print(gps.location.lat(), 6); Serial.print(" LNG="); Serial.println(gps.location.lng(), 6); } if (gps.altitude.isUpdated()) { Serial.print("Altitude:"); Serial.println(gps.altitude.meters()); altitude = String((int)gps.altitude.meters())+" m"; display.setCursor(18,35); display.print(altitude); } } void printSplashScreen() { display.drawBitmap(0,0,title,96,64,RED); display.drawBitmap(65,0,gpsIcon,30,30,GREEN); } void printUI() { display.fillScreen(BLACK); display.setTextColor(WHITE); display.drawBitmap(0,0,ui,96,64,WHITE); display.setTextSize(2); display.setTextColor(BLUE,BLACK); }
Demo
The demo for this project is quite simple. Go over the schematics to confirm you have everything hooked-up correctly then upload the code to your Arduino board. After a few minutes you should see the altitude of the device’s current location being displayed on the OLED. Be sure to test the module outdoors and with a view to the sky.
That’s it for this tutorial guys. Thanks for going through it to the end. If you have questions around today’s tutorial, feel free to reach out to me via the comment section.
Till Next time!
The video version of this tutorial is available on youtube.
Thank’s for the information.