Showing results for 
Search instead for 
Did you mean: 

Can't get a device to work on I2C on STM32F4

Associate II
Posted on November 01, 2016 at 13:19


In the past, I used Arduino Mega and Uno for some project of mine that required an OLED screen based on

driver and Real Time Clock module (

). Both work on I2C interface and worked just fine on Arduino. Chronodot uses Stephanie Maks'

and SSD1306 used

. I needed more CPU power and memory, therefore I bought STM32F4 I rewrote Stephanie Maks' library to work with Tilen Majerle's

for STM32F407, which is also used by SSD1306 through

. The SSD1306 screen worked without a problem on any I2C (I2C1, I2C2, I2C3), but I could not get Chronodot to work. I tried different I2Cx and pin packs, but still nothing. I connected it back to Arduino and it works without a problem. Yes, I could have made a mistake when rewriting the library, BUT it doesnt even pass the basic test:

Chronodot rtc;

TM_I2C_Init(I2C1, TM_I2C_PinsPack_1, 400000); 
// Configure I2C for RTC


/* Check if RTC connected to I2C */

(!TM_I2C_IsDeviceConnected(I2C1, CHRONODOT_ADDRESS))


/* Return false */



Is it possible that different I2C is used on Arduino and SSD1306 screen just includes both versions? Maybe some ACK or something? I do not fully understant everything that can change in this protocol so I can't speculate much what could be wrong. I ask for your assistance please. Thank you! #i2c-ssd1306-stm32f4-chronodot
Associate II
Posted on November 01, 2016 at 22:23


I guess you double checked all connections and HW wise everything is correct ( for example I read the the Chronodot doesn't have pull up resistors on board which are necessary for the I2C, so I assume you have them on the STM32F4 board... )

Your code looks correct, my only hint is to verify the Slave Address of the Chronodot.

On the Arduino you use 0x68 ( just the 7 bits ) on TM library ( and in general STM32 I2C libraries ) you must specify the full 8 bits, so the address should be 0xD0..


Associate II
Posted on November 02, 2016 at 11:13

Thank you for response!

Yes, that was exactly it, 8-bit address instead of 7-bit. I even read an article on addresses and I couldn't figure out that it was wrong. Thank you so much!