I have Data on an Arduino NANO (Slave) which needs to be transfered over to my Raspberry PI (Master)via I2C-Bus... so far so good.
I want to use the I2C-registers for that.
Writing on other Registers from the Arduino is no Problem, reading Registers from the Raspberry PI neither.
But from what I understood I need to write on the I2C-Registers from the Arduino itsself, to read them out from the Raspberry. But after now many hours of searching I still don't know if this is even possible.
Continuing I am thinking that if I read out a Sensor like MPU6050 via I2C, I read the direct Registers, so the MPU needs to be writing on the own Registers too.
On the Arduino I'm curently using the Wire.h library.
Can you do your project in a different way ?
The I2C bus is not a good bus between processors or between boards.
Do you have a classic Arduino Nano ? That is a 5V board, and it has a 5V I2C bus (SDA and SCL change between 0V and 5V). The Raspberry Pi has a 3.3V I2C bus. Do you use a I2C level shifter ?
How long are the wires for the I2C bus ? If you use a cable, what kind of cable is it ?
A sensors has registers. An Arduino board in I2C Slave mode (also called "Target" mode) does not have such registers. You can write code to make something similar to the registers of a sensor.
However, in most cases a certain package of data is defined, which is transferred over the I2C bus, without "registers".
Can you show the code for both the Nano and the Raspberry Pi ?
If you use a USB cable and connect the Arduino Nano to a USB port on the Raspberry Pi, then you have a Serial/UART connection. There is also no conflict with voltage levels.
A single block of data is easier than writing code to behave like the registers of sensors.
The buffer in the Wire library for sending and receiving is 32 bytes.
That means that your array can have a maximum of 16 integers (of 2 bytes each).
Suppose that your sensors update the array and the array is read via the I2C bus.
If there is a bug in the sketch or a sensor is disconnected and the array is no longer updated, how do you know in the Raspberry Pi how old the sensor data is ? I could be from weeks ago.
ehm yes the Arduino recieves Data via CAN-Bus and this data needs to go to the Raspberry. The Sensors on the I2C can be direcly read out by the Raspberry.
And I can make a loop that waits for a new Message via CAN, which then writes the Information to the Array and sends it.
Do you have other Suggestions, except from using UART?