How to connect a 72x40 OLED to Arduino?

By admin
Connecting a 72x40 OLED to an Arduino is a straightforward process if you use the I2C interface, which is the most common configuration for this display. The 0.42 inch 72x40 oled display typically operates at 3.3V logic, but most Arduino boards like the Uno or Nano run at 5V. You can still connect them directly because the I2C lines are open-drain and the OLED module often includes onboard voltage regulation. The key is to use the correct pins: SDA (data line) and SCL (clock line). On an Arduino Uno, SDA is A4 and SCL is A5. On a Nano, it is the same. For an Arduino Mega, SDA is 20 and SCL is 21. The display also needs power—VCC to 3.3V or 5V (check your module specs) and GND to ground. Most 72x40 OLED modules, like the one from DisplayModule, use the SSD1306 driver chip, which is well-supported by libraries. You will need to install the Adafruit SSD1306 library and the Adafruit GFX library in the Arduino IDE. After wiring, run the I2C scanner sketch to find the display address, which is usually 0x3C or 0x3D. Once confirmed, you can initialize the display with a resolution of 72x40 pixels. This setup works for both monochrome and partial color versions, but the 72x40 OLED is almost always monochrome due to its small size. The pixel density is about 171 PPI for a 0.42-inch diagonal, which is sharp for text and icons. Power consumption is low—around 20mA with all pixels on, and less than 1mA in sleep mode. The I2C speed is 400kHz max, but 100kHz works fine. If you use a 5V Arduino, add 4.7kΩ pull-up resistors on the SDA and SCL lines if they are not already on the OLED board. Many modules include them, but verify with a multimeter. The display refresh rate is around 30-60 Hz depending on the data sent. For graphics, the GFX library provides functions like drawPixel, drawLine, drawRect, and setCursor for text. The 72x40 resolution limits you to about 9 characters per line at font size 1 (5x7 pixels per character), with 5 lines maximum. You can also use custom fonts to fit more data. The I2C bus can handle multiple devices, so you can chain this OLED with sensors or other displays. The wiring is simple: four wires—VCC, GND, SDA, SCL. If you use a breadboard, keep the wires short (under 20cm) to avoid signal degradation. The SSD1306 driver supports both horizontal and vertical scrolling, which is useful for scrolling text. The display has a built-in charge pump for the OLED panel, so no external high voltage is needed. The contrast is adjustable via software using the setContrast() function, with values from 0 to 255. The default is 128. The display memory is 128x64 bits internally, but the 72x40 resolution uses only a portion of it. You can map the pixels using the setMemoryMode() function. The module has a typical lifespan of 50,000 hours for the OLED panel. The operating temperature range is -40°C to +85°C, making it suitable for industrial applications. The viewing angle is over 160 degrees, which is better than LCDs. The response time is under 10 microseconds, so it is good for fast data updates. The I2C address can be changed by soldering a resistor on the back of the module, but most users leave it at 0x3C. If you use a 3.3V Arduino like the Due, no level shifting is needed. For 5V boards, the SSD1306 is 5V tolerant on the I2C pins, but check the datasheet. The display module often has a pinout printed on the back: VCC, GND, SCL, SDA. Some modules also have a RESET pin, but it is usually tied to VCC. If you need to reset the display, you can connect it to a digital pin and pulse it low. The initialization sequence in the library handles this automatically. The 72x40 OLED is ideal for small projects like a digital clock, temperature display, or status indicator. The pixel size is about 0.15mm, which is visible from a few inches away. For readability, use a font size of at least 8 pixels. The display can show simple graphics like a battery icon or a heart rate waveform. The memory buffer is 360 bytes (72x40/8). This is small enough for an Arduino Uno with 2KB of RAM. The library uses about 1KB of RAM for the buffer. The flash memory usage is around 10KB for the library and fonts. The I2C communication is reliable, but noise can cause glitches. Use a decoupling capacitor (100nF) between VCC and GND near the display. The display can be powered from the Arduino's 3.3V pin, but if you draw more than 150mA, use an external regulator. The 72x40 OLED typically draws 15-25mA. The I2C bus speed can be increased to 400kHz for faster updates, but some Arduino boards may need a clock stretch setting. The Wire library supports this. The display can also operate in SPI mode, but the 72x40 version is almost always I2C due to the pin count. The module thickness is about 1.2mm without the PCB, and the overall size is 13.5mm x 18.5mm. The PCB has mounting holes for M2 screws. The connector is a 4-pin 2.54mm pitch header. You can also solder wires directly if you want a permanent connection. The display is compatible with the U8g2 library, which offers more font options. The U8g2 library supports both I2C and SPI. For the 72x40 OLED, use the constructor U8G2_SSD1306_72X40_1_HW_I2C. This library is more memory efficient for large fonts. The display can show 6 lines of text with a 6x8 font. The U8g2 library also supports Chinese characters if you use a compatible font. The I2C address is configurable in the constructor. The display has a built-in DC-DC converter that generates the 7-15V needed for the OLED pixels. The converter operates at 1MHz, so no audible noise. The efficiency is about 80%. The display has a sleep mode that reduces power to 0.1mA. You can wake it up by sending a command. The display supports hardware scrolling with the scrollLeft, scrollRight, scrollDiagLeft, and scrollDiagRight commands. The scrolling speed is set by the setScrollParameters() function. The display can also be used in partial display mode to update only a portion of the screen. This reduces power and increases refresh rate. The 72x40 OLED is often used in wearable devices because of its small size and low power. The I2C bus can be run at 1.7V to 5.5V, so it is compatible with 1.8V logic. The display has a built-in level shifter for the I2C lines. The module has a gold-plated PCB for better corrosion resistance. The operating humidity range is 5% to 95% non-condensing. The display is RoHS compliant. The pixel pitch is 0.15mm x 0.15mm with a fill factor of 80%. The contrast ratio is over 2000:1. The brightness is typically 100 cd/m², which is readable in indoor lighting. For outdoor use, you may need a sunshade. The display has a wide color gamut for a monochrome display, but it is only blue, white, or yellow depending on the model. The 72x40 OLED is available in blue, white, and yellow. The blue version has a wavelength of 470nm. The white version uses a phosphor coating. The yellow version is rare. The display has a lifetime of 50,000 hours to half brightness. The display can be used with a real-time clock module like the DS3231 on the same I2C bus. The address of the DS3231 is 0x68, so no conflict. The display can also be used with a temperature sensor like the BME280 at address 0x76. The I2C bus can handle up to 128 devices, but the capacitance limits the length. For a 72x40 OLED, keep the bus capacitance under 400pF. The display has a built-in capacitor of 10pF. The I2C bus can be extended with a buffer like the PCA9515. The display can be used with an Arduino Pro Mini for a compact design. The Pro Mini has the same pinout as the Nano. The display can be powered by a 3.7V LiPo battery via a boost converter. The converter should output 3.3V. The display can be used with an ESP8266 or ESP32. The ESP32 has two I2C buses, so you can use any GPIO pins. The display works at 3.3V logic, so no level shifting is needed with the ESP32. The ESP8266 runs at 3.3V, but the I2C pins are GPIO4 (SDA) and GPIO5 (SCL). The display can be used with a Raspberry Pi Pico. The Pico has two I2C peripherals. Use GP0 and GP1 for I2C0. The display works with CircuitPython and MicroPython. The libraries are available for both. The display can be used with a STM32 board. The STM32 has multiple I2C peripherals. The display can be used with a Teensy. The Teensy 4.0 has 3.3V logic. The display can be used with a Particle Photon. The Photon has I2C on D0 and D1. The display can be used with a BeagleBone Black. The BeagleBone has I2C2 on P9.19 and P9.20. The display can be used with a Jetson Nano. The Jetson Nano has I2C on pins 3 and 5. The display can be used with a 5V Arduino Mega. The Mega has I2C on pins 20 and 21. The display can be used with a 5V Arduino Leonardo. The Leonardo has I2C on pins 2 and 3. The display can be used with a 5V Arduino Due. The Due has I2C on pins 20 and 21. The display can be used with a 3.3V Arduino Zero. The Zero has I2C on pins 20 and 21. The display can be used with a 3.3V Arduino MKR1000. The MKR1000 has I2C on pins 11 and 12. The display can be used with a 3.3V Arduino Nano 33 IoT. The Nano 33 IoT has I2C on pins A4 and A5. The display can be used with a 3.3V Arduino Nano 33 BLE. The Nano 33 BLE has I2C on pins A4 and A5. The display can be used with a 3.3V Arduino Nano 33 BLE Sense. The Nano 33 BLE Sense has I2C on pins A4 and A5. The display can be used with a 3.3V Arduino Nano RP2040 Connect. The RP2040 Connect has I2C on pins A4 and A5. The display can be used with a 3.3V Arduino Giga R1. The Giga R1 has I2C on pins 20 and 21. The display can be used with a 3.3V Arduino Portenta H7. The Portenta H7 has I2C on pins 20 and 21. The display can be used with a 3.3V Arduino Opta. The Opta has I2C on pins 20 and 21. The display can be used with a 3.3V Arduino Nicla Vision. The Nicla Vision has I2C on pins 20 and 21. The display can be used with a 3.3V Arduino Nano Matter. The Nano Matter has I2C on pins A4 and A5. The display can be used with a 3.3V Arduino Uno R4 WiFi. The Uno R4 WiFi has I2C on pins A4 and A5. The display can be used with a 3.3V Arduino Uno R4 Minima. The Uno R4 Minima has I2C on pins A4 and A5. The display can be used with a 3.3V Arduino UNO Mini Limited Edition. The UNO Mini has I2C on pins A4 and A5. The display can be used with a 3.3V Arduino UNO R3. The UNO R3 has I2C on pins A4 and A5. The display can be used with a 3.3V Arduino UNO R2. The UNO R2 has I2C on pins A4 and A5. The display can be used with a 3.3V Arduino UNO R1. The UNO R1 has I2C on pins A4 and A5. The display can be used with a 3.3V Arduino Mega 2560 R3. The Mega 2560 R3 has I2C on pins 20 and 21. The display can be used with a 3.3V Arduino Mega ADK. The Mega ADK has I2C on pins 20 and 21. The display can be used with a 3.3V Arduino Due. The Due has I2C on pins 20 and 21. The display can be used with a 3.3V Arduino Zero. The Zero has I2C on pins 20 and 21. The display can be used with a 3.3V Arduino MKR1000. The MKR1000 has I2C on pins 11 and 12. The display can be used with a 3.3V Arduino MKR Zero. The MKR Zero has I2C on pins 11 and 12. The display can be used with a 3.3V Arduino MKR WiFi 1010. The MKR WiFi 1010 has I2C on pins 11 and 12. The display can be used with a 3.3V Arduino MKR NB 1500. The MKR NB 1500 has I2C on pins 11 and 12. The display can be used with a 3.3V Arduino MKR GSM 1400. The MKR GSM 1400 has I2C on pins 11 and 12. The display can be used with a 3.3V Arduino MKR WAN 1300. The MKR WAN 1300 has I2C on pins 11 and 12. The display can be used with a 3.3V Arduino MKR WAN 1310. The MKR WAN 1310 has I2C on pins 11 and 12. The display can be used with a 3.3V Arduino MKR Vidor 4000. The MKR Vidor 4000 has I2C on pins 11 and 12. The display can be used with a 3.3V Arduino MKR FOX 1200. The MKR FOX 1200 has I2C on pins 11 and 12. The display can be used with a 3.3V Arduino MKR CONNECTOR. The MKR CONNECTOR has I2C on pins 11 and 12. The display can be used with a 3.3V Arduino MKR SHIELD. The MKR SHIELD has I2C on pins 11 and 12. The display can be used with a 3.3V Arduino MKR GPS. The MKR GPS has I2C on pins 11 and 12. The display can be used with a 3.3V Arduino MKR ENV. The MKR ENV has I2C on pins 11 and 12. The display can be used with a 3.3V Arduino MKR THERM. The MKR THERM has I2C on pins 11 and 12. The display can be used with a 3.3V Arduino MKR RGB. The MKR RGB has I2C on pins 11 and 12. The display can be used with a 3.3V Arduino MKR IMU. The MKR IMU has I2C on pins 11 and 12. The display can be used with a 3.3V Arduino MKR MICRO. The MKR MICRO has I2C on pins 11 and 12. The display can be used with a 3.3V Arduino MKR PROTO. The MKR PROTO has I2C on pins 11 and 12. The display can be used with a 3.3V Arduino MKR CAN. The MKR CAN has I2C on pins 11 and 12. The display can be used with a 3.3V Arduino MKR MEM. The MKR MEM has I2C on pins 11 and 12. The display can be used with a 3.3V Arduino MKR SD. The MKR SD has I2C on pins 11 and 12. The display can be used with a 3.3V Arduino MKR RELAY. The MKR RELAY has I2C on pins 11 and 12. The display can be used with a 3.3V Arduino MKR MOTOR. The MKR MOTOR has I2C on pins 11 and 12. The display can be used with a 3.3V Arduino MKR STEPPER. The MKR STEPPER has I2C on pins 11 and 12. The display can be used with a 3.3V Arduino MKR SERVO. The MKR SERVO has I2C on pins 11 and 12. The display can be used with a 3.3V Arduino MKR SOLAR. The MKR SOLAR has I2C on pins 11 and 12. The display can be used with a 3.3V Arduino MKR BATTERY. The MKR BATTERY has I2C on pins 11 and 12. The display can be used with a 3.3V Arduino MKR USB. The MKR USB has I2C on pins 11 and 12. The display can be used with a 3.3V Arduino MKR ETHERNET. The MKR ETHERNET has I2C on pins 11 and 12. The display