ESP8266 / Hiletgo 1.3" 128x64 OLED / U8g2 display library : Hello World

Using PlatformIO CLI on Linux (Ubuntu 18.04)

src/main.cpp

/*
Working with the 1.3" OLED Display 128x64 via I2C (software)
on a NodeMCUv2 ESP8266 board

HiLetgo
SSH1106

Arduino AVR PIC STM32

*/

#include "Arduino.h"
#include "U8g2lib.h"
#include <stdio.h>


U8G2_SH1106_128X64_NONAME_F_SW_I2C display(U8G2_R0,/*clk*/ 4, /*data*/ 5);

void setup() {

  Serial.begin(74880);
  display.begin();
  display.clearBuffer();

  display.setFont(u8g2_font_profont12_tf);
  display.drawStr(0,12,"Hello World");

  display.sendBuffer();
}

void loop() {
  //This is for verifying the code is running (viewed in the PIO monitor)
  Serial.println("Running...");
  delay(1000);
}
main.cpp

Setup

Using Linux (Ubuntu 18.04) + PlatformIO CLI

platformio.ini

[env:latest_stable]
framework = arduino
platform = espressif8266
board = nodemcuv2

lib_deps = olikraus/U8g2@^2.32.7

monitor_port = /dev/ttyUSB1
monitor_speed = 74880 ;Xtal on ESP8266 board (ESP-12E) is 26Mhz so 2880 * 26 = 74880

upload_speed = 921600 ; increased upload time from ~17 to ~3 secs.
platformio.ini

For those interested or just starting out:

$ pio run --target upload
Processing latest_stable (framework: arduino; platform: espressif8266; board: nodemcuv2) ------------------------------------------------------------------------------------------ Verbose mode can be enabled via `-v, --verbose` option CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/nodemcuv2.html PLATFORM: Espressif 8266 (3.2.0) > NodeMCU 1.0 (ESP-12E Module) HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash PACKAGES: - framework-arduinoespressif8266 3.30002.0 (3.0.2) - tool-esptool 1.413.0 (4.13) - tool-esptoolpy 1.30000.201119 (3.0.0) - tool-mklittlefs 1.203.210628 (2.3) - tool-mkspiffs 1.200.0 (2.0) - toolchain-xtensa 2.100300.210717 (10.3.0) LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf LDF Modes: Finder ~ chain, Compatibility ~ soft Found 36 compatible libraries Scanning dependencies... Dependency Graph |-- 2.32.7 | |-- 1.0 | |-- 1.0 Building in release mode Compiling .pio/build/latest_stable/src/main.cpp.o Linking .pio/build/latest_stable/firmware.elf Retrieving maximum program size .pio/build/latest_stable/firmware.elf Checking size .pio/build/latest_stable/firmware.elf Advanced Memory Usage is available via "PlatformIO Home > Project Inspect" RAM: [==== ] 36.5% (used 29884 bytes from 81920 bytes) Flash: [=== ] 26.3% (used 275109 bytes from 1044464 bytes) Building .pio/build/latest_stable/firmware.bin Creating BIN file ".pio/build/latest_stable/firmware.bin" using "/home/scotty/.platformio/packages/framework-arduinoespressif8266/bootloaders/eboot/eboot.elf" and ".pio/build/latest_stable/firmware.elf" Configuring upload protocol... AVAILABLE: espota, esptool CURRENT: upload_protocol = esptool Looking for upload port... Auto-detected: /dev/ttyUSB1 Uploading .pio/build/latest_stable/firmware.bin esptool.py v3.0 Serial port /dev/ttyUSB1 Connecting.... Chip is ESP8266EX Features: WiFi Crystal is 26MHz MAC: xxxxxxxxxxxxx Uploading stub... Running stub... Stub running... Changing baud rate to 921600 Changed. Configuring flash size... Compressed 279264 bytes to 204757... Writing at 0x00000000... (7 %) Writing at 0x00004000... (15 %) Writing at 0x00008000... (23 %) Writing at 0x0000c000... (30 %) Writing at 0x00010000... (38 %) Writing at 0x00014000... (46 %) Writing at 0x00018000... (53 %) Writing at 0x0001c000... (61 %) Writing at 0x00020000... (69 %) Writing at 0x00024000... (76 %) Writing at 0x00028000... (84 %) Writing at 0x0002c000... (92 %) Writing at 0x00030000... (100 %) Wrote 279264 bytes (204757 compressed) at 0x00000000 in 2.7 seconds (effective 838.6 kbit/s)... Hash of data verified. Leaving... Hard resetting via RTS pin... ============================== [SUCCESS] Took 15.44 seconds ============================== $ _