Characteristic Locus
Inheritance System.Object > AT24Cxx
Inherited Members System.Object.ToString() System.Object.Equals(System.Object) System.Object.Equals(System.Object, System.Object) System.Object.ReferenceEquals(System.Object, System.Object) System.Object.GetHashCode() System.Object.GetType() System.Object.MemberwiseClone()
Namespace Meadow.Foundation.ICs.EEPROM
Assembly AT24Cxx.dll

Syntax

public class AT24Cxx

Remarks

The AT24Cxx series of chips provide a mechanism for storing data that will survive a power outage or battery failure. These EEPROMs are available in varying sizes and are accessible using the I2C interface.

Examples

The following example shows how to turn on and off the LED using the IsOn property, and uses a StartBlink(onDuration, offDuration) API method to make the LED blink staying on for 500ms (0.5s) and off for 1000ms (1s):

using System.Threading;
using Meadow;
using Meadow.Foundation.ICs.EEPROM;

namespace LedSample
{
    public class Program
    {
        static IApp _app; 
        public static void Main()
        {
            _app = new App();
        }
    }

    public class App : AppBase<F7Micro, App>
    {
        public App ()
        {
            var eeprom = new AT24Cxx(0x57);

            var memory = eeprom.Read(0, 16);
            for (ushort index = 0; index < 16; index++)
                Console.WriteLine("Byte: " + index + ", Value: " + memory[index]);

            eeprom.Write(3, new byte[] { 10 });
            eeprom.Write(7, new byte[] { 1, 2, 3, 4 });

            memory = eeprom.Read(0, 16);
            for (ushort index = 0; index < 16; index++)
                Console.WriteLine("Byte: " + index + ", Value: " + memory[index]);


            Thread.Sleep(Timeout.Infinite);
        }
    }
}
Example Circuit

The chip used to develop this library is one that is available on a common DS3231 RTC module with EEPROM memory module:

Constructors

View Source

AT24Cxx(II2cBus, Byte, UInt16, UInt16)

Create a new AT24Cxx object using the default parameters for the component.

Declaration
public AT24Cxx(II2cBus i2cBus, byte address = 80, ushort pageSize = 32, ushort memorySize = 8192)

Parameters

Type Name Description
II2cBus i2cBus
System.Byte address

Address of the MAG3110 (default = 0x50).

System.UInt16 pageSize

Number of bytes in a page (default = 32 - AT24C32).

System.UInt16 memorySize

Total number of bytes in the EEPROM (default = 8192 - AT24C32).

Methods

View Source

Read(UInt16, UInt16)

Force the sensor to make a reading and update the relevanyt properties.

Declaration
public byte[] Read(ushort startAddress, ushort amount)

Parameters

Type Name Description
System.UInt16 startAddress

Start address for the read operation.

System.UInt16 amount

Amount of data to read from the EEPROM.

Returns

Type Description
System.Byte[]
View Source

Write(UInt16, Byte[])

Write a number of bytes to the EEPROM.

Declaration
public void Write(ushort startAddress, byte[] data)

Parameters

Type Name Description
System.UInt16 startAddress

Address of he first byte to be written.

System.Byte[] data

Data to be written to the EEPROM.