Transmitting 4 float values from an Arduino Uno to an Arduino Mega


I am trying to capture 4 ultrasonic distance sensor values as float values and transmit them through wire to an Arduino Mega. I used I2C but I could only transmit 1 float value instead of 4. I am trying to understand how to communicate the data between the 2 Arduinos through the serial ports, but I cannot figure out the code. I don't know if I should make an array of 4 float values, and how I should communicate that array to the Arduino Mega. I am looking for virtually no time delay for this method. Can you please help me figure out how to write the code to transmit 4 float values between 2 Arduinos? Also I don't know if it matters but right now I have the I2C setup as the Mega is the master and is requesting data from the Uno, the slave.

Thank you,

have a read thru this:

hope that helps....

Use UART serial, with delimiters, as described in Serial Input Basics. I2C is intended for chip to chip communication on a single PCB.

Have a look at this Arduino to Arduino I2C Tutorial.


You can easily transfer data automatically over UART or I2C using SerialTransfer.h. It comes with many examples and you can install it using the Arduino IDE's Libraries Manager