Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

How To Save A Text In The EEPROM Of The Arduino- (Part 21/49)

By Ajish Alfred October 16, 2013

A microcontroller might need to store its data like sensor value, or a particular count or image data for a long period of time. The most common type of memory used with the microcontroller based systems is EEPROM. The EEPROM stands for Electrically Erasable Programmable Read Only Memory which is a kind of Read Only Memory (ROM), which can be written and erased by means of electrically programming and hence the name. Once programmed the data it will remain in the memory for a very long time even if there is no power available. EEPROM memory is widely used in microcontroller systems where some particular data need to be retained each time the system is turned on and to save particular data before the system is powered off.

There are several EEPROM memory chips available which can be interfaced in a microcontroller based system with the help of serial communication protocols. Most of the microcontrollers also have small sized built-in EEPROM which can be used in small applications and hence the need for an external memory chip, circuit and code complexity can be avoided. The serial communication protocols can be again used with those kinds of microcontrollers to connect the internal EEPROM with other devices or with the serial port of a PC. The size of the data which can be saved in the internal EEPROM of a microcontroller is limited to a few kilobytes normally. Hence they are used to store some sensor values, counts or sometimes text like data from the GPS etc. This particular project demonstrates how to connect the internal EEPROM of the Arduino board with the serial port of a PC and save a text in it which can be read back even after the Arduino is powered off and turned on again. 


 

The size of the EEPROM memory available in the Arduino board varies from one kind of board to another. The arduino board is built around an AVR microcontroller burned with arduino boot-loader providing all the necessary circuitry for the microcontroller to operate. The arduino board used in this project is the arduino pro-mini board which has an ATMEGA328 microcontroller having an internal EEPROM of size 1Kb. The pro-mini board also one set of Tx and Rx pins which can be used to connect the board with serial communication lines. In this project the pro-mini board is programmed using the Arduino IDE version 1.0.3 downloaded for windows.

The image of the Arduino pro-mini board and the Arduino IDE is shown in the following;

Typical Arduino Pro-Mini Board

Fig. 1: Typical Arduino Pro-Mini Board

 

Arduino IDE Software Window

Fig. 2: Arduino IDE Software Window

 

Since the arduino pro-mini board has no circuitary for interfacing it with the serial port or the USB port of the PC, an external USB to TTL converter board is required to connect it with the PC. This hardware helps in programming the arduino board and also helps in the serial communication with the PC through the USB port of the PC.

 External USB To TTL Converter Board For Programming Arduino And Serial Communication

Fig. 3: External USB to TTL converter board for programming Arduino and serial communication

It is assumed that the reader has gone through the project how to get started with the arduino and done all the things discussed in it. The Arduno IDE is very easy to start with and has lot of built in libraries and function for every simple and complex tasks. The Arduino IDE also has a library called <EEPROM.h> which provides functions to access the built-in EEPROM of the Arduino board’s microcontroller. The code written for this project also makes use of few functions from the <EEPROM.h> to read and write the built-in EEPROM. The functions are namely EEPROM.write() and EEPROM.read() and the details of those functions are already discussed in previous projects on how to read and write the EEPROM of the Arduino, how to test the EEPROM of the Arduino and how to save a sensor value in the EEPROM of the Arduino.

The Arduino IDE also provide some built-in functions which helps in the serial communication process. There is a function which helps to initialize the serial communication port with a particular baud rate and there are functions to send data to the serial port and read data from the serial port. The functions used in this projects are namely Serial.begin(), Serial.print(),Serial.println(), Serial.available(),Serial.read() and Serial.write(). The details of these functions and similar functions for the serial communication are already discussed in previous projects on how to do serial communication with the Arduino, how to send and receive serial data using arduino, how to do serial debugging with the Arduino.

The project also displays some text on the LCD with the help of the functions from the library <LiquidCrystal.h>. The important functions provided by the library <LiquidCrystal.h> are already used and explained in previous projects on how to interface an LCD, how to display sensor value on LCD, how to connect the LCD with the PC and how to make an LCD scrolling display.

In this project an LED is connected to the pin number 6 of the Arduino board which serves the purpose of indicating each data byte written by blinking once and also blinking continuously after the EEPROM runs out of memory. The LED is controlled by using the built-in functions of the Arduino IDE namely pinMode(),digitalWrite() and delay() which are discussed in the previous projects on how to get started with the Arduino, how to use digital input and output of the Arduino.

THE CODE

The code written for this project configures the pin number 6 as output pin where an LED indicator is connected using the function pinMode(). The LCD is the initialized using the function lcd.begin() and generates an initial display in the 16*2 LCD screen. The function Serial.begin() is then used to initialize the serial port with a baud rate of 9600. The code then reads the entire EEPROM memory using the function EEPROM.read() and send the data as previously saved text to the serial port using the function Serial.write(). The entire EEPROM memory is then cleared by writing it with white spaces using the function EEPROM.write() before the new text is read into. The code then waits till the user input text data bytes using the function Serial.available(). As the serial data is available it is written to the successive memory locations using the function EEPROM.write() along with blinking an LED connected to the pin number 6 for each data byte written using the function digitalWrite(). Once the EEPROM of the Arduino runs out of memory the LED is blinked continuously using the functions digitalWrite() and delay().

