logo elektroda
logo elektroda
X
logo elektroda

ESP32 + OLED WiFi and BT module - commissioning, tests, description

TechEkspert  23 10215 Cool? (+8)
📢 Listen (AI):

TL;DR

  • An ESP32 WiFi module with a 128x64 SSD1306 OLED display uses an I2C bus and exposes ESP32 terminals on the board edges.
  • The display is driven with U8g2 over software I2C, configured as U8G2_SSD1306_128X64_NONAME_F_SW_I2C with SCL on pin 4 and SDA on pin 5.
  • The OLED uses address 0x3C, and the board is selected as Wemos ESP32 / WEMOS LOLIN32 in Arduino.
  • ESP32's extra RAM makes JSON processing easier, so the module can present weather forecasts or other API data from OpenWeatherMap, Wunderground, or Airly.
Generated by the language model.
Soon, on elektroda.pl, a WiFi module will appear with an ESP32 board and an OLED SSD1306 display. The ESP32 capabilities and the integration with Arduino are described here: ESP32 + Arduino . The English-language description of the integration is available here: ESP32 & Arduino on Windows .
The SSD1306 display works on the I2C bus at the address 0x3C. SCL is connected to pin 4, SDA to I / O 5 - ESP32. On the board we find a USB UART converter, a 3.3V stabilizer and ESP32 terminals led to the edges of the board. The monochrome OLED display provides a very good contrast and a pleasant image appearance.


One of the libraries, eg U8g2, can be used to operate the display. After selecting Sketch-> Attach Library-> Manage Libraries, we can add or update U8g2. The configuration of the built-in display in U8g2 is as follows:
U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2 (U8G2_R0, / * clock = * / 4, / * data = * / 5, / * reset = * / U8X8_PIN_NONE);
Set the board as Wemos ESP32: Tools-> WEMOS LOLIN32

ESP32 has more RAM than ESP8266 or ATmega328 and we can more conveniently process data in JSON format provided in the API of many systems. For example, the weather forecasts http://openweathermap.org/api and https://www.wunderground.com/weather/api or air quality data https://airly.eu/pl/api/ are available as JSON.
Much of this data is available online for free, just register an account and receive your personal key.

In the case of openweathermap http://openweathermap.org/price, after creating an account, we receive our key, after checking what ID has our city http://bulk.openweathermap.org/sample/city.list.json.gz (e.g. for Warsaw 7531926 ) we can send inquiries and present the weather forecast on the display.

To conveniently process JSON data, add the ArduinoJson library to Arduino by searching for it in Sketch-> Attach library-> Manage libraries.

We get the weather forecast for the following hours in a fairly simple way:


Below is an example of a simple code that you can adapt both to display the current weather forecast, as well as to virtually any data published by JSON. Instead of descriptions, you can enter a graphical representation of the weather forecast: https://openweathermap.org/weather-conditions

Code: C / C++
Log in, to see the code


What ideas do you have for using a miniature WiFi module with ESP32 and a 128x64 OLED display?


About Author
TechEkspert
TechEkspert wrote 7044 posts with rating 5455 , helped 16 times. Been with us since 2014 year.

Comments

george2002 26 Feb 2018 23:38

Everything was nice, but you could not use all the subtitles in Polish, only in English ... in short, did the author add anything to the code or just compiled it? :) ? what Flash and RAM capacity of this... [Read more]

TechEkspert 27 Feb 2018 05:48

As I wrote, the ESP32 parameters and the integration method can be found in the linked material to the previously shared module. I wrote the code based on the available examples, there is nothing innovative... [Read more]

atek000 27 Feb 2018 10:43

I can see a small minus of this module, especially at the beginning as we want to play with everything and check everything. The display is on one side and the buttons are on the opposite. If you stick... [Read more]

piterek-23 27 Feb 2018 13:45

Buddy, you can plug this module into the breadboard so that the buttons and the USB socket will be behind the plate ;) [Read more]

atek000 27 Feb 2018 14:08

Sure I can, I know it and everyone who plays with such modules. My point is that everything on the same side would be more convenient though. If someone is interested and chooses from many available solutions,... [Read more]

logos 27 Feb 2018 15:52

