STM32F103C8T6 with RTC DS3231 & I2C LCD 16x2

Post here first, or if you can't find a relevant section!
Post Reply
Arief Azzmi
Posts: 1
Joined: Sun Jun 14, 2020 5:25 am

STM32F103C8T6 with RTC DS3231 & I2C LCD 16x2

Post by Arief Azzmi »

Hi from Malang, Indonesia,

This my first time using STM32 for my personal study. I need tutorials to make my own digital clock using Blue Pill, DS3231 RTC and I2C LCD. Is there any library that suitable for my project? I've searched for it, but it's not compatible. And i still don't know about the code, too.

Thanks, really need your advices and help.
ag123
Posts: 1668
Joined: Thu Dec 19, 2019 5:30 am
Answers: 25

Re: STM32F103C8T6 with RTC DS3231 & I2C LCD 16x2

Post by ag123 »

stm32 has its own rtc, and the blue pill has its on 32k crystal check the libraries.
same with the LCDs, there is probably an existing library
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: STM32F103C8T6 with RTC DS3231 & I2C LCD 16x2

Post by mrburnette »

Arief Azzmi wrote: Sun Jun 14, 2020 5:35 am ...
This my first time using STM32 for my personal study. I need tutorials to make my own digital clock using Blue Pill, DS3231 RTC and I2C LCD. Is there any library that suitable for my project? I've searched for it, but it's not compatible. And i still don't know about the code, too.
...
Welcome to the forum.
With a 'blue pill' you have a choice of two directions: Roger Clark's core and the STM official core.

Some basic knowledge about Arduino:
- Libraries are mostly written for external devices: sensors by model or modules by name... so, you would be looking for a "DS3231" library compatible with the "STM32F103xx blue pill". As stated by AG123, the blue pill has a 32K watch crystal. I did a write-up of a clone board recently and posted a test sketch using that library: here
and the library for use with Roger's core is here.

Now, for a display.
- As stated above, libraries are generally written for external devices. You need a display and they come in two general protocols: SPI and I2C.
I have an example of using an OLED I2C display here.
I have an example of using an ILI9341 SPI display here.

For Roger's core, much information can be found in the old forum: here.

For blue-pill and maple-mini STM32F103 projects, I have a few here. Many are years old, so I cannot promise that the newest ArduinoIDE will compile them error-free, you may have to study the error message and do your own fixing. But, the examples would be fair for guidance on creating your own code from scratch, which is what I would suggest. For example, I have a STM32F103 GPS clock design here.

Now, a little bit about the Official core that I gave the link to previously. That core is far more sophisticated than Roger's core as it is a commercial product with thousand of users, thus it is well supported and has evolved to be very complete. By contrast, Roger's core is an enhanced version of the LeafLab's core which is 10+ years old. LeafLab still maintains a static copy of their old support forum and documentation here.

Good luck, I hope the links above will give you some motivation to take a bit of time and do some reading and then select a path forward for your clock project. You will learn so very much more by taking bits and pieces of what you need and then building your own project. If you get an error, everything is explained somewhere from a Google Search.

Ray
fredbox
Posts: 125
Joined: Thu Dec 19, 2019 3:05 am
Answers: 2

Re: STM32F103C8T6 with RTC DS3231 & I2C LCD 16x2

Post by fredbox »

The first thing to do is to connect the hardware one piece at a time and then run a I2C scanner program to make sure that your I2C devices are detected at the right address. In Ardiuino, select File->Examples->Wire->i2c_scanner.

DS3231 modules typically have two addresses, one for the clock and another for the eeprom.
I2C backpacks as used on a LCD module should have one address.

There are at least three different I2C backpacks that are wired differently that are used on 16x2 LCD modules. You will need to make sure that the library you choose has the right configuration to match your display.

The DS3231 and LCD are simple enough that libraries are not necessary, but you should be able to find suitable ones in the Arduino library manager. Also, most DS3231 modules expect a rechargable battery. You will need to disable the charger if powered by more than 3.3 volts.

For DS3231, I use a variation of the code here: https://tronixstuff.com/2014/12/01/tuto ... h-arduino/
Post Reply

Return to “General discussion”