i2c OLED screen content shifting ... sometimes!

Hi

I am building an automated egg incubator... so I have some sensors:

  • 2x DS18B20 (Dallas library)
  • 1x DHT11 (non-blocking library used)
  • tiny i2c OLED screen
  • Fan (5V one always running)
  • Relay board with 2 relays (1 for a ceramic lamp to heat the incubator, 1 for a 220V microwave motor to turn the eggs every 3 hours)

To pilot the lamp relay, I am using the interrupts of the Counter 1 to 1MHz

All that is described here with the code also:

But ... I guess I still have some errors because:

  • The content of the oled screen shifts by itself occasionally
  • I had to tweak the twi.c/h files to avoid some deadlocks and thus reset the i2c bus automatically if it fails... (seems like something others have since the hack was found on internet).

So, do you have any idea why the content of screen is not always starting at 0,0?
Any suggestion during the code review is welcome of course :slight_smile: !

... I am not trying to do the most beautiful code... just a working one since the eggs will soon be there and I need the system to run non-stop for 21 days!

Thanks!