Default setup and screen display code for Ideaspark ESP8266-096OLED

Hey, I bought one of these off of Temu a while back and started playing with it, but the online code tutorials didn't work. The ESP8266 would connect to the web but I couldn't make the screen display anything.

After a lot of trial and error I was able to track down the listing and find the missing pieces, which were these steps:

1: Install CH340 driver
2: Install ESP8266 Board
3: Select board as NodeMcu 1.0(ESP-12E Module)
4: Install the U8g2 library by oliver
5: Set the board properties:
Upload Speed 921600
Flash Size: 4MB (FS-2MB OTA: ~1019kb)
(The other defaults were fine)

And then here is a sample code that will re-create the default screen display when flashed from the Arduino IDE:

<Arduino.h>
<Wire.h>
<U8g2lib.h>

U8G2_SSD1306_128X64_NONAME_F_SW_I2C
//u8g2(U8G2_R0,/'clock='/14,/'data='/12,U8X8_PIN_NONE); This is what was in the listing, but it didn't work. The next line corrects that.
u8g2(U8G2_R0,14,12,U8X8_PIN_NONE);

void setup(void) {
u8g2.begin();
}
void loop(void) {
u8g2.clearBuffer();
u8g2.setFont(u8g2_font_6x13_tf); //This sets the font
u8g2.drawStr(0,10,"Hello,ideaspark"); // (X pos, y pos, content)
u8g2.drawStr(0,26,"ESP8266");
u8g2.drawStr(0,36,"ESP8266 0.96");
u8g2.drawStr(0,46,"ESP8266 0.96 inch");
u8g2.drawStr(0,56,"ESP8266 0.96 SSD1306");
u8g2.sendBuffer();
delay(1000);
}

Hopefully that helps someone!

qnsinternational,

QNS International excels in executive search dubai with precise management services. Trust us to find top-tier talent to drive your business forward.

deltaroot,

Modern it security solutions are provided by Deltaroot to protect your digital assets. Strong defense against cyber attacks in both IT and OT settings is ensured by our customized strategy. Put your trust in Deltaroot for complete security and comfort in an ever-changing online environment.

lcentin,

void loop()
{
getNTPtime(10);
showTime(&timeinfo);
//delay(10);

long rssi = WiFi.RSSI();
if (rssi >= -55) {
u8g2.drawBox(102,7,4,1);
u8g2.drawBox(107,6,4,2);
u8g2.drawBox(112,4,4,4);
u8g2.drawBox(117,2,4,6);
u8g2.drawBox(122,0,4,8);
u8g2.sendBuffer();
} else if (rssi < -55 & rssi > -65) {
u8g2.drawBox(102,7,4,1);
u8g2.drawBox(107,6,4,2);
u8g2.drawBox(112,4,4,4);
u8g2.drawBox(117,2,4,6);
u8g2.drawFrame(122,0,4,8);
u8g2.sendBuffer();
} else if (rssi < -65 & rssi > -75) {
u8g2.drawBox(102,8,4,1);
u8g2.drawBox(107,6,4,2);
u8g2.drawBox(112,4,4,4);
u8g2.drawFrame(117,2,2,6);
u8g2.drawFrame(122,0,4,8);
u8g2.sendBuffer();
} else if (rssi < -75 & rssi > -85) {
u8g2.drawBox(102,8,4,1);
u8g2.drawBox(107,6,4,2);
u8g2.drawFrame(112,4,4,4);
u8g2.drawFrame(117,2,4,6);
u8g2.drawFrame(122,0,4,8);
u8g2.sendBuffer();
} else if (rssi < -85 & rssi > -96) {
u8g2.drawBox(102,8,4,1);
u8g2.drawFrame(107,6,4,2);
u8g2.drawFrame(112,4,4,4);
u8g2.drawFrame(117,2,4,6);
u8g2.drawFrame(122,0,4,8);
u8g2.sendBuffer();
} else {
u8g2.drawFrame(102,8,4,1);
u8g2.drawFrame(107,6,4,2);
u8g2.drawFrame(112,4,4,4);
u8g2.drawFrame(117,2,4,6);
u8g2.drawFrame(122,0,4,8);
u8g2.sendBuffer();
}

}

bool getNTPtime(int sec)
{
{
uint32_t start = millis();
do
{
time(&now);
localtime_r(&now, &timeinfo);
delay(10);
} while (((millis() - start) <= (1000 * sec)) && (timeinfo.tm_year < (2016 - 1900)));

if (timeinfo.tm_year <= (2016 - 1900)) 
    return false;

Serial.print("Time Now: ");  
Serial.println(now); 

}
return true;
}

