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
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