I also have this module purchased on Aliexpress and I am adding two links http://www.lilygo.cn/ https://github.com/LilyGO?tab=repositories [Read more]

futek2 01 Mar 2018 04:39

Hello. I use the LOLIN ESP32 OLED module as MINI PV LOGER to my ES5000 inverter. Communication is via WIFI within 50 meters. Just a little computer. More details and program code on the link below. ... [Read more]

TechEkspert 03 Mar 2018 09:22

A very nice use of the module as a remote display, WiFi is used or would ESP-Now make sense here? [Read more]

futek2 03 Mar 2018 09:47

Hello. The ESP8266 is installed in the ES5000 inverter and it has been in operation for almost a year. Power supplied by means of a 12VDC / 3.3VDC isolation converter. Photo attached. On ESP8266 it... [Read more]

Bullseye 03 Mar 2018 10:47

I have a quick question, namely what are the differences between: 1. Wemos LOLIN32 lite ESP32 v1.0 (MicroPython uploaded by default) 2. NodeMCU ESP-32S v1.1 According to the description and appearance,... [Read more]

korrus666 09 Mar 2018 22:17

There is a problem with the link: https://git.oschina.net/dfrobot/FireBeetle-ESP32/raw/master/package_esp32_index.json Namely, the json file that is being downloaded has an incorrect link to the Git... [Read more]

rafcio_21 03 Apr 2018 12:41

Hello, I bought this module from gadgets and I have a question whether this OLED is colored or only white inscriptions on a black background. [Read more]

futek2 03 Apr 2018 13:43

Hello. The display in the ESP32 module with OLED is black and white, as in the earlier descriptions on the attached photos. https://www.elektroda.pl/rtvforum/viewtopic.php?p=17071588#17071588 Colors... [Read more]

futek2 12 Sep 2018 11:11

Hello, interested in the topic. For a few days I have been struggling with the problem that I want to transfer the code from ARDUINO UNO to LOLIN ESP32 OLED. The program is practically compiling but it... [Read more]

TechEkspert 12 Sep 2018 22:52

Or maybe try something more high-level? https://techtutorialsx.com/2017/10/07/esp32-arduino-timer-interrupts/ [Read more]

futek2 13 Sep 2018 07:37

I warmly welcome. Thanks TechEkspert for info. I am familiar with it, but it does not work in practice. I want to run the TDR meter according to this concept. The electronics are complete. https://forum.arduino.cc/index.php?topic=183770.msg1365676#msg1365676 ... [Read more]

TechEkspert 16 Sep 2018 19:16

An interesting project, in this application, going down to the register level may pay off. It is worth showing up in DIY later. [Read more]

futek2 16 Sep 2018 20:44

Hello. I am slowly finishing the code, but without any register operations. But when I checked what impulses appear with the help of the LOGIC ANALYZER, it occurred to me that this device would also... [Read more]

tos18 08 Nov 2018 04:39

I would like to propose another way to initialize the oled display. In my case, the change made operations on oled take place at least twice as fast. So to the point is: U8G2_SSD1306_128X64_NONAME_F_SW_I2C... [Read more]

FAQ

