ESP32 NTP OLED clock

As a first project with my new ESP32 module with OLED display I chose to build OLED clock. I thought I’ll just find some existing code, upload it and it’s done. There are a few such projects for ESP8266 in NodeMCU. So I started with NodeMCU upload.

First I tried NodeMCU binary from https://nodemcu-build.com/ but it was throwing strange binary streams to serial and didn’t respond to any keys. Then I found out it is probably only for ESP8266 so I decided to build esp32-dev version from sources like this:

Now since I want to use NTP for getting exact time and don’t want to write own client, let’s see if there is a library available:

Let’s open Libraries

Now search for NTP

OK, let’s try one

Install it. It contains example code so I can copypaste it into main.cpp. So now I have time source. Next I need display driver. Googling “ESP OLED” gives me this library:https://github.com/squix78/esp8266-oled-ssd1306What attracted my attention was, that those screenshots showed exactly the same pictures my device was showing with factory firmware (which I backed up just for case). So I knew it might work. So I installed it as the README says by running

platformio lib install 562

in PlatformIO console.

Then I connected my module via USB and /dev/ttyUSB0 appeared. Next I put together some example code and hit Upload.

Unfortunately, nothing was shown, nor on serial port, nor on display. But one thing I was not sure about was display address defined by:

Thanks – the problem was with my particular WiFi network, it works with my mobile hotspot.

Couple of observations – my microcontroller gets extremely hot; my thoughts immediately to remedy this are to decrease the update frequency of the clock. Can you think of something else that might cause this.

Another general observation is the display is nice and bright but at night time it’s probably too bright – is there a way to decrease the brightness, and moreso is there a way to decrease the brightness according to the time of day?

OK so I added “void setContrast(char contrast);” and “display.setContrast(0);” to the “void display_text” section. It does seem to have an effect on screen brightness somewhat, but less than I expected.