[SOLVED] Problem with i2c devices when powering down

Hello,

Im currently working with an OLED screen and a RTC module (DS3231). The thing is that when I power down the devices, the current is 0.88mAh. But if I only use 1 i2c device (Oled screen or RTC, doensnt matter) the consuption is 0.014mAh.

What is going on? I don’t understand anything.

I think the I2C bus is still sending information or some device is not correctly powered OFF. For the DS3231 Im setting the PIN to LOW and for the OLED screen im using some code that I found on the Adafruit library

My problem is the current, I would like to cut that as much as I can so the batteries Im planning to add will last longer. Is there any way to switch the devices off so they wont consume power?

I attached a more detailed scheme of my wiring.

Thanks in advance

// **** INCLUDES *****
#include <Wire.h>
#include "LowPower.h"
#include "SSD1306Ascii.h"
#include "SSD1306AsciiWire.h"
#include <RTClibExtended.h>
#include <avr/power.h>

SSD1306AsciiWire display;
RTC_DS3231 RTC;      //we are using the DS3231 RTC


const byte rtcPIN = 8;

void setup()
{
  Serial.begin(9600);
  pinMode(rtcPIN, OUTPUT);
  digitalWrite(rtcPIN, LOW);
}

void loop()
{

  digitalWrite(rtcPIN, HIGH);
  delay(5);
  Wire.begin();

  RTC.begin();
  display.begin(&Adafruit128x64, 0x3C, 4);
  display.setFont(System5x7);
  display.clear();



  display.print("Hello!!");

  DateTime now = RTC.now();
  printTimestamp(now);


  delay(5000);

  uint8_t control = 0x00;
  Wire.beginTransmission(0x3C);
  Wire.write(control);
  Wire.write(0xAE);
  Wire.endTransmission();

  Wire.end();
  digitalWrite(rtcPIN, LOW);
  // Enter power down state for 8 s with ADC and BOD module disabled
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);

}

void printTimestamp(DateTime currentTime) {
  char timestampChar[20];  // should handle yyyy/mm/dd hh:mm:ss and null terminator
  snprintf(timestampChar, sizeof(timestampChar), "%d/%02d/%02d %02d:%02d:%02d",  currentTime.day(),  currentTime.month() , currentTime.year() , currentTime.hour(), currentTime.minute(), currentTime.second()); // write to char array
  Serial.println(timestampChar);
}

What current?

Post a hand drawn (not Fritzing) wiring diagram.

Just updated with some pictures, sorry for the shit quality of the diagram, I also attached a picture of the real thing

Can you describe, and draw a diagram of the actual circuit ?

The photgraph clearly shows two arduinos connected together ?

Sorry, I forgot to say that, the other arduino is without the processor, its only for uploading code to the ATMEGA328P.

The ATMEGA is conencted to and RTC and an OLED screen, thats pretty much it. I turn the device on, say hello on the screen and display the time on the serial port and then I go to sleep. The problem is the 0.8mAh current I have while sleeping that is way more than the current I have when I only attach 1 I2C device.

The more devices, the more current drawn. Until you can post a clear, detailed wiring diagram, no one can help.

Better diagram with the wiring attached, hopefully it will help you all in understanding me

Thanks

The better diagram seems to be missing the I2C pullups and does not show how the second Arduino is connected ?

Better, but what voltage is Vcc?

Again, what current are you talking about?

You do realize that putting the Arduino to sleep does not put the devices to sleep?

"The better diagram seems to be missing the I2C pullups and does not show how the second Arduino is connected ?"

As Im using breakout boards, as far as I've read in some other post they include the pullups so there is no need to add them.

As I've menctioned before, there is NO second arduino, its just the interface (TX,RX, RESET & GND) to use the Serial port to upload code to my ATMEGA328PU

"Better, but what voltage is Vcc?"

The voltage is 5V

"Again, what current are you talking about?"

When I connect the device, it turns on and the current is about 40mAh, then 2 things happen, as you can see in the code, i turn off (or at least I think im turning off) the oled screen and then I cut power from the RTC module setting the pin to low.

"You do realize that putting the Arduino to sleep does not put the devices to sleep?"

Yes, I know, but here is the thing, same diagram, but only connecting 1 thing (lets say RTC module) the current when sleeping is extremely low, same changing the RTC for the OLED display. But when I connect both, when I go to sleep the current is way higher, like 0.88mAh.

Maybe im not doing something right when I try tu turn off both devices, thats why Im looking for some help here.

Im sorry, english is not my language and I'm doing my best in trying to explain things,

Thanks

Post links to all the modules.

If the I2C devices are 3.3V only, you have already destroyed them.

When I purchased them I checked that and It says 5V, also , as I've menctioned before, they work perfectly fine, the problem is the current, so Im pretty sure I didnt break anything.

Anyways, this are the devices Im using:

OLED SCREEN: OLED blanco LCD Módulo De Pantalla LED 0,96 "0,96 pulgadas I2C CII serie 12864*128*64 SSD1306 3V ~ DC 5V SPI módulo Serial para Arduino|display module|white oledoled lcd led display - AliExpress

RTC MODULE: Módulo de memoria de reloj en tiempo Real para Arduino, minidispositivo de precisión RTC, DS3231 AT24C32 IIC, DS3231SN AT24C32, 1 unidad|rtc module|rtc ds3231arduino rtc - AliExpress

The RTC module is a bad design, featuring a battery charger that runs of 5V and pullup resistors that defeat powering down the module.

Here is how to fix that.

Yes, you're right, I read about it before, but still, if I use my modified version of the RTC Im getting the same results more or less. Im getting a current of 0.73mAh with the modified version vs 0.88 of the original one.

Note that the LED of the RTC still has light even if I turn the power off. I figured out that is due to the SDA & SCL lines, if I unplug them the current goes down to 0.01mAh.

Any ideas?

Thanks

the LED of the RTC still has light

Remove the totally useless LED.

"Remove the totally useless LED."

I know, and I did, I have my modified RTC version, but still drawns 0.73mAh in sleep mode. The thing is that i think 0.3 comes from SDA pin and 0.3 comes from SDL.

Im 100% sure its something about the i2c line, having only 1 i2c device give me an excelent low power current, about a few microAmps

Any help will be apreciated

So, you did not remove the pullup resistor module either?

I followed this picture to get rid of the LED and the charging circuit:

Will the device work if i remove also the pullup resistances? I though I would need them

You need only one pullup resistor on each I2C line. You need to check every device, as well as the processor board.

Edit: you need to power the RTC only when reading or writing to it. An Arduino output pin can be used to power it during those operations.

“You need only one pullup resistor on each I2C line. You need to check every device, as well as the processor board.”

Ok mate, you’re a genious. I removed the RTC pullup and now everything works with a current of 0.03mAh! Thanks very much for your help

“Edit: you need to power the RTC only when reading or writing to it. An Arduino output pin can be used to power it during those operations.”

Yeah, I was doing that since the begining

With that the problem is now solved, thanks a lot to all that contributed!