OLED Digital Clock With Arduino Pro-mini

by jandb86 in Circuits > Arduino

3898 Views, 3 Favorites, 0 Comments

OLED Digital Clock With Arduino Pro-mini

00_overview.jpg

This is digital clock using 0.91 inch OLED and arduino pro-mini.

It’s the first time for me to utilize the very small OLED display and tiny pro-min board.

Therefore, simple project is chosen as digital clock making is relatively easy and not much complex.

While making the circuit above, I need to handle several challenges like below.

***

- Pro-mini board type is very confusing as 3.3v and 5v type of boards are available

- As pro-mini board lacking USB interface for programming, additional break-out board (USB to serial programmer) is necessary for uploading sketch code

- 0.91 inch OLED is using I2C interface and DS3231 real time clock module also using I2C for communication

- Choosing correct voltage regulator is necessary for power up the clock circuit

***

When you using arduino Uno or Micro boards, circuit wiring and uploading program is very easy as there are many how-to contents are available in Internet.

But for the simple project such as clock making, personally thinking that using expensive Uno or micro boards is a kind of luxury. .

That’s why I’m choosing pro-min board as its price is the half of Uno and Micro boards.

But according to the how-to in several web-pages I saw, pro-mini is a little bit special for configuring and using it.

Let’s start story about making digital clock with pro-mini.

Knowing About Pro-mini Board

01_Pro-mini_2.jpg

As you can see, there are no kind and detail explanations available about the board I received.

Also soldering pin-heads by myself is necessary.

When I saw the “The simple” marking at the backside of the board, it seem like playing joke on me.

Therefore, I was searching web pages to get information about pro-mini board.

And I knew that there are several variants are available as follows.

***

- Arduino Pro Mini (3.3V, 8 MHz) w/ ATmega328P

- Arduino Pro Mini (3.3V, 8 MHz) w/ ATmega168

- Arduino Pro Mini (5V, 16 MHz) w/ ATmega328P

- Arduino Pro Mini (5V, 20 MHz) w/ ATmega328P ??

***

There seems diverse pro-mini boards are available using different Input voltage (3.3v, 5v), processor type (ATmega328P, ATmega168) and clock speeds (8M, 16M, 20M).

The marking on the backside of the board saying “simple”…. Huh?

Also pin layout is very different from Uno and Micro boards and confusing.

Especially location of I2C pins including A4 (SDA) and A5 (SCL) (analog pin 4 and 5) on the pro-mini board is interesting.

“Which type of board I bought” is the first challenge I faced to start clock project.

Identifying Pro-mini Type

02_pro_mini_type.jpg

For identifying specific pro-mini board type, someone recommend check markings on the CPU process chip and oscillator.

But the markings are so tiny to see with naked eyes without magnifying glass.

Therefore measuring voltage between Vcc and GND of pro-mini is the most reliable method as shown in the picture above.

Connections for measuring Vcc voltage is like below.

***

- Connecting 6~8V external DC power supply to the RAW and GND pins of pro-mini board

- Measuring voltage between Vcc and GND

- If pro-mini is 5V type, Vcc voltage shall be 4.5 ~ 5V range

- If it is 3.3V type, voltage may 3.1 ~ 3.3V

***

As Vcc voltage is 4.6V, the board I bought is 5V type with ATmega328P processor and 16M clock speed (or maybe 20M).

When you looking very hard on the CPU surface, you can read tiny marking of CPU type.

OK! Anyway… finally I know which pro-mini board I have…. Very SIMPLE isn’t it.... Huh?

Parts

03_Parts.jpg

Clock circuit is not much complex as you can buy ready-to-use break-out boards, wiring all together and assembling them for finishing.

Only the LM7806 power supply board is the one I made myself.

The following is the detail parts list.

***

- Pro-mini board soldered on the universal board

- 0.91 OLED break out board which using I2C for communication with pro-mini

- DS3231 RTC (Real Tine Clock) break out board

- Power supply board using LM7806

- 9V power wall mount adaptor

- Acrylic board (10cm W x 7cm H x 4mm(4T)/3mm(3T) D) x 2

- Metal supporter 2.5cm length x 4

- Bolts and nuts

Wiring Pro-mini With Other Break-out Boards

04_wiring_2.jpg

I mentioned several challenges in the head of this story.

Among them, choosing power supply voltage and cascading two I2C devices (0.91 inch OLED and DS3231 RTC) is included.

Firstly, I choose 6V for power supply voltage because of the following reasons.

***

- Pro-mini board including Microchip MIC5205 LDO (Low Drop Out) voltage regulator and it requires only several hundred mV for output 5V regulated voltage

- Therefore supplying 6V is quite OK for powering pro-mini board as well as 0.91 OLED and DS3231 boards

