I'm displaying the millisecond count from Arduino's millis() function, on an I2C OLED display. But I'm getting corrupted font characters. How can this be fixed?

By Julian

Youtuber, shed dweller, solar charge controller aficionado

17 thoughts on “Arduino oled display and the u8glib picture loop”
  1. Avataaar/Circle Created with python_avatars Tonio García says:

    Gracias por la info Julian

  2. Avataaar/Circle Created with python_avatars KirillDK says:

    Thanks, Julian, it was very helpful for me!

  3. Avataaar/Circle Created with python_avatars polisbaba says:

    nice work THANK YOU!

  4. Avataaar/Circle Created with python_avatars Petilajos says:

    I searched many hours for the solution. Thank you that he shared with me.

  5. Avataaar/Circle Created with python_avatars Dave -in-NJ says:

    request : show how to get font alignment.

    temp : 72,21
    RH : 34.75
    pr : 29.92

    change font and get
    p : 72,21
    : 34.75
    : 29.92

  6. Avataaar/Circle Created with python_avatars AN86 says:

    i write all as you are and i get
    'u8g' was not declared in this scope next to the u8g.firstPage();

    was im doing something wrong ?

  7. Avataaar/Circle Created with python_avatars Choriposter 24/7 says:

    you should show a STM32 chip , icstation sells them, i no longer have a reason to buy an arduino

  8. Avataaar/Circle Created with python_avatars Mithat Konar says:

    So, the takeaway is that you shouldn't update values in the loop that updates the display. Seems obvious in retrospect. 🙂

  9. Avataaar/Circle Created with python_avatars Whitefields5595 says:

    Julian, Please get back in the garden and continue the Muppet project. I'm converting some of my lighting in the house to 12V LED charged from a dedicated 240W panel(s) and I need a good charge controller. Im up the road from you in Solihull so willing to be a test site.

  10. Avataaar/Circle Created with python_avatars Stephen Kramer says:

    good problem solving thinking.

  11. Avataaar/Circle Created with python_avatars Thomas Arthofer says:

    Hi Julian, your problem is in your example code. In the do…while loop you write all pages while always using the current millis() time. So if millis increases while drawing a line, you get 5 lines with "1234" as millis, the next 5 lines with "1235" and so on.
    So if you add "unsigned long millis_value = millis();" before the do…while loop and use millis_value instead of millis() itself, you will get rid of the tearing.

  12. Avataaar/Circle Created with python_avatars Al Lipscomb says:

    You could do something like:
    void setup() {
    last = millis();
    }
    voidloop(){
    now = millis();
    diff = now – last;
    if (diff > 1000) {
    updateYourDisplay(now);
    last = now; // omitted in original post
    }
    }

  13. Avataaar/Circle Created with python_avatars Dean Greenhough says:

    Many thanks for the reply, working late I see. I would be very very interested in your illuminating is even more. Reply appreciated

  14. Avataaar/Circle Created with python_avatars Aperson says:

    Lol, my iphone glitched out and played the previous video i viewed instead… It literally looked like you were re-uploading videos for a second.

  15. Avataaar/Circle Created with python_avatars TheViewFromUpHere says:

    Your update rate for the display is too fast. You can't display a ms value in real time without some blurring of the numbers.

  16. Avataaar/Circle Created with python_avatars TheConanRider says:

    change int m to uint32 m to solve the integer overflow issue.

  17. Avataaar/Circle Created with python_avatars George Formless says:

    I note that you are using the latest 1.6.8 version of the Arduino IDE. When I installed this last week it rejected my u8glib library as incompatible with the IDE on every start up. I've just checked and the u8glib library doesn't seem to have been updated for some time, so I'm wondering if anyone else has had this problem.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.