void showTime(tm *localTime)
{
//print to serial terminal
Serial.print(localTime->tm_mday);
Serial.print('/');
Serial.print(localTime->tm_mon + 1);
Serial.print('/');
Serial.print(localTime->tm_year - 100);
Serial.print('-');
Serial.print(localTime->tm_hour);
Serial.print(':');
Serial.print(localTime->tm_min);
Serial.print(':');
Serial.print(localTime->tm_sec);
Serial.print(" Day of Week ");
Serial.println(localTime->tm_wday);
Serial.println();

char time_output[20];
u8g2.setFont(u8g2_font_courB12_tf);
u8g2.drawStr(0,10,getDOW(localTime->tm_wday));
u8g2.setFont(u8g2_font_inr19_mn);
sprintf(time_output, "%02d:%02d:%02d", localTime->tm_hour, localTime->tm_min, localTime->tm_sec);
u8g2.drawStr(0,38,time_output);
u8g2.setFont(u8g2_font_courB10_tf);
sprintf(time_output, "%02d/%02d/%02d", localTime->tm_mday, localTime->tm_mon + 1, localTime->tm_year - 100 + 2000);
u8g2.drawStr(0,56,time_output);
u8g2.sendBuffer();
}

char * getDOW(uint8_t tm_wday)
{
switch(tm_wday)
{
case 1:
return "Monday";
break;
case 2:
return "Tuesday";
break;
case 3:
return "Wednesday";
break;
case 4:
return "Thursday";
break;
case 5:
return "Friday";
break;
case 6:
return "Saturday";
break;
case 7:
return "Sunday";
break;
default:
return "Error";
break;
}
}

lcentin,

/* >>> Credits <<<
From the original ideas by Bizarroland (thanks!!!) that posted the original code:
https://kbin.social/m/Arduino/t/779187/Default-setup-and-screen-display-code-for-Ideaspark-ESP8266-096OLED

And the link to useful tips & Info's (aka library fonts names, commands ...)
https://github.com/olikraus/u8g2/wiki

For the NTP clock part I used the ideas from Emmanuel Odunlade (thank you! Good project)
https://www.electronics-lab.com/project/network-clock-using-esp8266-oled-display/

For the WiFi strenght bar indicator I modified the positron79 code (thank you! Nice idea)
https://forum.arduino.cc/t/wifi-bars-for-uno-wifi-rev2-with-oled-display/866644/3
*/
<Arduino.h>
<Wire.h>
<U8g2lib.h>
<ESP8266WiFi.h>
<time.h>

U8G2_SSD1306_128X64_NONAME_F_SW_I2C
u8g2(U8G2_R0,14,12,U8X8_PIN_NONE);
const char* ssid = "YOUR-WIFI-SSID-HERE";
const char* password = "YOU-WIFI-PASSWORD-HERE";
const char* NTP_SERVER = "time.ien.it";
const char* TZ_INFO = "CET-1CEST-2,M3.5.0/02:00:00,M10.5.0/03:00:00";

tm timeinfo;
time_t now;
long unsigned lastNTPtime;
unsigned long lastEntryTime;

void setup(void) {
u8g2.begin();
Serial.begin(115200);
Serial.println("\n\nNTP Time Test\n");

WiFi.begin(ssid, password);
Serial.print("Connecting to network");
int counter = 0;
while (WiFi.status() != WL_CONNECTED)
{
delay(200);
if (++counter > 100)
ESP.restart();
Serial.print( "." );
}
Serial.println("\nWiFi connected\n\n");

configTime(0, 0, NTP_SERVER);

setenv("TZ", TZ_INFO, 1);

if (getNTPtime(10))
{
// wait up to 10sec to sync
}
else
{
Serial.println("Time not set");
ESP.restart();
}

showTime(&timeinfo);
lastNTPtime = time(&now);
lastEntryTime = millis();

}

lcentin,

Thank you Bizarroland! You gave me the right starting point to modify the original code!
Modifying other sources (thanks to the other contributors mentioned inside the code) I
created a NTP digital clock with WiFi strenght bar indicator.
Hope this helps someone..
Enjoy!
Luigi

Bizarroland,
Bizarroland avatar

Just a little extra:

https://github.com/olikraus/u8g2/wiki

This is the github that covers the various display options in the library.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • Arduino
  • ngwrru68w68
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • megavids
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • anitta
  • Leos
  • tester
  • provamag3
  • JUstTest
  • All magazines