logo elektroda
logo elektroda
X
logo elektroda

[Solved] [Arduino] SSD1306 flashes after adding Deep.sleep/Blynk

pier 1878 38
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 18529612
    pier
    Level 24  
    Hello.
    Colleagues please help as I have no strength left.

    Tell me what is wrong in this code that as soon as I add Deep.sleep or initiate Blynk, the display only flashes and displays nothing. Without these functions it works normally and shows measurements from the sensor.


    Code: C / C++
    Log in, to see the code
    .

    Added after 4 [hours] 23 [minutes]:

    I've come to the realization that some strange display has hit me. The same program uploaded to another board works with deep.sleep and with Blynk without any problems.
    Do you know what the issue is with this display?
  • ADVERTISEMENT
  • #2 18530364
    Marek_Skalski
    VIP Meritorious for electroda.pl
    And isn't this display from the new series? They need a much higher initialisation delay. Without this, they either display nothing or just flash the image and everything disappears.
  • ADVERTISEMENT
  • #3 18530466
    pier
    Level 24  
    Marek_Skalski wrote:
    And isn't this display from the new series? They need a much higher initialisation delay. Without that they either display nothing, or just flash an image and everything disappears.
    .
    Not sure about the new series bought this week.
    So does it initialise and give delaja or how to do it? Some new library maybe?
  • #4 18530486
    khoam
    Level 42  
    Do you have the pin from the display reset connected to the ESP?
    Code: C / C++
    Log in, to see the code
    .
  • #5 18530511
    pier
    Level 24  
    khoam wrote:
    Do you have the pin from the display reset connected to the ESP?
    Code: C / C++
    Log in, to see the code
    .

    This is an I2C display with only four pins, no reset.
  • ADVERTISEMENT
  • #8 18530830
    Marek_Skalski
    VIP Meritorious for electroda.pl
    New type display:
    [Arduino] SSD1306 flashes after adding Deep.sleep/Blynk .

    Display of old type:
    [Arduino] SSD1306 flashes after adding Deep.sleep/Blynk

    The main differences are:
    - the size of the display itself (the new one is smaller)
    - width of the ribbon connecting the display to the board - the new one is narrower
    - number of components on the board - the new one has less
    The old ones start immediately (< 50 ms from power on). The new ones need (in my case) > 400 ms. I bought some of the new ones and thought they were defective. But I was surprised to find that after a reset of the circuit they work without any problem. A while later I figured out that the chip needs more time to start. In tests it came out > 400 ms.
  • #9 18530954
    khoam
    Level 42  
    The problem may also be that the default I2C speed when calling Adafruit_SSD1306 library functions is 400 kHz. I very much doubt that the ESP8266 can handle the calls properly then - there is no I2C hardware controller in the ESP8266. I would suggest calling the constructor with the following parameters:
    Code: C / C++
    Log in, to see the code
    .
    Or even be tempted to use an even lower speed I2C:
    Code: C / C++
    Log in, to see the code
  • #10 18530994
    pier
    Level 24  
    I have an old-style display.

    Khoam nothing is achieved by these treatments. After a reset the image shows for a while and disappears....
  • #11 18531015
    khoam
    Level 42  
    pier wrote:
    After a reset the image shows for a while and disappears...
    .
    If with the ESP.deepSleep() command at the end of the loop() then I'm not even surprised and I already wrote you about it in another thread.
    pier wrote:
    that as soon as I add Deep.sleep or initiate Blynk then the display just flashes and nothing is displayed.
  • #12 18531179
    pier
    Level 24  
    khoam wrote:
    pier wrote:
    After a reset the image shows for a while and disappears...
    .
    If with the ESP.deepSleep() command at the end of the loop() then I'm not even surprised and I already wrote you about it in another thread.
    pier wrote:
    that as soon as I add Deep.sleep or initiate Blynk the display just flashes and displays nothing.
    .

    Khoam then where do I place deep.sleep?
    I put the Blynk initialisation in the setup as you suggested. In general eggs are happening with this display. Wherever I give delay(); for a test, the display is already dead. The rest of the program i.e. BME280, Blynk, Thingspeak are working fine.
  • #14 18531232
    pier
    Level 24  
    khoam wrote:
    Blynk.run() should be in loop():
    https://examples.blynk.cc/?board=ESP8266&...0WiFi&example=GettingStarted%2FBlynkBlink

    ESP.deepSleep() should not be called after every loop() run, but only when you decide to do so and it makes sense. When you return from deep-sleep, the program executes from the beginning, as after a reset.


    Yes Blynk.run() I have in loop().

    And now it's like this, when I use the Deep.sleep function the display shows the correct image for a while and that's it, but when I initialise the Blynk the display is completely dead. I don't understand any of this.

    I don't know how to use ESP.deep.sleep. I read the sensor, display the measurements on the lcd, send to the server and put ESP to sleep why should I spin the loop more times?
  • #15 18531359
    khoam
    Level 42  
    pier wrote:
    I read the sensor, display the measurements on the lcd, send to the server and put the ESP to sleep why should I spin the loop more times?
    .
    This is going to be a problem, because Blynk.run() requires this "spinning" in loop().
  • #16 18531390
    pier
    Level 24  
    khoam wrote:
    pier wrote:
    I read the sensor, display the measurements on the lcd, send to the server and put the ESP to sleep why should I spin the loop more times?
    .
    This will be a problem because Blynk.run() requires this "spinning" in loop().


    Well, not really. Already that two years I have a weather sensor that works according to what I wrote. Now I wanted to make a second one and such eggs I have with this display.
  • #17 18531538
    khoam
    Level 42  
    There is one more thing. In the code you call Wire.begin(D5,D6) because of the pin change for I2C. On the other hand, display.begin(SSD1306_SWITCHCAPVCC, 0x3C) also calls Wire.begin(), but already for the default I2C pins (D1, D2). So try changing this call to:
    Code: C / C++
    Log in, to see the code
    The last parameter (false) means that Wire.begin() will not be called again.
  • #18 18531822
    pier
    Level 24  
    khoam wrote:
    There is one more thing. In the code you call Wire.begin(D5,D6) because of the pin change for I2C. However, display.begin(SSD1306_SWITCHCAPVCC, 0x3C) also calls Wire.begin(), but already for the default I2C pins (D1, D2). So try changing this call to:
    Code: C / C++
    Log in, to see the code
    The last parameter (false) means that Wire.begin() will not be called again.
    .

    I checked for peace of mind but just as I thought it didn't change anything. I repeat the display works if there is no lag, blynk or sleep in the code. For some unknown reason the problem for this display is any delay in the code, just give a delay(); greater than 10 anywhere in the code and already the display is silent.
    Khoam probably needs to consider that this display is some kind of junk, damaged or has some clone of the SSD1306 driver, give up on it and buy a new one.
  • #19 18532111
    khoam
    Level 42  
    pier wrote:
    Khoam I guess you have to consider that this display is some kind of junk, damaged or has some clone of the SSD1306 driver, give up with it and buy a new piece.
    .
    If you buy a new display and the problem remains, we'll probably come back to the subject.;)
  • #20 18532168
    pier
    Level 24  
    khoam wrote:
    pier wrote:
    Khoam probably need to consider that this display is some kind of junk, defective or has some clone of SSD1306 driver, give up with it and buy a new piece.
    .
    If you buy a new display and the problem remains, then we'll probably be back on topic.;)


    And didn't I write you that after uploading this program to another board with another copy of the display everything works as expected. I might be tempted to swap the lcd itself then it will be 100% sure.
  • #21 18532177
    khoam
    Level 42  
    Publish perhaps the latest version of the code with all the fixes I wrote about that is not working properly.
  • #22 18532404
    pier
    Level 24  
    Code: C / C++
    Log in, to see the code
    .


    Blynk.begin, Blynk.run() and ESP.deep.sleep are commented out because enabling any of them results in the display not working.

    Added after 8 [hours] 37 [minutes]:

    I still tried uploading a sample program from the library examples. Of course I changed the SCL SDA pins and what the display does not display anything.
  • ADVERTISEMENT
  • #23 18534148
    khoam
    Level 42  
    pier wrote:
    Of course I changed the SCL SDA pins and what the display does not show anything.
    .
    Can you check that these pins are connected via resistors to 3V3?
  • #24 18534524
    pier
    Level 24  
    I connected another copy of the display to this board and it works as expected and blynk and deep.dleep.
    The conclusion is that these two-colour displays are kind of weird.
    As it turns out, I'm not the only one who has a problem with this display Link .

    I also did a trial with adding pullups on the data lines, with no effect.
  • #25 18534898
    khoam
    Level 42  
    When the display is not working, does the message "SSD1306 allocation failed" appear in the serial port monitor?
  • #26 18535562
    pier
    Level 24  
    khoam wrote:
    When the display is not working, does the message "SSD1306 allocation failed" appear in the serial port monitor?
    .

    I'm not likely to see such a message, the question is still what speed do I set the transmission to?

    But the eggs continue with this display. I've been playing around with the other display for a while, now I've plugged in the faulty one to check that message you wrote about and miracle works with Blynk! In the code I just added the display of one character more. But with sleep it still doesn't work? My hands are falling off.

    Code: C / C++
    Log in, to see the code
    .
  • #27 18535730
    khoam
    Level 42  
    Rather, it should be:
    Code: C / C++
    Log in, to see the code
    .
  • #28 18535756
    pier
    Level 24  
    khoam wrote:
    It should rather be:
    Code: C / C++
    Log in, to see the code
    .

    It starts to work and with sleep, although the display does not always get up after deep.sleep.

    What does this UL give?
  • #29 18535765
    khoam
    Level 42  
    pier wrote:
    What does this give UL?
    .
    The fact that the result of the operation will then be a uint64_t, not an int.
    Code: C / C++
    Log in, to see the code


    Added after 13 [minutes]:

    pier wrote:
    although the display doesn't always get up after deep.sleep.
    .
    And what does this mean specifically? Are you sure the ESP8266 itself is awake?
  • #30 18535806
    pier
    Level 24  
    khoam wrote:
    pier wrote:
    What does this give UL?
    .
    The fact that the result of the operation will then be a uint64_t, not an int.
    Code: C / C++
    Log in, to see the code


    Added after 13 [minutes]:

    pier wrote:
    although the display doesn't always get up after deep.sleep.
    .
    And what does this mean specifically? Are you sure the ESP8266 itself is awake?
    .

    More likely the whole thing is catching a hang because there are no further resets.
  • Topic summary

    The discussion revolves around issues faced when integrating the SSD1306 OLED display with an ESP8266 microcontroller while using Blynk and Deep Sleep functions. Users report that the display only flashes or shows nothing when these functions are added, despite working correctly without them. Suggestions include ensuring proper initialization delays for the display, checking I2C connections, and adjusting I2C speeds. It was noted that newer SSD1306 displays may require longer initialization times. The problem persisted until a board update resolved the issues, allowing the display to function correctly with Blynk and Deep Sleep.
    Summary generated by the language model.
    ADVERTISEMENT