Reading from FT24C16A EEPROM

Hi,

I'm trying to get a reading from blood pressure machine that uses FT24C16A EEPROM. I've connected all the necessary pins from the FT24C16A to Arduino UNO and successfully got a reading from the I2C interface, but the data that came out doesn't match the reading on the machine.

Here is the code I'm using:

#include <Wire.h> 
int sys,dias,bpm;
bool bPrint=0;
int count,countT;
char buff[30];

void setup()
{
  Wire.begin(0x50);             // join i2c bus with address #4
  Wire.onReceive(receiveEvent); // register event
  Serial.begin(9600);           // start serial for output
}

void loop()
{
}

void receiveEvent(int howMany)
{
  while(0 < Wire.available()) // loop through all but the last
  {
    char c=Wire.read(); // receive byte as a character
    int ic=c;
    Serial.println(ic);    
    if(countT<4) {
      if(c=='A'){
        countT=1;
      }
      if(c=='9') {
        countT++;
      }
      if(c=='1') {
        countT++;
      }
      if(c=='0') {
        countT++;
      }
    } else if (countT==4) {
      //Serial.write(c);
      if (count==0) {
        sys=c;
      } else if (count==1) {
        dias=c;
      } else {
        bpm=c;
      }
      count++;
      if (count==3) {
        Serial.println("");
        sprintf(buff,"sys:%d, dias:%d, bpm:%d",sys,dias,bpm);
        Serial.println(buff);
        countT=0;
        count=0;
      }
    }
  }
}

Your FT24C16A is a I2c slave device, it doesn't initialize the connection itself.
So using the onReceive() callback is incorrect in your case.

Additionally, you try to read the data completely wrong way. You set the device address (0x50) only, but not to set the data address inside the device and not indicate, how many bytes you want to read from it.

Below is an example of reading len data bytes to data buffer from the cell address:

  byte data[len] = {0};
  Wire.beginTransmission(0x50);
  Wire.write(address);
  Wire.endTransmission(false);
  Wire.requestFrom(0x50,len);
  for (int rc=0, byte* p=(byte*)data; Wire.available() && rc < len; rc++, p++) {
    *p=Wire.read();
  }
1 Like

I have tried that method also, but the machine would froze every time I feed Wire.write() instructions to it, is there any other methods to accomplish this without issuing the write() instruction?

Are you trying to read the memory while the device is in operation???

No, before reading data you have to inform the chip what data cell you want to read. The only method doing this is usung the write().

If your project froze while wire.write() - it means that something definitely wrong with your schematic or your code.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.