I've been using the u8g2 library to to send sensor data to a 128x64 OLED. It works great but only after I start the serial monitor.
Is there something I can put in the setup to initiate this when I don't have it plugged into a computer?
I've included some basic Hello World code below. For example, if I go through and modify it to Hello Jupiter, it will upload to the Arduino but it won't be sent to the OLED until after I open the serial monitor. This would be fine but I need the device to work even when it's not plugged into the computer.
Thanks!
#include <Arduino.h>
#include <U8g2lib.h>
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif
U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ 16, /* data=*/ 17, /* reset=*/ U8X8_PIN_NONE);
void setup() {
Serial.begin(115200);
while (!Serial)
delay(100);
u8g2.begin();
delay(50);
}
void loop() {
u8g2.clearBuffer(); // clear internal memory
u8g2.setFont(u8g2_font_helvB08_tr );
u8g2.drawStr(0,10,"Hello World");
u8g2.sendBuffer(); // transfer internal memory to the display
}