DS3231 + AT24C32 as data logger and I2C protocol

Hello everyone!

I am new to this forum and I have a plentiful of questions for you! To introduce myself, I would like to mention that I cannot completely understand how I2C protocol works; therefore I need some clarification from you!

To begin with I would like to connect a RTC DS3231 module with a couple of DS1820B thermometers. Also I just found out that my DS3231 RTC module has a AT24C32 chip emended that can be used as a data logger so I would like to take full advantage out of this!

I can understand that all those modules communicate through I2C protocol and have their own unique addressee except AT24C32 which need its addressee to be programmed by the user. At this moment I am not capable of producing a code without the use of libraries for each module! Is it possible to connect all of them on an arduino and simultaneously use a dedicated library for each one of those modules or learning how I2C works is a must at that point?

Also, I would like some clarifications on how to use EEprom on DS3231! I searched on the internet and I cannot find any clue on how to save data there!! Is there any tutorial available? Also is there a easy way to register an addressee AT24C32 on module?
Note: I want to learn and not to take a direct solution for my problem! So please explain to me in as much detail as possible how I2C works and how I can use it for my project!

The eeprom on the module should be at address 0x50 and you can use the Wire.h library to read/write. You can treat it as an independent device.

Also, I would like some clarifications on how to use EEprom on DS3231! I searched on the internet and I cannot find any clue on how to save data there!!

If you Google "exernal eeprom arduino" you will find plenty.

Here is a tool--the i2c scanner which will help you find all the addresses on the bus.

// I2C Scanner
// Written by Nick Gammon
// Date: 20th April 2011

#include <Wire.h>

void setup() {
  Serial.begin (115200);

  // Leonardo: wait for serial port to connect
  while (!Serial) 
    {
    }

  Serial.println ();
  Serial.println ("I2C scanner. Scanning ...");
  byte count = 0;
  
  Wire.begin();
  for (byte i = 8; i < 120; i++)
  {
    Wire.beginTransmission (i);
    if (Wire.endTransmission () == 0)
      {
      Serial.print ("Found address: ");
      Serial.print (i, DEC);
      Serial.print (" (0x");
      Serial.print (i, HEX);
      Serial.println (")");
      count++;
      delay (1);  // maybe unneeded?
      } // end of good response
  } // end of for loop
  Serial.println ("Done.");
  Serial.print ("Found ");
  Serial.print (count, DEC);
  Serial.println (" device(s).");
}  // end of setup

void loop() {}

There is a library to help with page boundary issues with multi byte writes GitHub - JChristensen/extEEPROM: Arduino library to support external I2C EEPROMs.
You may want to take a look at it, but writing single bytes using Wire.h can do everything at the cost of some speed for large writes.

The DS18B20 is not I2C. It is Onewire. You will have to assign the DS18B20 to a different pin than the I2C pins. But there's a library you can use to communicate with them.

Pete

I've done some research regarding I2C and I get some idea on how to communicate with a module. However, still I cannot understand if I can use a library at the same time! Is it possible to use a library for DS3231 and at the same time communicate with standard I2C commands with AT24C32?

Achileas7:
I've done some research regarding I2C and I get some idea on how to communicate with a module. However, still I cannot understand if I can use a library at the same time! Is it possible to use a library for DS3231 and at the same time communicate with standard I2C commands with AT24C32?

Yes.