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.

Step 1: What's Needed

Picture of What's Needed

ESP32 SOC

USB cable

Arduino IDE

Step 2: Assuming Arduino IDE Is Already Installed

Picture of 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

Picture of 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

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.

Comments

JohnL29 (author)2017-11-06

If you want to try something possibly even easier than the Arduino IDE, try the ESP32 for Lua web IDE to run your OLED from Lua on the ESP32. http://chilipeppr.com/esp32 is the site. I found it pretty easy once I had an XBM image converter widget built in ChiliPeppr workspace as seen in the attached images.

vganapetyan (author)2017-10-03

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).

johnnyfrx (author)vganapetyan2017-10-10

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.

vganapetyan (author)johnnyfrx2017-10-10

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.

kasras4 (author)2017-08-28

Thank you mister for this tutorial, it helped me a lot !.

Here is what i have so far (based on a WEMOS Lolin 32 board ) :

a Wifi scanner and once connected to a given network

a simple http server on it that recieves some commands thanks to the URLs.

The commands are needed to control a motor.

so here is my question ( i am a developper but pretty new in the whole electonic world ;-) )

IS it possible to control a motor driver ( i have a BTS7960 43A link : https://www.instructables.com/id/Motor-Driver-BTS7960-43A/) with that wemos lolin board ?

or do i need an arduino for example ?

thanks for your help!

have a nice day

johnnyfrx (author)kasras42017-08-28

Hi Kasras4,

I think the problem you could run into is that the voltage output of the ESP's GPIO pins is 3.6v. If you are working with a motor driver like the BTS7960 and using PWM, you 'may' need a reliable 5v output like the Uno/Mega have. All of the GPIO's on the ESP32 support PWM and the correct frequency so you should be OK in those respects.

kasras4 (author)johnnyfrx2017-08-29

Thank you.

Could you tell me where did you find the fact that this ESP’s dedicated I2C pins are on GPIO 5 and 4 for data and clock respectively ?

is it mentioned in the datasheet of the esp32 ? if yes which page please ? ( i am kind of lost with all the tables )

johnnyfrx (author)kasras42017-08-29

No datasheet...couldn't find decent docs for this particular board anywhere. I tracked down a comment buried in a vendors comment. Also, more info is at the link below at this time...wasn't there when I started working with this board. Hope it helps as a starting point at the least. https://www.esp32.com/viewtopic.php?t=2058

FrancoC14 (author)2017-07-14

what is the value for D3 and D5?

i have this compiler error

'D3' was not declared in this scope

SSD1306 display(0x3c, D3, D5);

johnnyfrx (author)FrancoC142017-07-14

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

I've attached ESP32_Wemos_I2C_Scanner sketch to step 3 which should confirm if your pins are addressed correctly. Load it on your ESP32 and check out serial monitor.

pescelupo (author)johnnyfrx2017-07-18

scan return:

I2C device found at address 0x3C !

if i set:

SSD1306 display(0x3c, 5, 4);

is blocked on "Hard resetting....."

johnnyfrx (author)pescelupo2017-07-18

Also...can you run any other simple Arduino sketches on it successfully? WiFi scanner or similar...to output to the serial monitor so you know that it is processing.

johnnyfrx (author)pescelupo2017-07-18

When you first powered it up 'out-of-the-box' without loading anything new to it, did the screen demo run?

johnnyfrx (author)pescelupo2017-07-18

When you first powered it up 'out-of-the-box' without loading anything new to it, did the screen demo run?

FrancoC14 (author)johnnyfrx2017-07-18

yes, demo pre-loaded worked fine

pescelupo (author)pescelupo2017-07-18

SimpleDemo example oled screen is empty

johnnyfrx (author)FrancoC142017-07-14

Try changing that line in your source to:

SSD1306 display(0x3c, 5, 4);

MübinI (author)2017-06-28

I have this board. I compiled the program but I can not upload it to board. There are 2 buttons EN and BOOT. Should I press one of them? Which one? I tried all combination of pressing buttons but nothing helped. I always get these errors;

warning: espcomm_sync failed

error: espcomm_open failed

error: espcomm_upload_mem failed

error: espcomm_upload_mem failed.

USB-Serial is working, I mean If I connect the board to usb, it sends some information on console. I close the console and try to upload the code, I receive errors.

johnnyfrx (author)MübinI2017-06-28

You followed the steps to add the board to your boards manager? You shouldn't need to press any buttons when programming this ESP via USB. Are your Serial speeds matching, etc...? Have any of the other example sketches worked?

MübinI (author)johnnyfrx2017-07-06

Hi,

I found my fault. I was giving wrong I2C pins for display. I gave correct addresses (5, 4) and it worked. Thanks.

johnnyfrx (author)MübinI2017-07-06

Glad you figured that out! It is a fun little Gizmo!

bfpa40 (author)MübinI2017-07-05

While you have the serial monitor window open Press and hold down the EN button for 3-4 seconds then release and you will see the board respond in the windod and from that point you are ready to upload sketched to the board.

scoopydo (author)2017-06-19

I just got mine from Bangood. Very timely, thank you.

johnnyfrx (author)scoopydo2017-06-21

Let me know how you make out with it.

carlos66ba (author)2017-06-16

Can you provide the link to where this device can be bought? Thanks!

johnnyfrx (author)carlos66ba2017-06-16

Hi There,

I got mine from eBay at http://r.ebay.com/UaGwCN

Have a good weekend!

carlos66ba (author)johnnyfrx2017-06-16

Thank you!!

Swansong (author)2017-06-16

Thanks for sharing :)

johnnyfrx (author)Swansong2017-06-16

Thanx for looking!

About This Instructable

17,759views

23favorites

License:

More by johnnyfrx:ESP8266/ESP-01 Arduino Powered Leak DetectorESP8266/Arduino SmartThings Relay for Christmas LightsESP8266/Arduino MQTT Memo Minder W/LCD (AKA Teenage Gamer Attention Getter!)
Add instructable to: