Following the suggestion of Fiendish to post here: Hello

Nick, thank you very much for this I2C-anything library that works a treat with two arduinos (one sender, one receiver).

Is there any suggested method or at least an example sketch of having two different sender arduinos send their floats to the receiver e.g. by alternating slave adresses in the receiver loop? With a simple re-insertion of the section (but with a different address) into the receiver sketch restarting with Wire.begin() and then Wire.begin(new address) things are botched up.

In addition: if I define -float f in sender A- and -float e in sender B- the receiver keeps on printing the float e value in the serial.Print ("float value e"); serial.println(e); -postion, no matter if I swap from Sender A to sender B -by changing the SCL/SDA connections, and the serial.Print ("float value f");serial.println(f); prints fancy numbers.

If at least the swapping would cause the floats to be printed in the correct position I could maybe switch the respecive senders I2C down in turns....

Of course hotplugging /hotswitching SDA and SCL from senders causes the senders sketch to be blocked at times.

The idea of sending data from Sender B to Sender A, and from Sender A to to receiver left me frustrated the last few hours, due to the fact that Im a total noob and/or that its simply not possible to have two masters send to one slavereciver without running into i2C conflicts. Unless some unknown acrobatics is performed.

The ultimate idea is to have two separate megas (with i2c sensors attached to them) execute feedbackloops and still be able to transfer these values and other values to a display via I2C. the alternate way could be that a dac is used to translate the I2C values into voltages that hardware....)

Any help greatly appreciated Best Daniel

  • Please draw a schematic for us. It is not really clear to me, how the setup is and why. Also please show your code. Without these two, your description is really difficult to understand. Generally I would discourage the use of multi-master mode in I2C. I'm myself working on multi-master for ATtinys, and I have to say, that it can be a real mess. If you describe the context, maybe we can point you to a better alternative.
    – chrisl
    Feb 5, 2021 at 8:26
  • Please describe why you think you need multiple masters for one slave. As chrisl wrote, I2C multimaster typucally is not much fun and there might be simpler solutions (one master/ 2slaves, I2C combined with UART, etc.)
    – Sim Son
    Feb 5, 2021 at 16:58

1 Answer 1


Dear Chrisl and Sim Son

Please accept my apologies for not replying earlier, am still recovering form a timbering accident and have limited painless access to my laptop.

thinking in boxes: BOX 1 = Arduino Mega number one regulates the pressure of proportional valves (via I2C conected quaddac MCP4728 to 0-10V) based on the flowvalues of 4 I2C-connected FLowsensors.

BOX 2= Arduino Mega number two does the same with a second set of 4 flowsensors and 4 analog proportional valves.

Splitting this to two arduinos was originally because a) i was unable figure out how to get 2 DACS on the same I2C line and handle the LDAC address fiddling which turned out to be a good approach because the total number of required GPIO pins exceeds the available number of pins of one Mega (many rotary encoders attached, TTL signal delayer for 8 channels, pots to set values, status LEDS.

Both arduinos are supposed to send the values for the flow-setpoints, actual pressure values, actual flow values, other sensor data to a third arduino MEGA =BOX 3 that displays all kind of things on a large TFT. (for what its worth, this third Mega has some inputs from a different set of other I2C sensors that basically provide TTL signal outputs, if event-criteria have been met. the latter TTL are fed back to the first two arduinos to provide decision criteria in if loops)

So, i learn from you that the multimaster approach unlikely to be fun at all, especially given my limited knowledge and loathing /ignorance to handle and send strings. You will at least laugh at me now but i saved quite some time the on day i wrote to you by simply translating all the flow etc values of BOX 1, Box 2-Ardinos (pressures, flowsetpoints and actual flow values into voltages with the help of additional multiplexed DACs, then I pick up the the voltages with I2C-ADCs hooked to the Arduino with the SPI-display (BOX 3) that in turns translates into the true values and prints to the TFT. Any delay and inprecision at the displays side is acceptable so far, analog value fluctuation has been smoothed, the additional hardware is no issue at this stage of the project.

I am sorry that his original issue regarding I2C led me astray to oldfashioned analog data processing

BUT: if you have any hints or pointers to libraries as how two arduinos that act already as I2C Masters can send their data (a bundle of floats) via UART/RXTX, or any other bus to a receiver that handles these as printable variables: more than welcome, i will try to keep abreast of what you suggest.

Best Daniel

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.