Introduction: Nextion/Arduino Calculator

A useful calculator for the Arduino Uno. The calculator is similar in style to the
standard calculator that ships with Windows 10. Note: It does not include the scientific and programmer functions that the Windows 10 calculator does, but these functions may be implemented at a later date.

The calculator provides a set of 10 functions:

  • Add, Subtract, Multiply, Divide
  • Percentage calculation
  • 1/x calculation
  • Square root
  • Square
  • [C]ancel - clears the calculator's memory
  • [CE] Clear Entry - Deletes the last entry made into the calculator

All calculations are carried out with double precision. Note that because of the Arduino being as small as it is, the output of decimals is limited to two places.

This version of the calculator uses a Nextion NX4832T035 3.5" HMI TFT LCD Display which should be connected to the TX/RX pins of the Arduino (see the Build Hardware step).

Supplies

  • Arduino Uno
  • Nextion NX4832T035 3.5" HMI TFT LCD Display (Available from Ebay)
  • Jumper wires
  • 4Gb Micro SD Card (Available from Ebay)
  • Micro SD Card Adapter (Available from Ebay)

Step 1: Build Hardware

Hardware setup is simple, requiring only a few connections.

Connect the LCD display to the Arduino Uno as follows:

Nextion LCD Arduino Uno

  • GND -> GND
  • VCC -> VCC
  • TX -> RX (pin 0)
  • RX -> TX (pin 1)

Step 2: Upload the TFT File to the Display

The TFT file is the calculator's user interface file displayed by the LCD. It is contained in the project ZIP file which can be downloaded from GitHub and needs to be uploaded to the LCD for display. Download it now, and extract the contents on to your computer drive.

We will use a micro SD card to do the upload. Insert the micro SD card into the micro SD card adapter and plug the adapter into your PC. After a few moments, Windows will recognize the SD card as a new drive. Right-click the drive and select Format from the menu. Select FAT32 as the format type and click okay.

The formatting should take just a few seconds. Formatting the SD card is a necessary step, or the Nextion won't be able to read its contents.

Power off the LCD. Copy the calculator-ui.tft file from the ZIP file to the formatted SD card and insert the card into the Nextion LCD. Ensure that the calculator-ui.tft file is the only file on the SD card, or the Nextion won't load the file.

Power on the LCD and the device will load the TFT file from the SD card. Remember to remove the SD card from the LCD when the upload is complete.

Power off, then power on your display and you should see the calculator's user interface.

Step 3: Upload the Calculator Sketch to the Arduino

Locate the Nextion-Calculator.ino file from the project ZIP file that you downloaded and open it in the Arduino IDE.

Make sure your Arduino is connected and then compile and upload the sketch.

That's it! You should now have a working calculator running on the display. Try a few calculations.