sorry this is my first message in this board.
Iam not very well at englisch, so please sorry
My problem:
I coded some tiny sketch to be displayed on the oled
my board:
https://www.amazon.de/gp/product/B071P9 ... UTF8&psc=1
Oled:
https://www.amazon.de/gp/product/B01L9G ... UTF8&psc=1
All things ar display at the seriel att all time but on the oled it hangs after about 1 minute ???
Whats wrong
Thanks for any help
greetings from D
Code: Select all
#include <WiFi.h>
#include "time.h"
#include <Adafruit_SSD1306.h> // 0.9 Zoll OLED
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
const char* ntpServer = "pool.ntp.org";
const long gmtOffset_sec = 3600;
const int daylightOffset_sec = 3600;
char ssid[] = "***"; // Your network SSID (name)
char pass[] = "***"; // Your network password (if any)
static float TempS = 7.8;
static float TempG = 15.3;
static short Lux = 59;
void setup() {
Serial.begin(115200);
Serial.printf("Connecting to %s ", ssid);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.print("Local IP address : ");
Serial.println(WiFi.localIP());
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32)
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println("Modul startet...");
display.println("Locale IP addresse: ");
display.println(WiFi.localIP());
configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
printLocalTime();
display.display();
delay(5000);
}
void loop()
{
Serial.print("Temperatur Schlafhaus: ");
Serial.printf("%3.1f \n",TempS);
Serial.print("Temperatur Vorraum : ");
Serial.printf("%3.1f \n",TempG);
Serial.print("Helligkeit (LUX) : ");
Serial.println(Lux);
Serial.println("");
display.clearDisplay();
display.setCursor(0,0);
display.setTextSize(1);
printLocalTime();
display.setTextSize(2);
display.setCursor(0,10);
display.print("SH :");
char anzeige[10];
dtostrf(TempS, 4, 1, anzeige);
display.println(anzeige);
display.print("GH :");
dtostrf(TempG, 4, 1, anzeige);
display.println(anzeige);
display.print("LUX:");
display.println(Lux);
display.display();
delay(1000);
} //void loop
void printLocalTime()
{
struct tm timeinfo;
if(!getLocalTime(&timeinfo)){
Serial.println("Failed to obtain time");
return;
}
Serial.println(&timeinfo, "%d.%m.%Y %H:%M:%S");
display.println(&timeinfo, "%d.%m.%Y %H:%M:%S");
}