mercredi 29 novembre 2017

Oled display and Arduinos

This article is to highlight a few points for anyone wanting to use an Oled display with Arduinos.
I had a few trouble with them, therefore it is also a reminder for me.
These are the cheap Oled displays (0.96 In  or 1.5 In, 128x64  ) connected via I2C, found everywhere on the net.
Power supply ; 3.3 V  or 5V, any voltage is Ok, no difference in brightness.
SCL connected to pin A5
SDA connected to pin A4

Arduino uno and Oled display;

For some unknown reason, the Arduino UNO could not raise correct signals. The thing worked when the two signals SCL and SDA were connected through 10K resistors to Gnd.

The U8Glib library worked fine. I have used as header :

#include "U8glib.h"
#include <Wire.h>
and as descriptor
U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_DEV_0|U8G_I2C_OPT_FAST); 

Arduino 101 and Oled display;

Although the 101 could seem compatible to the UNO, it is not exactly.
Differences are
-the core is a 32 bits core
- voltage is 3.3 V
Because of that, the U8g2lib will not work.

Why using the 101 ? Because it has accelerometers, gyros, more memory and will use a real time operating system (multitasking)

In that case, Oled displays do not need any resistor.
Supply is 3.3V, of course.

As a header I have used succesfully
#include <U8g2lib.h>
#include <Wire.h>
descriptor :
U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0,SCL,SDA,U8X8_PIN_NONE);

and some links :
https://create.arduino.cc/projecthub/alexis-santiago-allende/oled-display-with-arduino-101-a96935
https://github.com/olikraus/u8g2/wiki/