Comments (13)
Thanks for the issue, if time permits I will try to investigate this weekend.
from fram_i2c.
Thanks, enjoy your weekend!
from fram_i2c.
At least one problem is in this line
if (!fram.begin(0x50, &I2CFRAM)) {
as there exist no begin function with these parameter type. So think that explains it.
I've written a minimal sketch based on your snippet. Can you give it a try?
#include "Arduino.h"
#include "FRAM.h"
#define I2C_SDA 21
#define I2C_SCL 22
// FRAM Memory
#define I2C_SDA_2 16
#define I2C_SCL_2 17
#define I2C_Freq 100000
// I2C1
TwoWire I2CPower = TwoWire(0);
// I2C2 for FRAM sensor
TwoWire I2CFRAM = TwoWire(1);
FRAM fram(&I2CFRAM); // <<<<<<<<<<<<<<<<<<<<<<<
void setup()
{
Serial.begin(115200);
Serial.print("FRAM_LIB_VERSION: ");
Serial.println(FRAM_LIB_VERSION);
// Start I2C communication
I2CPower.begin(I2C_SDA, I2C_SCL, I2C_Freq);
I2CFRAM.begin(I2C_SDA_2, I2C_SCL_2, I2C_Freq);
// You might need to change the FRAM I2C address, in our case it's 0x50
if (!fram.begin(0x50)) // <<<<<<<<<<<<<<<<<<<<<<<
{
Serial.println("Could not find a valid FRAM sensor, check wiring!");
while (1);
}
Serial.print("ManufacturerID: ");
Serial.println(fram.getManufacturerID());
Serial.print(" ProductID: ");
Serial.println(fram.getProductID());
Serial.print(" memory KB: ");
Serial.println(fram.getSize());
}
void loop()
{
}
// -- END OF FILE --
Should print something like
ManufacturerID: 10
ProductID: 1296
memory size: 32
from fram_i2c.
FYI, I created a develop branch which fixes another issue - no relation to yours -
from fram_i2c.
Thanks, I tried to upload this sketch but its hanging on: I2CFRAM.begin(I2C_SDA_2, I2C_SCL_2, I2C_Freq);
Gives me the next errors:
C:\Users\..\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.4\libraries\Wire\src/Wire.h:79:10: note: candidate: 'bool TwoWire::begin(int, int, uint32_t)'
bool begin(int sda=-1, int scl=-1, uint32_t frequency=0); // returns true, if successful init of i2c bus
^~~~~
C:\Users\..\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.4\libraries\Wire\src/Wire.h:80:10: note: candidate: 'bool TwoWire::begin(uint8_t, int, int, uint32_t)'
bool begin(uint8_t slaveAddr, int sda=-1, int scl=-1, uint32_t frequency=0);
^~~~~
exit status 1
call of overloaded 'begin(int, int, int)' is ambiguous
from fram_i2c.
I2CFRAM.begin(I2C_SDA_2, I2C_SCL_2, I2C_Freq);
is outside the library context, but still.
What is happening is that the compiler cannot decide which of the two versions of the begin() function to use.
What the compiler is missing is type information of the parameters. #define does not make the type explicit.
So better use const int or const uint32_t (32 bits unsigned integer) to give the compiler the info it needs.
Try this.
#include "Arduino.h"
#include "FRAM.h"
const int I2C_SDA = 21;
const int I2C_SCL = 22;
// FRAM Memory
const int I2C_SDA_2 = 16;
const int I2C_SCL_2 = 17;
const uint32_t I2C_Freq = 100000;
// I2C1
TwoWire I2CPower = TwoWire(0);
// I2C2 for FRAM sensor
TwoWire I2CFRAM = TwoWire(1);
FRAM fram(&I2CFRAM); // <<<<<<<<<<<<<<<<<<<<<<<
void setup()
{
Serial.begin(115200);
Serial.print("FRAM_LIB_VERSION: ");
Serial.println(FRAM_LIB_VERSION);
// Start I2C communication
I2CPower.begin(I2C_SDA, I2C_SCL, I2C_Freq);
I2CFRAM.begin(I2C_SDA_2, I2C_SCL_2, I2C_Freq);
// You might need to change the FRAM I2C address, in our case it's 0x50
if (!fram.begin(0x50)) // <<<<<<<<<<<<<<<<<<<<<<<
{
Serial.println("Could not find a valid FRAM sensor, check wiring!");
while (1);
}
Serial.print("ManufacturerID: ");
Serial.println(fram.getManufacturerID());
Serial.print(" ProductID: ");
Serial.println(fram.getProductID());
Serial.print(" memory KB: ");
Serial.println(fram.getSize());
}
void loop()
{
}
// -- END OF FILE --
Note: you can use markdown syntax to enhance your posts - see https://www.markdownguide.org/cheat-sheet/
(having a lunch now, back later this afternoon)
from fram_i2c.
Now it compiled, and give me the next message in the serial monitor:
FRAM_LIB_VERSION: 0.4.0
Could not find a valid FRAM sensor, check wiring!
That seems strange to me, the first line gives the version number, so it looks that the FRAM memory is responding.
But it stops at the second line, the adres of the fram module is right, I tried your example files and that worked correctly.
By the way, thanks for your time!
from fram_i2c.
The first line only shows the version of the library.
It is the second line or so after setup()
Unfortunately I have no FRAM module nearby to replicate your hardware setup, but OK.
- the examples work
- fram = ok
- wiring is ok
- address is correct
Lets check what the function begin() returns
Can you try
#include "Arduino.h"
#include "FRAM.h"
const int I2C_SDA = 21;
const int I2C_SCL = 22;
// FRAM Memory
const int I2C_SDA_2 = 16;
const int I2C_SCL_2 = 17;
const uint32_t I2C_Freq = 100000;
// I2C1
TwoWire I2CPower = TwoWire(0);
// I2C2 for FRAM sensor
TwoWire I2CFRAM = TwoWire(1);
FRAM fram(&I2CFRAM); // <<<<<<<<<<<<<<<<<<<<<<<
void setup()
{
Serial.begin(115200);
Serial.print("FRAM_LIB_VERSION: ");
Serial.println(FRAM_LIB_VERSION);
// Start I2C communication
I2CPower.begin(I2C_SDA, I2C_SCL, I2C_Freq);
I2CFRAM.begin(I2C_SDA_2, I2C_SCL_2, I2C_Freq);
// You might need to change the FRAM I2C address, in our case it's 0x50
int x = fram.begin(0x50);
Serial.println(x, HEX);
Serial.print("ManufacturerID: ");
Serial.println(fram.getManufacturerID());
Serial.print(" ProductID: ");
Serial.println(fram.getProductID());
Serial.print(" memory KB: ");
Serial.println(fram.getSize());
}
void loop()
{
}
from fram_i2c.
As the examples all work with the 1st I2C bus, it does not tell anything yet about the 2nd I2C bus.
- are you sure that SDA and SCL are correct - not swapped?
Lets try to check if the pins 16 and 17 work for "Wire0"
#include "Arduino.h"
#include "FRAM.h"
// FRAM Memory
const int I2C_SDA_2 = 16;
const int I2C_SCL_2 = 17;
const uint32_t I2C_Freq = 100000;
TwoWire I2CFRAM = TwoWire(0);
FRAM fram(&I2CFRAM);
void setup()
{
Serial.begin(115200);
Serial.print("FRAM_LIB_VERSION: ");
Serial.println(FRAM_LIB_VERSION);
// Start I2C communication
I2CFRAM.begin(I2C_SDA_2, I2C_SCL_2, I2C_Freq);
// You might need to change the FRAM I2C address, in our case it's 0x50
int x = fram.begin(0x50);
Serial.println(x, HEX);
Serial.print("ManufacturerID: ");
Serial.println(fram.getManufacturerID());
Serial.print(" ProductID: ");
Serial.println(fram.getProductID());
Serial.print(" memory KB: ");
Serial.println(fram.getSize());
}
void loop()
{
}
from fram_i2c.
Backgrounder: https://randomnerdtutorials.com/esp32-i2c-communication-arduino-ide/
from fram_i2c.
Thanks, the last code works! I've read the (backgrounder) link above and tried to figure it out myself with that information before I asked here. I complemented the code in my final code and it works correctly.
from fram_i2c.
the last code works!
OK, means the pins work.
I complemented the code in my final code and it works correctly.
So you use only one I2C bus, OK
If your problem is solved, you may close the issue.
from fram_i2c.
I use now two I2C, the first part allready worked, I replaced the code:
// You might need to change the FRAM I2C address, in our case it's 0x50
if (!fram.begin(0x50)) // <<<<<<<<<<<<<<<<<<<<<<<
{
Serial.println("Could not find a valid FRAM sensor, check wiring!");
while (1);
}
by
// You might need to change the FRAM I2C address, in our case it's 0x50
int x = fram.begin(0x50);
Serial.println(x, HEX);
from fram_i2c.
Related Issues (17)
- getSize returns wrong value HOT 8
- add readObject, writeObject APIs HOT 6
- Add clear() function HOT 1
- sleep mode HOT 24
- memory addressing for MB85RC1MT HOT 47
- interface for ESP32 is lacking
- Ringbuffer HOT 18
- failing to write a float value, but don't know why HOT 15
- Issues with FRAM's that use Page Addressing HOT 15
- [Wish] - read back logging HOT 37
- esphome port or I2C/GPIO abstraction HOT 16
- [Question] Begin after deepsleep produces an error HOT 5
- MB85RC04 FRAM9 HOT 27
- Support for Additional FRAM Devices and Addressing Modes HOT 2
- Error by reading internal Metadata HOT 3
- Stewrat HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fram_i2c.