And my latest addition to this Blynk Serial Display phase I am on…
The TTG ESP32 with OLED & 18650
Tiny screen, but good resolution (128x64)… hard to focus up close
//#define BLYNK_DEBUG
#define BLYNK_MAX_READBYTES 1024
#define BLYNK_MSG_LIMIT 0
#define BLYNK_HEARTBEAT 60
#define BLYNK_NO_BUILTIN // Disable Blynk's built-in analog & digital pin operations
#include <U8g2lib.h> // For OLED
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0,/* reset=*/ U8X8_PIN_NONE,/* clock=*/ 4, /* data=*/ 5); // The all important setup for the TTGO's build in OLED
// Define a custom console for OLED debug output
class CustomConsole
: public Print // This automatically adds functions like .println()
{
public:
CustomConsole() {}
virtual size_t write(uint8_t ch) { // Grabs character from print
u8g2.print(char(ch)); // Add character to OLED buffer
Serial.print(char(ch)); // Repeat all character output to Serial monitor
if (ch == '\n') { // End of line check
u8g2.sendBuffer(); // Dump buffer to OLED
line += height; // Increment next line down
if (line >= 72) {
line = height; // Reset line counter
}
u8g2.sendBuffer(); // Dump buffer to OLED
u8g2.setCursor(0, line); // Set curser to next line down
}
return 1; // Processed 1 character
}
private:
// define variables used in myConsole
int line = 8; // line counter
int height = 8; // Line pixel height
};
// initiate myConsole
CustomConsole myConsole;
#define BLYNK_PRINT myConsole
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <ESPmDNS.h> // For OTA
#include <WiFiUdp.h> // For OTA
#include <ArduinoOTA.h> // For OTA
#include <TimeLib.h>
#include <WidgetRTC.h>
char auth[] = "xxxxxxxxxx";
char ssid[] = "xxxxxxxxxx";
char pass[] = "xxxxxxxxxx";
char server[] = "10.10.3.13";
int port = 8080;
char currentTime[9];
char currentDate[11];
BlynkTimer timer;
WidgetRTC rtc;
void setup() {
pinMode(16, OUTPUT);
u8g2.setFont(u8g2_font_micro_mr); // choose a suitable font for Logo
Serial.begin(115200);
u8g2.begin();
timer.setInterval(1010L, TimeDatecheck);
timer.setInterval(2030L, RSSIcheck);
timer.setInterval(3045L, FlashLED);
WiFi.begin(ssid, pass);
Blynk.config(auth, server, port);
Blynk.connect();
ArduinoOTA.setHostname("TTGO - OLED & 18650"); // For OTA
ArduinoOTA.begin(); // For OTA
}
BLYNK_CONNECTED() {
rtc.begin();
setSyncInterval(360); // Time Sync
}
void loop() {
ArduinoOTA.handle(); // For OTA
timer.run();
Blynk.run();
}
//--------------------------------------------------//
void TimeDatecheck() {
sprintf(currentTime, "%02d:%02d:%02d", hour(), minute(), second());
sprintf(currentDate, "%02d/%02d/%04d", month(), day(), year());
myConsole.print(currentTime);
myConsole.print(" ");
myConsole.print(currentDate);
myConsole.println(" ");
}
void RSSIcheck() {
Blynk.virtualWrite(V67, WiFi.RSSI()); // RSSI
//myConsole.print("Board #1 - RSSI ");
myConsole.print("Board #2 - RSSI ");
myConsole.print(WiFi.RSSI());
myConsole.println(" ");
}
void FlashLED() {
digitalWrite(16, LOW); // Turn ON
delay(100);
digitalWrite(16, HIGH); // Turn OFF
}