Hello!
I am trying to build a datalogger using arduinos and have reached a point where I need to use more than one (in short, there are 7 analog inputs, 5 hall effect inputs (4 of which unfortunately have to come from an analog channel) as well as a G-meter and hopefully a GPS unit all to be written on an SD card)
So far I have gotten the analog, hall effect and G-meters to work independently (which is not much of a feat, I know) but now is the time to piece of all these together.
Which brings me to my problem.
I do not understand how Arduino i2c works in sending data to/from each other.
I understand how the S&M relationship works (har har!) but I do not understand how the data set that is receiving a byte becomes a char, and how to change that.
I refer to this tutorial:
If I understood correctly, the receiving Arduino does not care about what datatype was transmitted, it cares what it was told the data type to be (?)
If that is the case, why does something like this not work:
void requestEvent() {
Wire.write(analogRead(A0));
}
Rather than this code: (which works):
void requestEvent() {
Wire.write("123");
}
This comes from the fact that the transmission is done by first sending "1", then "2" then "3" rather than "123" is that right ?
The end result that I really want is to get the slave arduinos to create and send a string of their collected values (from hall or analog or g-meter) into the master as ready formatted comma separated text so the master can combine these into one ready made csv file
ie:
arduino1 gathers its anlog into: "data0,data1,data2," transmits this when asked for, arduino2 does the same "data3,data4,data5," so the master collects this into "data0,data1,data2,data3,data4,data5,data6,etc"
Sorry for rambling and I hope you can steer me in the right direction.
Thanks.