We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello, after successfully talking to 3 MCP23017 IO expanders on the I2C bus of my RPi3, i went on to explore the world of external storage, specifically the 24LC256. I've been using the processing.io library, but i've had no luck in correct reading/writing of data onto the chip. Can this be done with this library or do i need to get to lower level wiring library stuff? I'm not really that experienced with the datasheet commands reading,
here's that piece of code so far :
import processing.io.*;
I2C compass;
void setup() {
compass = new I2C(I2C.list()[0]);
compass.beginTransmission(0x51);
compass.write(0x00);
compass.write(0x00);
compass.endTransmission();
delay(100);
compass.beginTransmission(0x51);
compass.write(0x00);
byte[] in = compass.read(1);
println(in);
}
and the result i get from this is 0x30 instead of 0x00...
any help would be much appreciated!! Vangelis
P.S. yes using i2cdetect shows me the eeprom being on the 0x51 address :D
Answers
Very technical question... not sure how much feedback you will get. I can suggest exploring the source code of the lib in GitHub. That is, if you want to put that extra effort and learn about the commands and function call structure and the actual library design. I think that could help. Don't forget to post in stackoverflow and if you do, you can cross-link your posts. Good luck!
Kf
Lesson learned :D I tried to do the same thing with an arduino a few months back, i ended up reading and writing to an SD card building my own file system, took a lot of effort to build and i guess it's not worth it, i guess i'm better off using a usb memory stick and saving my stuff there (i really want a read-only fs on the pi!)
thank you for your answer kfajer!
@vargos21
What about the following?
@vargos21 Does this actually work? (I haven't even compile-tested)
EXCELLENT as always gohai thank you! what would this world be without you!! :)
not only did it work, but it also allows me to write more than one byte at a time (so writing a whole 64byte page will be faster than one-by-one byte :D )
here's my sample code (gohai's general answer works perfectly!)
and the result of the code was:
thanks again! )))