Hello, everyone
I got a UART for I2C module and wanted to try to program this with two Arduinos. So an Uno connected to the SC16IS750 via I2C and the SC16IS750 via RX / TX to a second Arduino Uno. I used the SC16IS750.h library and tried to exchange data using the example sketch. But this doesn't work.
I connected the module directly to the Arduino because the pins are tolerant up to 5.5V. But what I suspect, are the I2C and RX / TX pins still controlled with 3.3V? Then do I have to use a LevelConverter?
But apart from that, should I see any data on the Uno that is being received, even if the voltage level is not the same, right? Has anyone ever experimented with that part?
What I also saw that the module can only pack up to 64 bytes in the buffer. How can you send the data in such a way that the buffer never overflows and everything arrives?
Here are the codes:
/*Arduino 1 has the SC16IS750 connected on SDA/SCL
*TX/RX of the SC16IS750 is connected to Arduino 2
*VCC/GND
*I2C of the SC16IS750 is connected to VCC
*A0 and A1 of the SC16IS750 is connected as shown in the address table below
*/
#include <Wire.h>
#include <SC16IS750.h>
SC16IS750 i2cuart = SC16IS750(SC16IS750_PROTOCOL_I2C,SC16IS750_ADDRESS_AA); /*Address table: A1 A0 Address
VDD VDD 0x90 => AA
VDD GND 0x92 => AB
VDD SCL 0x94 => AC
VDD SDA 0x96 => AD
GND VDD 0x98 => BA
GND GND 0x9A => BB
GND SCL 0x9C => BC
GND SDA 0x9E => BD
SCL VDD 0xA0 => CA
SCL GND 0xA2 => CB
SCL SCL 0xA4 => CC
SCL SDA 0xA6 => CD
SDA VDD 0xA8 => DA
SDA GND 0xAA => DB
SDA SCL 0xAC => DC
SDA SDA 0xAE => DD
*/
int x = 0;
int y = 20;
int z = 300;
int A = 0;
int B = 0;
int C = 0;
char var;
void setup() {
Serial.begin(38400);
i2cuart.begin(9600);
}
void loop() {
x = x + 1;
i2cuart.write('X');
i2cuart.write(x);
i2cuart.write('Y');
i2cuart.write(y);
i2cuart.write('Z');
i2cuart.write(z);
while(i2cuart.available() > 0){
var = i2cuart.read();
switch(var){
case 'A' : A = i2cuart.read();
A |= i2cuart.read() << 8;
Serial.print("A = ");
Serial.println(A);
break;
case 'B' : B = i2cuart.read();
B |= i2cuart.read() << 8;
Serial.print("B = ");
Serial.println(B);
break;
case 'C' : C = i2cuart.read();
C |= i2cuart.read() << 8;
Serial.print("C = ");
Serial.println(C);
break;
}
}
}
/*Arduino 2 has the SC16IS750 connected on TX/RX
*/
int a = 0;
int b = 152;
int c = 1200;
char var;
void setup() {
Serial.begin(9600);
}
void loop() {
a = a + 1;
Serial.write('A');
Serial.write(a);
Serial.write('B');
Serial.write(b);
Serial.write('C');
Serial.write(c);
while(Serial.available() > 0){
var = Serial.read();
switch(var){
case 'X' : Serial.print("X = ");
Serial.println(Serial.parseInt());
Serial.flush();
break;
case 'Y' : Serial.print("Y = ");
Serial.println(Serial.parseInt());
Serial.flush();
break;
case 'Z' : Serial.print("Z = ");
Serial.println(Serial.parseInt());
Serial.flush();
break;
}
}
}
Bally