OLED Clock Using the ESP M3

by sadtzy in Circuits > Arduino

2128 Views, 30 Favorites, 0 Comments

OLED Clock Using the ESP M3

image_2023-09-23_144155850.png

ESP8285 is a coin sized SoC(System on Chip) IoT(Internet of Things) capable board with very less power consumption(Deep Sleep option compatible).

In this instructable will be demonstrating how to make a clock that gets time from an NTP server and displays it on an OLED Display.

Supplies

  1. ESP-M3
  2. OLED Display 128x64
  3. Breadboard
  4. Perfboard (Optional)
  5. Jumper Wires
  6. NodeMCU / ESP8266 programmer

The ESP-M3

image_2023-09-23_142922328.png

ESP8285 = ESP8266 + 1M Flash, And the original ESP8266 source code program can be used on it. The chip integrates the enhanced version of the Tensilica's L106 Diamond 32-bit core processor with on-chip SRAM in a smaller package. ESP8285 has a complete Wi-Fi network function, both can be used independently, can also be used as a slave from other host MCU running. When the ESP8285 hosting application, can be started directly from the external Flash. Built-in cache memory facilitates system performance and optimizes storage systems. In addition, ESP8285 only through the SPI / SDIO interface or I2C / UART port can be used as a Wi-Fi adapter, applied to any microcontroller-based design.

Chip Manufacturer link: https://www.espressif.com/en/products/hardware/esp8266ex/overview

Features

  1. the volume is ultra-small;
  2. serial to WiFi wireless transmission;
  3. 4) long-range ultra-low power consumption; 5)
  4. high temperature, up to 125 ℃ 6)
  5. fully compatible with ESP8266, the source can be used to transplant.


SOC characteristics

Built-in Tensilica L106 ultra-low power 32-bit microprocessor,

clocked at 80MHz and 160MHz support RTOS Built-in TCP / IP protocol stack Built-in 1-channel 10-bit high-precision ADC Peripheral Interface HSPI,

UART, I2C, I2S, IR Remote Control, PWM, GPIO.

The deep sleep hold current is 10uA and the shutdown current is less than 5uA

Wake up within 2 ms, connect and pass the packet

Standby power consumption less than 1.0mW (DTIM3) Built-in 1M bytes of SPI Flash


Wi-Fi features

Supports 802.11 b / g / n / (WiFi 4)

Support Station, SoftAP,

SoftAP + STA mode Support for Wi-Fi Direct (P2P)

Hardware acceleration P2P discovery, P2P GO mode / GC mode and

P2P power management WPA / PA2 PSK and WPS 802.11 i

security features: pre-authentication and TSN Hold 802.11n (2.4 GHz) 802.1h / RFC1042

frame encapsulation Seamless roaming support

Support AT remote upgrade and cloud OTA upgrade

Support for Smart Config features (including Android and iOS devices)

Module peripherals 1xUART 1xADC 1xEn 1x wakeup pin 1xHSPI 1xI2C 1xI2S 8xGPIOs

Programming the ESP-M3

image_2023-09-23_145736229.png
During Flash mode/uploading code: Then ESP8285 GPIO0 and Ground have to be connected to each otherwise the program wont get uploaded. 


I am using my NodeMCU to program the ESP-M3. Any existing Arduino or ESP board with an onboard USB to serial chip will work.

Connect the reset pin of the programmer to ground and use it's TX And RX pins to program the ESP-M3.


Refer image to connect your ESP in flash mode.

  1. GPIO 0 and GND of ESP-M3 has to be connected before your programmer is powered up. This tells the board to in flash mode or upload code to chip.
  2. Select Tools -> Board -> Generic 8285 Board
  3. Upload any ESP8266 compatible code. Once you see "Upload Complete" status in the Arduino IDE you can proceed to next step. Else make sure connection are made as per above steps.
  4. Disconnect GPIO 0 and Gnd.

Now re power board(I use 2 x 1.5v AA regular battery) connect LED or any output to pin the code uploaded needs. If you don't have any LED GPIO2 points to onboard blue led. You can upload Blink.ino to test it.


Downloads

Connecting the OLED Display

OLED Displays can have two communication modes SPI or I2C. My display uses SPI to communicate.

I2c uses 2 wire communication whereas SPI uses 4 or 5 wires to communicate with the display.


I2C Displays have 4 pins and SPI Displays have 7 pins.


If your display is I2C:

  • Connect SDA to GPIO 4
  • Connect SCL to GPIO 14


If your display is SPI:

  • Connect SCL to GPIO 14
  • Connect SDA to GPIO 4
  • Connect CS to GND
  • Connect DC to TX
  • Connect Reset to RX


Remove the TX and RX connections while uploading code


Upload the below code to check whether your display is working

Downloads

Connecting to WiFi and Getting the Time

Now that the display is working, let us move to the wifi part of the code. The ESP-M3 connects to the internet and gets time from a NTP time server and displays it on the OLED display.


Lines 6 and 7 are used to define which WiFi network to connect to


6 const char* ssid = "WIFINAME";
7 const char* password = "PASSWORD";


Line 10 defines the time server to connect to and get the time from. The number 19800 is the offset from GMT time depending on your time zone.


For GMT - 4 (America), The offset must be -4 * 60 * 60 = -14400

My time zone is GMT +5:30 so 5.5 * 60 * 60 = 19800

NTPClient timeClient(ntpUDP, "europe.pool.ntp.org", 19800);


After performing all required modifications we can now upload our code and test it.


Downloads

Breadboard

1WhatsApp Image 2023-09-23 at 14.10.07.jpg

Once the code is uploaded, the time is displayed on the screen.

Proto PCB

WhatsApp Image 2023-09-23 at 14.10.07.jpg
WhatsApp Image 2023-09-23 at 14.10.07.jpg1.jpg

To make this project even more professional, we can solder the screen and esp-m3 on a prototyping board and place it anywhere.

Finished

VID 20230923164929~2

Screen flickering isn't visible to our eyes