When the coding is finished one can verify and upload the code to the Arduino board as explained in the project how to get started with the Arduino. The Arduino board can then be connected to the PC using USB to TTL converter board and the previous text can be viewed or new text can be typed into using any serial monitoring software or using the Arduino IDE’s serial monitoring software itself as explained in the project how to do serial debugging with the Arduino.

 

 Arduino EEPROM Read Write Circuit Setup On Breadboard

Fig. 4: Arduino EEPROM Read Write Circuit Setup On Breadboard

 

Project Source Code

###




/*================================= EG LABS =======================================

The code for saving a text in the EEPROM and read it back when powered up

 

 The circuit:

 * LED attached from pin 6 to ground through a 1K resistor

 

 LCD:

 * LCD RS pin to digital pin 12

 * LCD Enable pin to digital pin 11

 * LCD D4 pin to digital pin 5

 * LCD D5 pin to digital pin 4

 * LCD D6 pin to digital pin 3

 * LCD D7 pin to digital pin 2

 * LCD R/W pin to ground

 * 10K resistor:

 * ends to +5V and ground

 * wiper to LCD pin 3

 * LED anode attached to digital output 6

 * LED cathode attached to ground through a 1K resistor

//================================= EG LABS =======================================*/



#include <EEPROM.h>

#include <LiquidCrystal.h>


LiquidCrystal lcd(12, 11, 5, 4, 3, 2);               // initialize the LCD library with the numbers of the interface pins

int address = 0;                                     // the variable which holds the address in the eeprom

int read_value = 0;                                  // the variable which holds the data which is read from the eeprom

char serial_in_data;                                 // the variable which holds serial input data

int led = 6;                                         // variable which holds the pin number at which the LED is connected

int i;

void setup()

{

  pinMode(led, OUTPUT);                               // initialize the led pin as an output.

  lcd.begin(16, 2);                                   // set up the LCD's number of columns and rows: 

  lcd.print("ENGINEERS GARAGE");                      

  lcd.setCursor(0, 1);   

  lcd.print(" SERIAL  EEPROM ");

  Serial.begin(9600);                                 // initialize the serial port with baud rate 9600

  Serial.println();

  Serial.println("PREVIOUS TEXT IN EEPROM :-");

  for(address = 0; address < 1024; address ++)        // read the entire EEPROM memory

  {  

    read_value = EEPROM.read(address);

    Serial.write(read_value);

  }

  Serial.println();

  Serial.println("WRITE THE NEW TEXT : ");

  

  for(address = 0; address < 1024; address ++)        // fill the entire eeprom memory with white spaces

    EEPROM.write(address, ' ');                 

  

  for(address = 0; address < 1024; )                  // write the incoming serial data to the EEPROM

  {

    if(Serial.available())

    {

      serial_in_data = Serial.read();  

      Serial.write(serial_in_data); 

      EEPROM.write(address, serial_in_data); 

      address ++;

      digitalWrite(led, HIGH);       

      delay(100);

      digitalWrite(led, LOW);

    }

  }

}


void loop()

{

  //---- blink LED -----//

  digitalWrite(led, HIGH);       

  delay(1000);

  digitalWrite(led, LOW);

  delay(1000);

  //---- blink LED -----//

}

###

 


Circuit Diagrams

Circuit-Diagram-Saving-Text-EEPROM-Arduino

Project Components

  • Arduino Pro Mini
  • LCD
  • LED
  • Resistor

Project Video


Filed Under: Arduino Projects
Tagged With: Arduino, eeprom, text
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: 5G Technology
This Tech Toolbox covers the basics of 5G technology plus a story about how engineers designed and built a prototype DSL router mostly from old cellphone parts. Download this first 5G/wired/wireless communications Tech Toolbox to learn more!

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Resistor Selection for Amplifier Layout
  • Permittivity and Permealibility in CST
  • Testing 5kW Grid Tied inverter over 200-253VAC
  • Single ended measuring ports and balanced antenna
  • Thermal modelling of repetitive power pulse

RSS Electro-Tech-Online.com Discussions

  • Can I make two inputs from one??
  • Beats Solo 4
  • Behlke swich
  • Is AI making embedded software developers more productive?
  • Simple LED Analog Clock Idea

Featured – LoRa/LoRaWan Series

  • What is the LoRaWAN network and how does it work?
  • Understanding LoRa architecture: nodes, gateways, and servers
  • Revolutionizing RF: LoRa applications and advantages
  • How to build a LoRa gateway using Raspberry Pi
  • How LoRa enables long-range communication
  • How communication works between two LoRa end-node devices

Recent Articles

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe