How to get data from an Arduino and send it to a Roborio

Hey guys!
My team recently bought a rioduino in order to use some new sensors for next season. I have been able to find a plethora of code for sending values from roborio to an Arduino using i2c and have been able to accomplish the same, but the issue is that I have not been able to find code for doing the reverse operation(Arduino to RoboRio). Does anyone know how to accomplish this and if so could push us in the right direction?



Doesn’t the RIOduino go into the MXP port on top? Why would you need I2C at that point?

MXP is a port with multiple connectors for different protocols: I2C, SPI, UART…

Yes. Arduino side, I simply did the write command but when I try and use the I2C read method, nothing is returned.

I2C devices have the concept of master/slave. Only the master can initiate a bus transaction. In your case, the RoboRIO is the master and the Arduino is the slave. So the RoboRIO needs to issue a command to get data from the Arduino. What exactly are you trying to read from the Ardino? You need to design a ReadData command so that the RoboRIO issues this command and the Arduino will respond by returning the data. Since the Arduino cannot initiate the bus transaction, if the data is “on-demand”, you may need to have the RoboRIO “poll” for data periodically.

Last year, I programmed an RGB light strip to go on our robot. It looked really good, but we wanted to be able to change what the lights were doing based on a condition in the match, or simply because we wanted to change them.

In the end, we just used four digital wires from the arduino to the roboRIO for communication, which gave us support for 2^4 = 16 light states. Of course, this is not the same as transmitting actual larger amounts of data, which would certainly require an analog communication. I2C should serve you well, or PWM, but if you don’t need that much data to go from the Arduino to the RoboRIO, you could still use digital pins.

On a side note, why are you choosing to use the Arduino to control sensors? If you just wire the sensors to the roboRIO then you could skip this problem entirely.

Good luck!