Conectar Wemos D1 a EEPROM 24LCXX


En este post doy una guía estructurada con el paso a paso explicando cómo conectar el Wemos D1 con la EEPROM 24LC256 usando la librería Sparkfun

Conectar Wemos D1 a EEPROM 24LCXX
oscar Escrito por oscar 25 June 2025 561 0

En este post doy una guía estructurada con el paso a paso explicando cómo conectar el WEMOS D1 con la EEPROM 24LCXX usando la librería sparkfun external eeprom.

Esta configuración te permitirá almacenar y recuperar datos de forma no volátil, ideal para configuraciones, cualquier información que deba mantenerse al apagar el dispositivo.

La EEPROM 24LCXX es una memoria no volátil I²C que permite guardar datos incluso después de apagar el microcontrolador. En este ejemplo.

Prerrequisitos

Wemos D1

Pines wemos d1
Pines wemos d1

 

Pines Wemos D1 mini
Pines Wemos D1 mini

EEPROM 24LCXX

A continuación, mencionamos las principales características de las memorias EEPROM, para este post vamos a usar una memoria 24LC256, aunque si va a trabajar con otra memoria de la familia 24LCXX, la conexion es la misma.

EEPROM 24LCXX
EEPROM 24LCXX

📦 Materiales necesarios

Componente Cantidad
ESP32 1
EEPROM 24LC256  1
Resistencias 10kΩ (Pull-up) 2
Cables dupont Varios
Protoboard

🔌 Conexión entre Wemos D1 Mini y EEPROM 24LC256

La 24LC256 se comunica mediante I²C, por lo tanto usaremos los pines SDA y SCL del Wemos D1 Mini.

EEPROM 24LC256 Wemos D1 Mini Descripción
VCC 3V3 Alimentación 3.3V
GND G Tierra
SDA D2 (GPIO4) Datos I²C
SCL D1 (GPIO5) Reloj I²C
WP GND Desactivar protección contra escritura
A0, A1, A2 GND (todos) Dirección I²C = 0x50

⚠️ No olvides conectar resistencias pull-up de 10kΩ entre SDA y VCC, y entre SCL y VCC.

Conexión wemos d1 eeprom 24LCXX
Conexión wemos d1 eeprom 24LCXX
Conexión wemos d1 24LCxx
Conexión wemos d1 24LCxx

🧰 Instalación de la librería SparkFun_External_EEPROM

💻 Código de ejemplo: Escribir y leer en la EEPROM

#include <Wire.h>

#include "SparkFun_External_EEPROM.h"
ExternalEEPROM myMem;

void setup()
{
  Serial.begin(115200);
  Serial.println("EEPROM example");

  Wire.begin();

  myMem.setMemoryType(512);

  if (myMem.begin() == false)
  {
    Serial.println("No memory detected. Freezing.");
    while (true)
      ;
  }
  Serial.println("Memory detected!");

  Serial.print("Mem size in bytes: ");
  Serial.println(myMem.length());

  byte myValue1 = 200;
  myMem.write(0, myValue1);

  byte myRead1 = myMem.read(0);
  Serial.print("I read (should be 200): ");
  Serial.println(myRead1);

  int myValue2 = -366;
  myMem.put(10, myValue2);
  int myRead2;
  myMem.get(10, myRead2);
  Serial.print("I read (should be -366): ");
  Serial.println(myRead2);

  float myValue3 = -7.35;
  myMem.put(20, myValue3);
  float myRead3;
  myMem.get(20, myRead3);
  Serial.print("I read (should be -7.35): ");
  Serial.println(myRead3);

  String myString = "Hi, I am just a simple test string";
  unsigned long nextEEPROMLocation = myMem.putString(30, myString);
  String myRead4 = "";
  myMem.getString(30, myRead4);
  Serial.print("I read: ");
  Serial.println(myRead4);
  Serial.print("Next available EEPROM location: ");
  Serial.println(nextEEPROMLocation);
}

void loop()
{
}

🔍 Explicación del código

✍️ Escritura y Lectura de Datos

✅ Escribir/Leer un byte:

✅ Escribir/Leer un int:

int myValue2 = -366;
myMem.put(10, myValue2);
int myRead2;
myMem.get(10, myRead2);
Serial.print("I read (should be -366): ");
Serial.println(myRead2);

Usa internamente memcpy() para dividirlo en bytes y almacenarlo.

✅ Escribir/Leer un float:

float myValue3 = -7.35;
myMem.put(20, myValue3);
float myRead3;
myMem.get(20, myRead3);
Serial.print("I read (should be -7.35): ");
Serial.println(myRead3);

✅ Escribir/Leer una String:

🧪 Verificando funcionamiento

  1. Conecta tu ESP32 y sube el código.
  2. Abre el monitor serial a 115200 baudios.
  3. Deberías ver el mensaje: 
Memory detected!
Mem size in bytes: 65536
I read (should be 200): 200
I read (should be -366): -366
I read (should be -7.35): -7.35
I read: Hi, I am just a simple test string
Next available EEPROM location: 65

 


Comentario

Debe aceptar antes de enviar