Page 1 of 1

0.9 inch oled hangs after about 1 Minutes

Posted: Tue Apr 10, 2018 7:26 pm
by shrimps
Hi all,
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");
}



Re: 0.9 inch oled hangs after about 1 Minutes

Posted: Wed Apr 11, 2018 7:56 am
by rin67630
You might just have got a crappy hardware.
I had much trouble with those modules.

Re: 0.9 inch oled hangs after about 1 Minutes

Posted: Wed Apr 11, 2018 8:58 am
by Archibald
Other people are reporting the same issue with I²C.

Alternative 'Wire' library is available here:
https://github.com/stickbreaker/arduino ... aries/Wire

Re: 0.9 inch oled hangs after about 1 Minutes

Posted: Wed Apr 11, 2018 12:47 pm
by mikemoy
@shrimps, I was getting I2c Errors after about 2-3 hours. I switched to ESP-IDF and have not had any so far.

Re: 0.9 inch oled hangs after about 1 Minutes

Posted: Thu Apr 12, 2018 11:03 am
by shrimps
Thanks for all Answers...

I will have a look at new Librarys...

Actually my i2c dosn´t answers... :geek:

But theese tiny things make a lot of fun

Greetings from D

BTW: Is anyone near my country (PLZ 41x) ?

Solved: 0.9 inch oled hangs after about 1 Minutes

Posted: Fri Apr 13, 2018 9:41 am
by shrimps
Hello, Feedback:
I changed the library from adafruit to esp8266-ole-ssd1306-master.
And secondly i found some skaky connection in my cables (seen at the i2c-scanner)

Now it runs 24h without problems...

Thank at all