Hello guys,
im trying to record data sent from an I2C Master (Projet ECU) to a Slave LCD (2x16 LCD, address 0x38).
i would like tp print this data to serial monitor.
so far i managed to get my Arduino to become a Master on the I2C bus instead of the ECU, and display data on the LCD just fine.
but when i try to record the incoming data from the ECU and print it to serial monitor im getting nothing but gibbrish.
this is the code im using.
#include <Wire.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup()
{
Wire.begin(0x38); // join i2c bus with address 0x38
Wire.onReceive(receiveEvent); // register event
Serial.begin(9600); // start serial for output
}
void loop() {
delay(100);
}
// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany) {
while (1 < Wire.available()) { // loop through all but the last
byte c = Wire.read(); // receive byte as a character
Serial.print(c); // print the character
Serial.print("\r");
lcd.print(c);
delay(1000);
// lcd.clear();
}
int x = Wire.read(); // receive byte as an integer
// Serial.println(x); // print the integer
// lcd.print(x);
}
output to serial monitor is:
65
69
65
225
229
128
132
128
0
4
128
132
128
0
4
65
69
65
49
53
128
132
128
0
4
65
69
65
225
229
128
132
128
0
4
128
132
128
0
4
65
69
65
49
53
128
132
128
0
4
65
69
65
225
229
128
132
128
0
4
128
132
128
0
4
can anyone offer assistance please?
thanks.