- As OLED and DS3231 boards will consume less than 100mA, LM7806 regulator is enough for supplying all required power

***

I don’t know why I bought several of LM7806 chips before.

Until now I can’t find right chance to use this chips.

Usually LM78xx required more than 2.5V different between input and output for proper voltage regulation.

But MIC5205 LDO of pro-mini only requires several hundred mV for correct voltage regulation, LM7806 can be utilized happily and only 1V difference between input and output is quite OK.

The other challenge is connecting two I2C devices to pro-mini board.

This one is also not much problem as two wires (SDA, SCL) from the pro-min can be wired together with two devices as cascading manner.

As each I2C device assigned with unique physical identifier, pro-mini can differentiate two devices with single line of control bus consists with SDA and SCL.

Failed Attempt for Programming Pro-mini

05_FTDI.jpg

This is last obstacle for making digital clock.

The shown is AVR (Advanced Virtual RISC micro-controller) programming tool supporting USB to serial (TTL level) converter which uploading program to an arduino pro-mini.

When I plugged it to PC, Windows device manager automatically install FTDI (company) device driver and recognize it as USB serial converter.

It also interfacing with Arduino IDE and seem inter-operating while sketch compiling and uploading.

But actual result is very disappointing.

Error occurred every-time Arduino IDE trying to upload compiled program.

Maybe something wrong with this specific board which I bought together with pro-mini.

But I can’t find any technically helpful information about this board.

If you are planning to buy programming tool, firstly checking the technical documentations are available for the product.

Otherwise you will face the same problem I experienced.

Successful Pro-mini Programming With Uno

06_Programming.jpg

Because bought programming tool is not working, I happened to give up for making clock with pro-mini.

But I found this instructable which explaining pro-mini programming method with Uno.

***

https://www.instructables.com/How-to-Program-Arduino-Pro-Mini-Using-Arduino-UNO/

***

As shown in the picture above, finally pro-mini is programmed by Uno with the following wiring between them.

***

- Rest (Uno) -> DTR (Pro-mini)

- Tx (Uno) -> Tx (pro-mini)

- Rx (Uno) -> Rx (pro-mini)

- 5V (uno) -> Vcc (Pro-mini)

- GND (Uno) -> GND (Pro-mini)

***

I will not repeat all how-to here as each step for programming with Uno is explained in the instructable mentioned above.

Finally last obstacle is disappeared by the help of other instructable author.

You can see video in the link below for the Uno operation while program uploading.

***

https://drive.google.com/file/d/1e39EJcqooRnTAZbFA...

***

When Uno start program uploading, you can see Tx and Rx LEDs of Uno blinking very rapidly in the video.

Sketch Program Code

07_Code.jpg

As sketch code is a little bit lengthy, I’ll explain only important code segments here.

I’m using well known DS3231 sketch code available in Internet

The DS3231 code supporting the following functions.

***

- Communicate with DS3231 IC ship for getting present year, date, time and temperature data

- Also time setting is possible by entering string by serial monitor console such as “T1605091300002” (2016 (year) 5 (month) 9 (day) 13 (hour) 00 (moniue) 00 second Monday) : T(Command string for time setting) + year(00~99) + month(01~12) + day(01~31) + hour(00~23) + minute(00~59) + second(00~59) + Day of the week(1~7, Sunday-1 Monday-2 Tuseday-3 Wendsday-4 Thursday-5 Friday-6 Saturday-7). For example T2101241845001 means (year 2021 January 24 PM 6:45:00 Sunday)

- Time data read from DS3231 chip is stored to variables including hours, minutes and seconds

***

As I necessary only 3 time data (hour, minutes and second), the following code is added.

***

- Gathering 3 time data to the String tm_str

- If hour, minute and second values are less than 10, add “0” for making hour/minute/second as two digit

- Put colon(:) between hour and minute

***

When time string (including hour/minute/second) is ready, activating OLED driving sketch code.

I’m using code in the other instructable (https://www.instructables.com/Tutorial-to-Interface-OLED-091inch-128x32-With-Ard/) which using u8g2 library for controlling 0.91 inch OLED.

The OLED driving sketch code supporting the following.

***

- Clear the internal memory (It will clear 0.91 OLED screen)

- Choose a suitable font

- Write something to the internal memory (Then written character or graphic will be shown on the screen). The u8g2 drawStr function should be called with c_str() method of String to be displayed on screen. Therefore “u8g2.drawStr(1,29,tm_str.c_str());” is used and time string will be display from the position column 1 and size of 29.

- Activating screen for showing written data

***

You can find detail about displaying characters on OLED screen in the instructable mentioned above.

The sketch code I’m using can be download in the link below.

https://drive.google.com/file/d/19kgfvoZOjlmJP7dkZv7CU09ZWjylL7Pk/view?usp=sharing

Thanks for reading.......