TL;DR: ESP32 boards run at up to 240 MHz and pack 520 kB SRAM; “nothing innovative there” [Elektroda, TechEkspert, post #17066879] Swap the SSD1306 driver to hardware-I2C for ~2× faster screen writes [Elektroda, tos18, post #17545454] Why it matters: Quick tweaks turn a cheap Wi-Fi/Bluetooth module into a snappy, sensor-ready IoT dashboard.

Quick Facts

• CPU clock: 160–240 MHz dual-core Tensilica LX6 [Espressif Datasheet, 2020] • RAM/Flash: 520 kB SRAM + typically 4 MB QSPI flash [Espressif Datasheet, 2020] • OLED bus: I²C, address 0x3C; SCL → GPIO4, SDA → GPIO5 [Elektroda, TechEkspert, post #17065928] • Hardware-I2C init cuts draw time from 6 ms to ~3 ms [Elektroda, tos18, post #17545454] • Wi-Fi reconnect timeout: module auto-restarts after 60 s [Elektroda, TechEkspert, post #17065928]

What are the core specifications of the LOLIN ESP32 OLED module?

The board uses an Espressif ESP32 dual-core LX6 (160–240 MHz), 520 kB SRAM, usually 4 MB flash, integrated 2.4 GHz Wi-Fi 802.11 b/g/n, Bluetooth v4.2 BR/EDR + BLE, USB-to-UART bridge, 3.3 V LDO and a 0.96-inch 128 × 64 monochrome SSD1306 OLED wired to GPIO4/5 [Espressif Datasheet, 2020][Elektroda, TechEkspert, post #17065928]

How do I wire the onboard SSD1306 display?

No wiring is needed—on the LOLIN32-OLED the display is already connected through I²C: SCL to GPIO4, SDA to GPIO5, address 0x3C [Elektroda, TechEkspert, post #17065928] Select those pins in your display driver or call Wire.begin(5,4).

Which Arduino library works best with the SSD1306?

U8g2 supports the panel and offers many fonts. Install via Sketch → Include Library → Manage Libraries and choose "U8g2" [Elektroda, TechEkspert, post #17065928]

Why switch from software to hardware I²C and how?

Software I²C redraws a full frame byte-by-byte. Changing to hardware I²C halves the draw time (≈6 ms → ≈3 ms) [Elektroda, tos18, post #17545454] Use:
  1. Wire.begin(5,4);
  2. U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, SCL, SDA, U8X8_PIN_NONE);
  3. u8g2.begin();

Is the OLED display color or monochrome?

It is monochrome (white pixels on black) but you can invert colors in software at a small current penalty [Elektroda, futek2, post #17146134]

How can I show OpenWeatherMap data on the OLED?

  1. Get a free API key and your city ID.
  2. Add ArduinoJson and U8g2 libraries.
  3. Use the sample sketch posted by TechEkspert; it connects, parses JSON, and rotates through eight forecast slots [Elektroda, TechEkspert, post #17065928] The code fits in under 40 kB flash and uses ≈20 kB heap with 16-entry forecasts.

Breadboard access to the side buttons is awkward—any workaround?

Insert the module so the OLED faces forward and the USB port plus buttons overhang the breadboard edge. That leaves the switches reachable, as piterek-23 explains [Elektroda, piterek-23, post #17067535]

What differs between Wemos LOLIN32 Lite and NodeMCU ESP-32S?

They share the same ESP32 core. LOLIN32 Lite ships with MicroPython, has fewer GPIO exposed, and uses a CP2102 USB bridge. NodeMCU ESP-32S exposes more pins and ships with factory test firmware. For most Arduino or MicroPython sketches the experience is identical [Elektroda, Bullseye, post #17076371]

How do I read a GPIO in under 1 µs?

Access the register block directly: define REG_READ(0x3FF4403C) & BIT(25) for GPIO25, then poll. Direct read executes in ~0.6 µs; using GPIO32–39 can cut the response to ≈0.083 µs but introduces a 1.875 µs interrupt latency [Elektroda, futek2, post #17558520]

Can ESP32 timers replace AVR Timer1 code that uses TCCR1A/B?

Yes. Use the Arduino-ESP32 timer API: timerBegin(), timerAttachInterrupt(), timerAlarmWrite() [TechTutorialsX, 2017]. You avoid fragile register values and still achieve sub-microsecond precision [Elektroda, TechEkspert, post #17437699]

What happens if Wi-Fi fails to connect?

The demo sketch waits 60 seconds, then calls ESP.restart(); the OLED shows "restart" before rebooting [Elektroda, TechEkspert, post #17065928] This safeguards against dead loops but can erase volatile data.

How was the module used as a MINI PV logger?

Futek2 linked ESP8266 on an inverter to a LOLIN ESP32 OLED over Wi-Fi and pushed readings to a cloud every 3 min. The ESP32 shows live power, runs from a 12 V→3.3 V isolated converter, and needs no PC [Elektroda, futek2, post #17071588] “Just a little computer.”

Can ESP-Now replace Wi-Fi for remote display?

Yes; ESP-Now is a connection-less 2.4 GHz protocol that frees the main Wi-Fi channel and cuts power by up to 30 % in similar telemetry apps [Espressif ESP-Now Guide, 2019]. TechEkspert suggested testing it for the PV remote screen [Elektroda, TechEkspert, post #17076245]
Generated by the language model.
%}