Close
0%
0%

Nextion 3.5" LCD Digital Compass for Arduino Uno

How to build an accurate digital compass using a 3.5 inch Nextion LCD and a QMC5883L compass module using the Arduino Uno.

Similar projects worth following
This is an accurate, easy to build digital compass that uses a 3.5 inch Nextion TFT LCD display and a QMC5883L 3 axis compass module.

Building an accurate digital compass is a fairly straight-forward task, especially with the Arduino Uno which makes life easy with its excellent libraries. What distinguishes this compass from others is that it uses a 65,336 colour TFT LCD to display a nice image of a compass and a heading in degrees. I also spent some time investigating the phenomenon of polar wander which affects compass readings.

To ensure that the compass is accurate, one needs to take into account the user's magnetic declination. The molten rock churning and spinning below our feet causes the Earth's magnetic poles to slowly wobble. This wobble affects the compass' reading. The magnetic declination is the "wobble offset" that needs to be added to a heading.

Magnetic declination is an important concept for accurate navigation. A compass will always point along the lines of magnetic force (which converge on what are called the magnetic poles). The angle between the direction of force and the direction of the geographic north pole is called the declination. If a compass at your location is pointing to the right of true north, declination is positive or east, and if it points to the left of true north, declination is negative or west. As one moves across the surface of the globe, lines of constant magnetic declination are called isogonic lines.

The image shows level curves drawn on a declination map to denote the magnetic declination varying over the years since 1900. Each level curve is an isogonic line.

Fortunately, the magnetic declination for locations on Earth are tracked by various agencies. It is possible to measure it directly yourself, but the easiest way you can obtain this information is to visit the magnetic-declination.com web site and look it up for your location.

The image above shows the magnetic declination for my location in the UK. This value is added to the heading azimuth (the angular heading measurement) obtained from the compass module. In my case, the value is -1.5. A failure to add this value to the heading results in an inaccurate compass reading. Furthermore, since the magnetic declination varies with time, the compass needs to be updated with the new value on a periodic basis.

For those of you requiring a little  more information, you can access the National Oceanic And Atmospheric Administration website's declination viewer . This viewer displays declination data stretching way back when and also provides predictions about where it may go next.

In addition to the viewer, the National Geospatial-Intelligence Agency (NGA) provides source code written in C that is free to download and includes a data file updated every five years to account for movement of the magnetic north pole.

To add to the implementation woes, since the magnetic declination also varies with location, a truly effective compass would obtain your GPS location and automatically lookup the declination. But this adds to the expense of the hardware. I make no attempt to do this with this compass: You simply edit the micro-controller source code and add your magnetic declination as a constant. Problem solved, albeit a little inelegantly.

In a nutshell, other than calibrating the compass before you use it (this entails rotating the compass 360 degrees and recording some offsets) that's pretty much the only detail you need to take care of with a digital compass. Connecting a compass module to an Arduino and an LCD is an easy task. The hard part is ensuring that the compass will produce an accurate reading.


See the Build Instructions section for instructions on building this compass.

  • 1 × 4GB Micro SD Card The LCD loads its user interface from a micro SD card
  • 1 × Arduino Uno
  • 1 × QMC5883L Compass Module Available for a few dollars from Ebay.
  • 1 × Nextion NX4832T035 3.5" TFT LCD Display
  • 1 × Micro SD Card Adapter An adapter is required to transfer files from your PC to the micro SD card.

  • 1
    Build Instructions Article

    I have produced an article containing full build instructions for this project and published it on my Arduino Project Hub. The URL is: https://create.arduino.cc/projecthub/mariogianota You will find the compass listed as one of the projects I have there.

View all instructions

Enjoy this project?

Share

Discussions

Eric Christian wrote 07/11/2023 at 01:47 point

Hello from Eric, How can I get the Nextion TFT file for this project?

Thanks in advance

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates