Introduction: OLED Car Gauges

This started as project to add gauges to my Lotus Elise after being put off the idea of large retro style analogue gauges that took up too much space in the small interior of the car. being a complete novice to programming and all forms of cad before this project I'm very happy with the end result.

Step 1: Materials and Tools

To successfully complete this project you will need the following as a minimum;

Step 2: Creating the Images

A key step and probably the most time consuming is to create a set of images that will be used to animate the working gauge/s. If you would like to skip this step for testing or if your project requires oil pressure or oil temp then there are sample images in the form of a pre-made gif on my github page here: https://github.com/dan22h/OLED-gauge

I found the best way to manufacture the images was to use inkscape (a free vector drawing program). I won't go into to much detail on using inkscape as there are plenty of good tutorials online, the key points to note are that it's worth setting up your page to mimic the resolution of the screen size (160x128), this is done by going to File, Document properties and under page set a custom size in pixels matching the display.

It is now a process of creating a base image for how you would like your screen to look, feel free to play around with this part to get it right as it will be the basis for every image you create afterwards. A key issue to point out here is that it's wise to test upload images to the screen to see how it will look before you waste time creating an entire sequence of images as certain colours don't come out out the same on the small screens as they do on a PC monitor. Grey was the worst offender for me, I found using a grey with a hint of blue or purple came out best.

You now need to create an image for every single value that you want to be able to display, making sure to edit any analogue elements such as sweeping needle with each change in numbered value. make sure to export the .png image for each screenshot before moving on to the next. It's absolutely essential that you export each image at the page size matching the screen resolution. If anyone knows a shortcut to this process please let me know.

I found the digital LCD style text worked best for moving images as it flows nicer due to the numbers staying in the same physical location no matter what number is displayed although feel free to experiment with this.

Step 3: Compile Images Into .GIF

Although the screens can be run using raw images, for reasons I'm not fully aware of the refresh rate is about 2x faster when using a .GIF file to call the images from.

A nice and simple browser based .GIF maker can be found here http://gifmaker.me/

Another curious issue with the screen is that when running a .GIF file, only colours used in the very first image will be used for all proceeding images. To combat this i create an image in inkscape made up from a jumble of different screens, so long as all necessary colours are present here, the rest of the .GIF will work perfectly. In the attached image you can see I have included this 'primer' image as the first in the sequence, this will never be displayed in the real world.

The second image In the sequence is your splash screen (the image you want to display on startup) followed by gauge screens in rising numerical value (very important).

If you want to have a multi gauge that displays different values on say a button press, then you can add these images onto the very end and modify the arduino code to call them up when required. this is how my oil pressure/voltage gauge is configured. I also have sample code on github for a spllit screen gauge I made for a friends BMW M3 to display diff and gearbox temps.

Step 4: Load Images to USD Card

Now that you hopefully have your images compiled into a GIF it's time to load them on to your uSD card.

Open the graphics composer inside the 4d workshop IDE, select add, then direct to your .GIF file. From the bottom right select the native screen resolution 160x128 in this case, don't worry about any other settings here, now click build (the little micro chip logo) it will ask you to save a .gcs file to your computer that can be used to quickly upload the same images at a later time. Leave build type as FAT selected folder, select the drive for your SD card and click OK, after a few seconds the SD card is good to go.

Step 5: Flash the Display

To prepare the display to run from serial commands from an arduino we need to first navigate to this directory;

C:\Users\Public\Documents\4D Labs\4DUpdates\Utils

look for uoled-160-g2.inc and open in notepad, delete the contents and replace with this;

media_Init();

media_SetSector(0x0000, 0x0000) ;

media_VideoFrame(0, 0, 1) ;

this code will load the 2nd image from the .GIF which should be your splash screen

Now connect your display to the PC using the dedicated programming cable, open up the 4d workshop IDE, from here navigate to; File, Options, Serial. Set the baud rate to 38400 and disable the screen saver by entering 0, then click OK.

Open a new project, selecting the uOLED-160-G2 and choose serial when prompted. Once opened navigate to Tools and select SPE load, this will flash the code revisions to the screen (select comms if you're having issues connecting to the screen). The screen is now good to go once the uSD card has been inserted.

Step 6: Connect to Arduino

For this stage I designed and made my own printed circuit boards with a dedicated automotive power supply to account for transient voltage spikes and the likes (I can provide more of these should anyone require). The actual control circuit consists of an attiny84 per screen, programmed using the arduino IDE using software serial to communicate directly with the display, This can be easily substituted for an arduino of your choice by simply editing the pin numbers you wish to use. All source code can be found here https://github.com/dan22h/OLED-gauge

The code contains completely customisable mean and running average calculations to smooth the output readings and provide very stable outputs, there is a built in dimmer function that can be enabled by pulling the appropriate pin to ground (I have this connected to my headlights using an optocoupler on the PCB) dimmerlow and dimmerhigh values can be set to suit, the same applies to the oil pressure/voltage gauge whereby the appropriate pin is pulled to ground to switch the display. Actual voltage readings are by means of a voltage divider circuit, again part of my PCB. There is code contained to control a relay that allows the gauge to run on after the car is turned off for a set period of time, this also allows the screen to be shutdown properly before disconnecting the power supply

Although the code can be configured to run any choice of sensor depending on your requirements, as it stands it uses an lmt86 linear output temperature sensor, I selected this for it's very high accuracy over it's complete operational range -50 to 150 degrees centigrade, I integrated the sensor into a 1/8npt sensor thermowell to connect directly to the engine.

Oil pressure is by means of 0-100psi digital transducer out putting a linear analogue voltage, again much better than the traditional sensor types with built in temperature compensation.

Step 7: Testing the Display

Time to apply the 5v supply to the screens and arduino, make sure there is a common ground to allow smooth comms between the two. it's a good idea to test against a known value here to confirm the code is up to scratch.

Step 8: Create Your Enclosure

This part is completely up to you, although I've included several incarnations of my own for inspiration, starting with my early laser cut surround up to my SLS 3d printed parts.

Enjoy

Sensors Contest 2017

Participated in the
Sensors Contest 2017