Multiple masters I2C

julianE

Senior Member
Hello, would it be possible to have a picaxe and a raspberry pi sharing an EEPROM. My thinking is to have a picaxe write data to an external EEPROM and then have a raspberry pi retrieve that data at will. I realize they can't both be active at the same time so i would have to have handshaking between Pi and picaxe. Thanks in advance.
 

inglewoodpete

Senior Member
PICAXEs do not really lend themselves to sharing i2c slaves with other masters. You could add an arbitration wire with a pullup resistor between the two masters so that each can test whether the other has control of the slave.

Since the Raspberry Pi is much more sophisticated than the PICAXE, could you set up a serial link between the two and have the Pi buffer and then save the data to the EEPROM?

Perhaps some more information on your project would help us grapple with the problem.
 

lbenson

Senior Member
would it be possible to have a picaxe and a raspberry pi sharing an EEPROM. My thinking is to have a picaxe write data to an external EEPROM and then have a raspberry pi retrieve that data at will
The easiest way would be for the picaxe to be an X2 type, like the 20X2. X2s can be I2C slaves, so the pi can read and write to it as if it were an EEPROM (128 bytes for the 20X2, 256 for 28X2 and 40X2), and the picaxe reads and writes to its scratchpad, which is the same space. See HI2CSETUP.
 

julianE

Senior Member
The easiest way would be for the picaxe to be an X2 type, like the 20X2. X2s can be I2C slaves, so the pi can read and write to it as if it were an EEPROM (128 bytes for the 20X2, 256 for 28X2 and 40X2), and the picaxe reads and writes to its scratchpad, which is the same space. See HI2CSETUP.
Hi lbenson, i have attached a 20X2 the way you mentioned and it works well. I was hoping to transfer much more data. I can transfer it using serial but i was just curious if it can be done with the I2C.
 

PhilHornby

Senior Member
Based on my own experience, I would go with @inglewoodpete's approach.

One of my first projects, was to port a Raspberry Pi project to Picaxe. The Pi used several python scripts running simultaneously, so I thought I'd use a pair of cooperating 20X2's communicating via I²C. The amount of handshaking I ended-up with was ludicrous - it took me longer to port the project, than it had to originally implement it!. One of the things I discovered, is that quite often the 20X2 is not 'readable' via I²C - presumably some of the 'blocking' instructions interfere?

The next time I needed to do something like this, I put one device in charge and communicated between the two of them using serial comms. The 20X2's background serial is quite good for this, but if one of the device's is a Pi, then best to let its O/S do the buffering.
 

julianE

Senior Member
Perhaps some more information on your project would help us grapple with the problem.
Thanks Gents. Project I'm planning is to have a box full of sensors outside of the house and have the picaxe act as a data collector, storing information in an external eeprom. I want everything running on solar/battery so the Pi would only turn on as needed and the picaxe, due to negligible power consumption, can be always on. I can remotely turn on the Pi and get the info from the picaxe and then access the pi through WiFi to get all the information. I have it all sorted out and can get the data using a serial and also program the picaxe remotely using the pi if need arises. I just thought it would be a lark if Pi could just access the EEProm directly. Also, it would not be too difficult to have a switching arrangement to share the EEPROM between the two systems, it's only 2 wires. Just an A/B switcher using CD4066 or even transistors.
 
Top