ESP32 With Integrated OLED (WEMOS/Lolin) - Getting Started Arduino Style

Introduction: ESP32 With Integrated OLED (WEMOS/Lolin) - Getting Started Arduino Style

If you're like me, you jump at the chance to get your hands on the latest and greatest ESP8266/etc...and put it through its paces. The ESP32 is no different but I have found that there isn't too much out there yet with regards to documentation. The first 2 steps should pertain to most ESP32 flavors and not just the one depicted with the OLED. Hopefully these 'couple-of-steps' will get you started. Good Luck....Have Fun...Let me know if it worked for you. A few assumptions are that you know how to navigate the Arduino IDE and work with their libraries.

UPDATE: 05Jan18 - Be sure to check out some updated ESP32 videos at the end of this Instructable. Internet Clock and Bluetooth BLE in action. Look in the YouTube notes for links to sketches.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: What's Needed

ESP32 SOC

USB cable

Arduino IDE

Step 2: Assuming Arduino IDE Is Already Installed

By default, the ESP32 does not show yet with the standard boards manager entries pointing to http://arduino.esp8266.com/stable/package_esp8266c...

Because of this we need to manually add them for the time being.

Follow ALL steps at the following site to prepare your Arduino IDE for your new ESP32 board.

https://github.com/espressif/arduino-esp32/blob/master/docs/arduino-ide/windows.md

If you do have the integrated OLED, and would like to try and get it running, proceed to the next step.

Step 3: Get the OLED Working on Arduino

Now that you've probably loaded an Arduino sketch on your ESP32, the 'pretty' pictures that were running on it when you first plugged it in are probably gone.

This particular ESP32 uses the SSD1306 libraries to communicate with the OLED display. I have had luck getting started by loading the following Arduino library and testing one of the SSD1306's included Example sketches. If the sketch fails to compile with errors, make sure you change the address it failed on to (0x3c, 5,4).

This ESP’s dedicated I2C pins are on GPIO 5 and 4 for data and clock respectively.

The attached ESP32_Wemos_I2C_Scanner sketch will confirm if your pins are addressed correctly. Load it on your ESP32 and check out serial monitor.

https://github.com/squix78/esp8266-oled-ssd1306

Step 4: Functional OLED With Arduino LDR Analog Input

****UPDATE 28Dec17 Check out video of ESP32 with working Internet/NTP clock. Code download URL's available on YouTube below video.

I decided to just keep rolling with this and managed to get the OLED working with 'real' data and not just the examples. Analog LDR feed. I've attached the Arduino sketch to this to help. Take it for a spin and let me know how you make out! If you need a 'brush-up' on the workings of Arduino and Analog, head over to https://programmingelectronics.com/tutorial-21-ana...

I got started on my Arduino adventure with these guys...the course is definitely worthwhile.

2 People Made This Project!

Recommendations

  • Tiny Speed Challenge

    Tiny Speed Challenge
  • Clocks Contest

    Clocks Contest
  • PCB Design Challenge

    PCB Design Challenge

47 Discussions

0
vpv96
vpv96

7 months ago

Thanks for your time!!!!

0
tkteun
tkteun

Tip 9 months ago on Step 4

The GND pin on the left is marked wrong, it actually says SND and it fries the module if used wrong...

0
tkosa
tkosa

Question 10 months ago

Hi Johnnyfrx, I just bought my first Wemos ESP32 w/OLED... I was very excited to find your instructables, plan to go through all to learn ESP32 especially wifi and BT capabilities...
So I got the oled display work with Adafruit_SSD1306 library. BTW: from their ssd1306_128x64I2C sketch they left off the Wire.begin(5,4); after Serial.begin(9600);
Without ' Wire.begin()' it did not display anything... hm.
I see in your sketch you use a different library...
#include "SSD1306.h" // alias for `#include "SSD1306Wire.h"'
Where do I get this version of the SSD1306 library?
Please kindly advise how to proceed. Thanks

0
tkosa
tkosa

Reply 10 months ago

Johnnyfrx, thanks for the link for the library. I had to comment out thow include files: //#include <SH1106Brzo.h>
//#include <SSD1306Brzo.h>, then it compiled and worked fine. Thanks. Now on to the next...:-)

0
vganapetyan
vganapetyan

2 years ago

Great tutorial, all worked fine. Thank you!

Did you try connecting other I2C devices to pins 4 and 5? I tried to connect BME280. and as soon as I connect the I2C pins the OLED stops working and the I2C scanner cannot find any devices on that pins (when I connect the same board to other pins, I2C scanner finds the devices).

0
johnnyfrx
johnnyfrx

Reply 2 years ago

Good to hear it helped. I may tinker this weekend and see what I can break. Will let you know if I am successful in adding additional I2C devices.

0
RobertWinkler
RobertWinkler

Reply 1 year ago

