So, I would like to send data from one arduino to another.
I set on using 12c and the wire library.
For that to work, i understand the datatypes sent / received need to be in bytes.
OK, so be it, seems reasonable request
But for some reason (which is probably very basic) when I change my data types I get odd math.
byte hall1 = 5;
byte rev = 0;
void setup() {
 // put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
 // put your main code here, to run repeatedly:
rev = (hall1*60);
Serial.println(rev);
}
For some reason, this sketch returns "44" whereas running the same code with int data type returns 300. Which you would expect.
Perhaps this may help
I2C protocol is 8 bits - usually.
To take advantage of both I2C and ASCII protocol your "data" should be represented as ASCII code AKA 7 bits.
For example numerical data "100" should be converted to ASCII code and transferred as hex 31 30 30 AKA three ASCII characters 1 0 0.
Since you do not transfer binary representation of your data as 8 bits word you have means to detect and even correct errors caused by noisy transmission media.
Never mind the "limits of data type " - immaterial trivia in this case.