Introduction: Arduino I²C™ EEPROM BYTEBANGER
Recently I became intrigued with I²C EEProms after salvaging some from an old rear projection TV I was scrapping out.
I scoured the internet trying to find more information about them- such as Datasheets, & Tutorials on how these things worked and could be used. Surprisingly, the information was scattered and somewhat scarce... datasheets were fairly easy to find, and there are a few tutorials (including videos) that show some very basic ways to access the eeproms functionality. I was still not satisfied for what I wanted to do, so I decided to setup my breadboard and write my own code, along with a couple of Arduino libraries... and The I²C™ EEPROM BYTEBANGER was born!
The tutorials I found lacked some things that I wanted to do, such as read and write data from and to the eeprom more than just one byte at a time. I also wanted to have the option to dump the eeprom data to an SD card, as well as load a CSV file from the SD card and re-program the eeprom.
Adding some data manipulation functions and control settings to the code really rounded out what I believe is a very nice Arduino application that you will enjoy! Surprisingly, the supplies you need are few... writing the code was the hard part... which is good news for you since that is provided here for you to download.
I wanted to make sure I could do all of this using an Arduino UNO since that still seems to be a very popular micro-controller, and my thoughts were "if it works on an UNO, then it should work on anything" which is probably true by changing the code slightly for your specific micro-controller.
You will need:
an Arduino UNO R3 with USB cable
at least 1 (and up to 8) I²C EEProms
an SD Card module
a speaker or piezo buzzer (optional)
some hookup wire
Step 1: Schematic
Use the above Fritzing schematic and photos as a guide to hook up your eeprom(s), SD Module, and optional speaker.
I found it was best to start with the eeproms.
Put them on the breadboard as shown, paying attention to the spacing between eeproms.
Check the datasheet for your specific eeprom but I've found that most of the I²C PDIP8 eeproms have the same pinout:
Pins 1-3 are the Address settings for the eeprom.
Pin 4 is connected to ground.
Pin 5 is SDA (data) which connects to the UNO SDA pin
Pin 6 is SCL (clock) which connects to the UNO SCL pin
Pin 7 is WP (Write Protect) which is connected to ground
Pin 8 is VCC connected to +5v
I found it easiest to start by adding the VCC and ground wires to each eeprom first. (if you are only using one eeprom this is super easy!)
Next wire the SDA lines and the SCL lines to the I²C bus.
Since we can address up to 8 eeproms on the I²C bus we will tie all of the SDA lines together and likewise with the SCL lines. If you notice in the photo, I used an additional power rail as the I²C bus. If you do not have an extra rail, you can just follow the Fritzing schematic.
Now tie all the WP (pin7) to ground.
We want to be able to write to the eeprom after-all... and don't worry, there is a SAFEMODE function in the code that we can use to emulate the Write Protect function.
Now we will hookup the SD Module...
Step 2: SD Module
Your SD Module may be slightly different from the one I used, but they are all basically the same. (You could even use a micro SD card adapter by itself... but that's a future project)
Looking at the pins on the SD Module from left to right they are:
CS- Chip Select
SCK- Serial Clock
MOSI- Master Out/Slave In
MISO- Master In/ Slave Out
3.3 (not used)
Connect CS to UNO pin 8
Connect SCK to UNO pin 13
Connect MOSI to UNO pin 11
Connect MISO to UNO pin 12
Step 3: Connect the Speaker
The Speaker or Piezo buzzer is completely optional.
Connect the Speaker to ground and UNO pin 7.
The code uses some sound functions, but not imperative for operation. (in fact sometimes I unplug the speaker when I don't want to hear the sound. You could setup a switch too.)
Step 4: Connect the UNO Power & Upload the Code
Connect the ground and +5v from the UNO to your breadboard power rails.
DON'T FORGET TO TIE YOUR TOP AND BOTTOM POWER AND GROUND RAILS TOGETHER!
Now just plug your UNO into your computer and upload the code!
The I²C EEPROM BYTEBANGER code is quite extensive and I will be doing a video tutorial series on all of the features, but it is also fairly well annotated with comments.
I welcome you to subscribe to my YouTube Channel where you can soon find the video tutorials, as well as more projects to come.
Participated in the
Arduino Contest 2019