How do you program an Arduino Uno to request data over I2C, sending parameters defining the request?
I'm trying to program Arduino A to read a sensor value from another Arduino B, and it first needs to tell B which sensor to report, but I can't find any easy way to do this with Arduino's Wire library. There doesn't seem to be anything like Wire.requestFrom(addr, 1235, 2)
which would then call a handler on the slave the looks like onRequest(sensor_id)
.
I found this page on how to push data one way to a slave, and I found this page on how to request data from a slave without specifying any input, but I can't find anything in between.
Is the solution to use the first method to set the parameters, and then the second to get the data? If so, that seems very circuitous. Is there a more direct method?