Adafruit I2C FRAM Breakout Library (Ported?)

Dear Photon team,

Hope you are all well,

I am trying to connect and control an Adafruit I2C Non-Volatile FRAM Breakout (https://www.adafruit.com/product/1895) using a Particle Photon. I’m not aware of any libraries that have been ported, the original one from Adafruit is https://github.com/adafruit/Adafruit_FRAM_I2C.

I’m happy to learn how to do it myself, but I have never done it before,

If anyone has any experience or knows of a ported library I would appreciate your help,

Thank you,

Sam

@peekay123 Has done this already :smile: I’ll wait on him to tell you where the library is.

@Sammy_Herring, I ported the SPI version of the library but not the I2C version. It is super simple and I will let you know what needs to be done.

@Sammy_Herring, here we go:

In Adafruit_FRAM_I2C.h, replace this section of code:

#if ARDUINO >= 100
 #include <Arduino.h>
#else
 #include <WProgram.h>
#endif

#include <Wire.h>

with:

#include "Particle.h"

In Adafruit_FRAM_I2C.cpp, comment out this line of code:

#include <stdlib.h>

Finally, in the example .ino file, get rid of or comment out this line of code at the top:

#include <Wire.h>

I suggest you power the FRAM board using 3.3v via the Photon’s 3V3 pin. The board already includes I2C pull-up resistors. I also recommend compiling against the latest stable release (0.5.3) or the near-stable 0.6.0-rc.2. Let me know how it works!

2 Likes

@peekay123

Is that replacement code supposed to be blank?

1 Like

Only for .ino files.
In .h and .cpp files there should be a #include "Particle.h"

1 Like

@RWB, no it was not supposed to be blank. I had a missing carriage return on my line which caused the problem. All fixed :wink:

1 Like

Hey Guys,

Thank you for all of your replies,

They have been extremely helpful! I have made the tweaks as suggested and now have a working library for I2C. I have uploaded the code to GitHub (https://github.com/SammyHerring/Adafruit_FRAM-I2C) and added @peekay123, @RWB and @ScruffR as contributors if you want me to link your GitHub accounts to the repo, I’m more than happy to.

Thank you again,

Sam

3 Likes

Sammy,

Thank you for doing this. I am interested in using this library as well. I new to the platform and are moving from the Particle Build to Particle Dev local IDE. To use this library, do I simply add these files to my local project folder? Is there a way to link to the Github repo so I could get updates?

Thank you and sorry for the basic question.

Chip

Yup you can add the library files to your project.

Is the library available in the Libraries for Particle? If that’s the case, you can simply add it to your project using the Desktop IDE.

Kenneth,

No, it is not in the libraries, I was posted to Github by Sammy. I was able to use it by moving to Particle Dev and putting it into a directory under my project.

Thanks, Chip

1 Like

Hi - late to this post I know and my first post here but I have had a good look around and can’t see the answer.

I bought some FRAM breakouts and have been following @chipmc excellent article on ruggedised electron but my FRAM just gives me 0xFF for every byte. My UK supplier thinks its because electron is based on ARM Cortex M3 which is not in supported list, but your system in the park is working fine for Chip.

Anyone else see this or had similar problem - the manuid and product id come back with 0xFF (so fail) as well?.

Thank you for help

@willjgi, Is this in regards to using FRAM with a Particle device? If not, which platform are you using? Which FRAM breakouts did you buy? How do you have it wired? Which library are you using to test?

Hi, thanks @peekay123 and just realised not posted half of what is needed!

I am using the Adafruit I2C FRAM Breakout Board with this library and its example on a particle electron wired to 3.3v vdd, gnd, sca & scl wired to same named pins on electron.

Data flows even though it fails on manuid and prodid.

@willjgi, first thing I would do is run an I2C bus scanner app to validate the device addresses:

If necessary, you can then adjust the library for the correct address. Can you confirm that the FRAM on the board is the Fujitsu MB85RC256V?

@peekay123 I will run the scanner (and try FRAM on an arduino as well) thx, this thread has also made me think I should be using your ported library rather than the one linked? I had used Chips Cellular logger firmware but that failed also.
Will run tests and report, it is the Fujitsu MB85RC256V.

1 Like

I’ve used the Adafruit FRAM with the Photon. I wrote a library for it as well

The instructions are here and the library is MB85RC256V-FRAM-RK in the community libraries.

3 Likes

Thanks @rickkas7 will try those as well - that should flush out something for sure! Can’t believe I hadn’t seen your lib earlier.

Will let you know how it goes.

Hi - I’ve run these sketches on electron and arduino mega with following output - I reckon my FRAM is not OK:

MB85RC256V-FRAM-RK:

on electron:

d1=536994573
addr=4, intVal=134503503, sizeof(int)=4
addr=8, doubleVal=0.000000, sizeof(doubleVal)=8
addr=16, str=Aeneus corydora, sizeof(stringBuf)=16
next fish name=Aeneus corydoras
addr=32, a=0 b=0.000000 c=0, sizeof(data)=12

d1=536994573
addr=4, intVal=134503503, sizeof(int)=4
addr=8, doubleVal=0.000000, sizeof(doubleVal)=8
addr=16, str=Aeneus corydora, sizeof(stringBuf)=16
next fish name=Aeneus corydoras
addr=32, a=0 b=0.000000 c=0, sizeof(data)=12

I2CScanner:

On Particle Electron

Scanning…
No I2C devices found

On Arduino Mega:

Scanning…
No I2C devices found

On Arduino Mega using adafruit FRAM Lib

Unexpected Manufacturer ID: 0xFFF
I2C FRAM not identified … check your connections?

Will continue in case this processor doesn’t support repeated start

Restarted 255 times

0x0: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
0x20: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
0x40: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
0x60: 0xFF 0xFF 0xFF 0

etc for 256k!

Do I go back to my FRAM supplier? Thank you

@peekay123 can you point me in the direction of your Adafruit SPI FRAM library please? I can’t seem to find it searching the forum :-/