Arduino Sketch for a Retro Analogue Meter Graphic on a Modern TFT Display





Introduction: Arduino Sketch for a Retro Analogue Meter Graphic on a Modern TFT Display

Another sketch from my collection that may be of interest...

Displaying small digital numbers of temperature and humidity etc on a tiny screen is not always the best way to show information. The old style analogue meters are better in some situations and are great for a quick visual check of a sensor reading from a distance, they are also a good way of showing trends. So here we have a retro looking analogue meter on a modern TFT display, complete with smoothly animated needle!

I've pulled together a couple of functions in a demo sketch here for digital and analogue meters. I have not got around to "parameterising" the functions, so at the moment it is not easy to draw the meters anywhere on the screen with defined size and scales, but if there is sufficient interest (and given time!) I will try to do this at some point, in which case this Instructable will be updated.

I used an UNO and 2.2" ILI9341 based 320 x 240 pixel TFT, these are available at low cost on the internet.

Step 1: Connecting Up and Libraries Needed

The UNO is connected to the TFT display as in my Instructable here.

The libraries needed are also in that Instructable too.

Step 2: The Meters

The analogue meter has a moving needle that sweeps slowly with configurable speed to show the new value of a variable. The value in this example is in the range 0 to 100 (I used it for showing humidity). Meter labels can be changed easily. The actual new digital reading is shown in the bottom left corner of the meter. Needle end stops are emulated for readings outside of the normal range! Coloured zones can be added to show comfortable ranges etc.

Tip: The needle flicker is minimal but removing the units display from the needle sweep zone will improve things (and also mean that Font 4 does not need to be loaded, saving FLASH space). Just two lines in the sketch (156 and 200) need to be commented out, use the new Arduino 1.6.0 IDE and switch on line numbering to help find them!

The digital meter uses a 7 segment font and shows a dim image of the unlit segments to try to emulate the look of a real 7 segment display! The colour could easily be changed, perhaps with the value as in my Instructable here.

Step 3: The Sketch

Here we are...

Normally I would make graphics functions like this easier to adapt, resize and relocate on the screen, but I did not need to elaborate the functions for my application. Come back for updates and any bug fixes at a future date!

Step 4: Video...

Here is a video of the analogue meter in operation (this includes some linear meters that are not part of this instructable). The needle flicker and jerky pauses in the video is due to my cheap webcam, the actual movement is much much smoother.



  • Water Contest

    Water Contest
  • Clocks Contest

    Clocks Contest
  • Creative Misuse Contest

    Creative Misuse Contest

14 Discussions

Have you had any issues with screen burn-in or are you only using this for short bursts? Thanks.

1 reply

I have only run TFT's fot 100's of hours and the screens change so I have not seen any problems.
TFT's don't suffer from permanent phosphor burns like CRT's did but it is possible to get image persistence in the LCD polarising medium which can sometimes be "washed away" by cycling the colours.

These displays are so cheap I have not been concerned about the problem myself.


2 years ago

This is exactly what I was looking for. Thanks a ton!

It would be too much to ask a skit where the orientation of the meter out 90 degrees to the right and to occupy 90% of TFT?

And it would be an example of how to modify the sketch paa have a full scale of 30 and a total of 100 increments for full scale deflection?

Thanks and congratulations

8 replies

Here you are, hope this is what you want...

The zip file contains a new library for the ILI9341 display and a sketch called "TFT_Meter_linear_4_30" which has been modified.


Hi, first of all I wanted to thank you for helping me !!!!

It's perfect but I get a blue vertical parallel lines tested under needle.He ARDUINO fleet card and other new TFT and continue to show the blue vertical lines do not you get it done ?



I have tested it again on my setup and it works fine. Can you post a picture so I can see these blue lines?

It looks like the display data going to the display is getting corrupted. Do you have any other electronics connected?


Hi, thank you very much Bodmer. Already solved, the problem was that I was using an old IDE. I used the IDE 1.6.0 and it works perfect. You can center the meter in the center of the TFT? (Not in the top part)

And the indication at the lower left corner does not match the indication of the needle (needle) can be adjusted to match the indications of the needle and the digital display? Thank you and congratulations !!!

Perfect, that is just what I needed, Bodmer!!!! Thanks a lot!!!!

Another question, you can display text at the bottom of the TFT, the party remains free under the indicator, which indicates eg "RH METER ON" when the A1 (Arduino analog input) is set to "1 "or high value?


Just add these lines after plotNeedle function on the loop():

tft.setTextColor(TFT_WHITE,TFT_BLACK); // Text colour
if(analogRead(A1)>511) tft.drawCentreString(" RH METER ON ", 160, 210, 4);
else tft.drawCentreString(" RH METER OFF ", 160, 210, 4);

Thank you very much again, Bodmer. Thanks for sharing your knowledge and the time you spend with us


I've tried to modify the sketch to suit the 1.8" ST7735 Display with no joy

is this something you could help with ?

many thanks


1 reply

OK, it is tricky to mod..

Here is a copy of the ST7735 library I use and I have added a meter sketch that works with this display.

You may have to change the initR parameter at line 40 to the one in 41 as some ST7735 displays use a different initialisation setup.

Let me know how you get on with it.