Hi, I have the same issue that the BME280 is not recognized on the pins 4, 5. The I2C scan does not find connected devices; the BME280 works with an Arduino. Did you succeed to connect a I2C sensor to the ESP32?

0
vganapetyan
vganapetyan

Reply 2 years ago

Hi! Thanks for your response! It seems my BME280 boards were all damaged. I couldn't make them work on other pins either although I2C scanner seems to be finding all the I2C addresses. Seems to be manufacturer defect. I have ordered more boards from another seller, will try them out when they arrive and will write here.

0
RobertWinkler
RobertWinkler

1 year ago

Thanks a lot, you instruction made me going with this nice board! Do you know if there is any usable Fritzing Part already available? This would make protyping even faster.

0
rlbruderick
rlbruderick

1 year ago on Step 3

Very inspiration Instructable.

I picked up a few of these Wemos (knock-off) boards. I've gotten the WiFi to work with the OLED, and I've gotten the BLE to work. But when I added basic WiFi functionality to my BLE sketch I ran out of memory. It there something set up wrong in my compiler?

Here's the fault message:

Arduino: 1.8.5 (Windows 10), Board: "WEMOS LOLIN32, 80MHz, Default, 921600"

Archiving built core (caching) in: C:\Users\Rick\AppData\Local\Temp\arduino_cache_201289\core\core_espressif_esp32_lolin32_FlashFreq_80,PartitionScheme_default,UploadSpeed_921600_66cb22ea348dffbd1935f23e326d859a.a

Sketch uses 1559370 bytes (118%) of program storage space. Maximum is 1310720 bytes.

Global variables use 69900 bytes (23%) of dynamic memory, leaving 225012 bytes for local variables. Maximum is 294912 bytes.

0
alleebell
alleebell

Tip 2 years ago

I bought one of these modules from a Chinese website. It has absolutely no instructions. It took me a while to figure out the device address and the I2C port is address. If you want to find the address of the OLED, the wire.begin should be wire.begin(5.4) instead of wire.begin().

0
arick
arick

2 years ago

I can upload the code to the board,

but only got this on my serial :

ets Jun 8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:812
load:0x40078000,len:0
load:0x40078000,len:11404
entry 0x40078a28

nothing on my OLED display

Here's the init code :

// Initialize the OLED display using Wire library
SSD1306 display(0x3c, D3, D5);
// SH1106 display(0x3c, D3, D5);


#define DEMO_DURATION 3000
typedef void (*Demo)(void);

int demoMode = 0;
int counter = 1;

void setup() {
Serial.begin(115200);
Serial.println();
Serial.println();


// Initialising the UI will init the display too.
display.init();

display.flipScreenVertically();
display.setFont(ArialMT_Plain_10);

0
Hellmut1956
Hellmut1956

Question 2 years ago on Step 2

I am following the instructions to add support for my ESP32 board at the page you list and, due to ignorance I do not know how to do this step:

open a Git Bash session pointing to ARDUINO_SKETCHBOOK_DIR and execute git submodule update --init --recursive

I did change the actual directory of the GIT Bash to the directory used as "ARDUINO_SKETCHBOOK_DIR" and the did enter the instruction. The error message made sense to me but I do not know how to do it right:
"No such file or directory". This directoy does not have any git content.

What do I have to do to be able to execute the instruction?

0
johnnyfrx
johnnyfrx

Answer 2 years ago

Hey Hellmut,
The folder mentioned "ARDUINO_SKETCHBOOK_DIR" in the example is just example. You need to add your specific folder structure for the target directory like they show in the screenshot on that same page. Please let me know if this helps or if you've already gotten it to work.
Have a good day!
Thanx,
JohnnyFRX

0
Hellmut1956
Hellmut1956

Answer 2 years ago

Thanks for responding. It is hard to learn how to present a question, sorry. When I tried I did replace "ARDUINO...DIR" with the correct path to the folder where the sketches are stored. Effectively I moved the working directory to my "ARDUINO...DIR" My problem was in executing the GIT Bash session:

git submodule update --init --recursive

I got the error message :

"No such file or directory"

So I do not know how to successfully do this step!

0
johnnyfrx
johnnyfrx

Answer 2 years ago

Try changing directories all the way into the esp32 subdirectory. See attached screenshot from my setup.

ScreenHunter 44.jpg
0
JochenH2
JochenH2

2 years ago

Hi Johnny, thanks for elaborating and posting the info. So, I got my board up and running with WiFi and OLED examples.

Only thing that failed was your scan. Any idea ?

Thanks - Jochen.

scan-err.jpg
0
johnnyfrx
johnnyfrx

Reply 2 years ago

Hi JochenH2,

Did the scan cause that reset? Your serial monitor should look something like my attached screenshot.

Are your I2C pins the same? Wire.begin(5,4);

ScreenHunter 25.jpg