Cannot get I2C communication to raspberry pi to work
LordSyd opened this issue · 2 comments
I tried connecting the RP using the following Arduino code:
`
#include <Wire.h>
void setup()
{
Wire.begin(11); // join i2c bus with address #11
Wire.onReceive(receiveEvent); // register event
Serial.begin(115200); // start serial for output
}
String msg = "";
boolean reset = false;
char current;
char previous;
void loop()
{
}
void receiveEvent(int howMany)
{
//msg = "";
while(Wire.available())
{
char current = Wire.read();
msg += current;
//Serial.println("current: " + String(current) + " pre: " + String(previous));
if(current == ';' && previous == ';'){
//Serial.println("c == 10");
//msg = "";
reset = true;
//break;
}
previous = current;
}
if(reset == true){
Serial.println(msg);
msg = "";
reset = false;
}
}`
On a standard Arduino, this works, but the opencr board does not get recognised as an i2c device. I looked at the libraries in the repository, trying to make sense of them, but I had to give up. Sadly this functionality is also not documented in the e-manual.
What methods and libraries do I need to use to establish an i2c connection with the board?
Regards,
Daniel
Hi,
I found a few threads regarding low-level I2c implementations. Not sure if I stumbled upon this one. The problem is that the project I am working on has a tight deadline, so playing around with native Stm32 functions is not an option. I know a bit about programming the MC directly, but not enough to get a working connection in the allotted timeframe (around two weeks from the time of writing and many other things to take care of). I hoped I could use the library just as I would with a "normal" Arduino, but that does not seem to be the case.
To be clear, is I2C support even something that should be available? Because I was a little bit confused about not finding any reference to it in the official e-manual.
If messing around with HAL or the Lower Layer of the Stm32 MC is the only way to get I2C working, I will have to move on for now and use an Arduino.