SSD1306 works intermittently

Hi everyone

I'm using exactly the display shown below with an ESP8266, the code is the basic example of the SSD1306.h, and it works. Then I remove the USB cable and reconnect and the display is comepletely black.
At that point I wait, say 20 minutes, I connect the USB cable and it works.
Every time!

Any suggestion?

It behaves the same both at 5V and 3V
[image]

The wiring is exactly this

and here the video that shows the behaviour

The OLED is not getting reset when power is removed. Maybe caps in the circuit are providing enough power for it to continue working at some basic level, even though that power is not enough to actually display anything.

After you disconnect the USB power, use a wire to short the Vdd and GND pins of the OLED for a few seconds. Then reconnect USB power.

If that works, that might confirm my theory about the caps.

In the video, there appear to be more components connected than you put in your "exact" wiring diagram.

Thanks for the hint. I was about to screem "it woooooorks" but it must have been a random miracle. Every now and then it works. The short trick must last around 1 minute.

I'm not an electronic expert so I don't get it, it's one of the magics I just apply blindly.
Assuming this is the solution, how do I fix this in the final version? The final gizmo will go into deep sleep for a variable amount of time depending on certain conditions, so it may wake up after 3 minutes and the screen will not be working.

What should I add? A resistor?

I removed the other things you see in the movie, same result. The OLED started with this issue almost immediately, even when the wiring was the very basic. I did not realise it, because just reflashing or resetting via the button, does not cause any problem. So it's an electric issue... I think.

At least 2 pull up resistors on the SDA and SCL lines.
(try 4K7 for 5V and 3K3 for 3V device)

If the bitstream to the I2C is broken at the wrong moment, the internal buffer of the display might have corrupted data. And as PaulRB points out the caps might keep this state for a while.

1 Like

So what is it, post a link to its technical data as I do not have one that looks like that. That should tell us if you need pull up resistors and what happens when power fails.

It may not be a problem at all.

When your gizmo goes to sleep, this will be under code control and will not be in the middle of an i2c transaction with the display, which is what is happening when you pull the USB plug.

For minimum power consumption in sleep mode, you may want to clear the display so every pixel is off. If consumption is still too high or you are still getting the problem for some reason, you could use a Wemos pin to control power to the OLED. I don't think the Wemos pins can supply enough current for the OLED, so you will probably need to use a transistor (eg. BC327).

Have you tried getting the OLED Vcc directly from the power supply, and not through the microcontroller?

Are you sure the ESP8266 is actually running? Looks like you are using a USB power bank, some of those need a minimum load current or they will shut off.

Thanks everyone for your hints. I tried almost everything, including the pull-up resistors.
To be honest I just put in two random resistors from the box (the label says 10K) and it did not work. For what they cost, I ordered a set of 4K resistors and will try.
To complete the research, my code executed on a NodeMCU with an integrated display, works perfectly, even if I abruptly remove the power. Clearly the display has all the resistors in the right place :wink:

This topic has been already discussed, but without a real solution.
I'm using two NodeMCU, one with a receiver and one with an emitter.

The receiver works as expected. It receives signals from remote controls and even from the emitter. The emitter works. Since it's supposed to be a break beam, my expectations were that, putting my hand in between, or a book, the receiver would stop to .... ehm, receive :slight_smile:

In the previous topic, it was pointed out that the receiver continues to get data because the emitter continues to send. But this is exactly the goal. If data are received then nobody passed in front of the emitter, otherwise the beam is broken and something will happen.
Here's what I already tried based on the research I made so far:

  • remove power from the emitter: the receiver clearly does not receive
  • break the beam with hand, book, plastic, the receiver reads data
  • If I point the TV remote towards the receiver and keep a button pressed, the receiver continues to read data, but if I put a hand in between, the reading stops.
  • randomly fill the rawData array to generate different values at every loop - this told me that the receiver actually reads from the emitter, and continues even with the Divine Comedy (all the 3 volumes) in between and no matter the distance

The emitter has only the IR led attached to pin D8.
The receiver has only the IR receiver attached to pin D6
Both are the most basic stuff, just the leds, not mounted on some fancy component.

Code is the most basic you can imagine... anyway here it is

//// the receiver
#include <IRremoteESP8266.h>
#include <IRrecv.h>
#include <IRutils.h>

const int RECV_PIN = D6;
IRrecv irrecv(RECV_PIN);

decode_results results;
void setup() {
  Serial.begin(9600);
  irrecv.enableIRIn();
}

int k = 0;

void loop() { // this is the receiver loop
  if (irrecv.decode(&results)) {
    Serial.println(results.value);
    irrecv.resume();
    k++;
    Serial.println(k);
// yes it's ugly but I want something to be printed in between the lines which are all the same
  }
  delay(100);
}


////// the emitter

#include <IRremoteESP8266.h>
#include <IRsend.h>
#include <IRutils.h>

const int SEND_PIN = D8;
IRsend irsend(SEND_PIN);

decode_results results;

uint16_t rawData[67] = {1000, 4500, 650, 550, 650, 1650, 600, 550, 650, 550,
                        600, 1650, 650, 550, 600, 1650, 650, 1650, 650, 1650,
                        600, 550, 650, 1650, 650, 1650, 650, 550, 600, 1650,
                        650, 1650, 650, 550, 650, 550, 650, 1650, 650, 550,
                        650, 550, 650, 550, 600, 550, 650, 550, 650, 550,
                        650, 1650, 600, 550, 650, 1650, 650, 1650, 650, 1650,
                        650, 1650, 650, 1650, 650, 1650, 600};

void setup() {
  //Serial.begin(9600);
  irsend.begin();  
}

int k = 0;

void loop() { // this is the sender loop
  irsend.sendRaw(rawData, 67, 38); // Send a raw data at 38kHz.
  delay(2000);
}

It appears you have a hardware problem, and without seeing how everything is connected, I can only make an educated guess. Could you post an annotated schematic showing exactly how you’ve wired each unit? Be sure to include all external components, power sources, and connections. This will help in diagnosing the issue more accurately.

1 Like

Confusing story. I gather that the receiver still receives when you put an object between transmitter and receiver. Maybe the IR transmit power is too high for the distance you're bridging. IR light does bounce of the ceiling etc. Try to lower the IR LED current by increasing the current limiting resistor for that LED.

I hope you already have a resistor in series with the LED. 100 ohm being the absolute minimum for pin survival.
Leo..

I'm attaching a picture of the wiring. Super basic.


Thanks for any idea.

Good point. I must admit I'm confused about the use of resistors. So, no I didn't. I attached the wiring in another reply. Where should I put the resistor? On the D8 line or the ground?

About bouncing, I even completely wrapped the emitter. Same result.

The term "in series" means connect the resistor to the Arduino pin, connect the other end of the resistor to your emitter.

What receiver are you using? That is the real part number of the device.

Discussed by you?
If so is this post still open?
If it is this is a breach of forum rules.

The topic was closed years ago, opened by someone else. I already did everything proposed there as a solution. Hence a new attempt.

Using exactly these BOJACK Infrared Emitter and IR Receiver Diode, lampe Infrared Emission and Receiver Tube for Arduino(pack of 10 pairs) : Amazon.co.uk: Business, Industry & Science

If you completely wrap it with ir-opaque material, you don't receive anything..
Anyway, try to work on the receiver side instead.

No. YOU have a post open now on the same or similar topic. I have reported this other thread to the forum moderators.

Can you post a link to the old topic not started by you.