Hi,
I'm working on a project (but I don't have the setup here at the time), so I'm wondering if I did this correctly - and hopefully one of the helpful people in this forum can guide me in the right direction if I'm wrong.
What I want to do, is to send data (a byte) to an Eeprom, and then I'd like to read from it again. This bit of code is using the Rom as more of a passthrough than a data storage unit. Meaning that what I send to it, should be read initially afterwards.
Can someone please tell me if Im on the right track here? The thing I'm mostly questioning is the part where I read the data from the Eeprom.
void Eeprom(void) {
//Writing data to the Eeprom
Wire.beginTransmission(eeprom); //Calling the Eeprom at the Eeprom address
Wire.write(high); //Telling the Eeprom we want to access the High address
Wire.write(low); //Telling the Eeprom we want to access the Low address
Wire.write(byte(incomingtemp)); //Writing the incoming temp data to Eeprom
//Serial.println(incomingtemp);
Wire.endTransmission(); //Stop transmitting to the Eeprom
delay(500); //Inserting a 500 ms delay
//Reading data from the Eeprom
Wire.beginTransmission(eeprom); //Calling the Eeprom again
Wire.write(high); //Telling the Eeprom we want to access the High address
Wire.write(low); //Telling the Eeprom we want to access the Low address
Wire.endTransmission(); //Ending transmission with the Eeprom
char readdata = Wire.requestFrom(eeprom, 1); //Requesting one byte from the Eeprom address
Serial.println(readdata);
delay(500); //Inserting a 500 ms delay
shelf++; //Count "shelf" one up
if (shelf > 255) shelf = 0; //When "shelf" 255 is reached, reset "shelf"
//and start writing to/reading from address 0 again
if (low == 255) high++; //If low address reaches 255, count high address 1 up
low++; //Count low address one up to prepare for next writing/reading
}//eeprom