Receive message from I2C, read analog input and create pwm same time

Hi everyone,

the idea of my project is receiving a I2C message from Raspberry:

=> If the message is reading analog, then read analog input in Arduino then send value back to Raspberry and it muss run until Arduino receive a new message, which says stop sending. In this task, all 6 analog input of Arduino can be requested and send value same time.

=> If the message is creating PWM signal with a value, which is in the message, then Arduino create PWM signal and run with received value. PWM muss run with this value until Arduino receives new message. In this task, all 6 PWM signal of Arduino can be requested to create signal same time.

My question is, is that possible to do this? I tried with the first task "analog reading" but same time creating PWM signal may be too much. Or could that be with FreeRTOS?

=> If the message is reading analog, then read analog input in Arduino then send value back to Raspberry and it muss run until Arduino receive a new message, which says stop sending. In this task, all 6 analog input of Arduino can be requested and send value same time.

That's not possible. The I2C interface isn't the same as the probably more familiar UART interface. The slave (I guess the Arduino in your setup) cannot send anything to the master except if the master explicitly asked for it and at exactly that time (because the master is providing the clock signal for that transfer).
If you want UART communication, use the UART interface!

=> If the message is creating PWM signal with a value, which is in the message, then Arduino create PWM signal and run with received value. PWM muss run with this value until Arduino receives new message. In this task, all 6 PWM signal of Arduino can be requested to create signal same time.

That might be possible.

My question is, is that possible to do this? I tried with the first task "analog reading" but same time creating PWM signal may be too much. Or could that be with FreeRTOS?

As the PWM signal is generated in hardware you can theoretically have that in parallel given that your first task would work.

Connect the Arduino with its USB connector to the Raspberry Pi. Buy a USB-hub if needed. Then use the Serial communication as pylon already wrote.

The I2C bus is not really a communication bus. It works best with sensors and so.

The Serial/UART/USB interface is already there. You don't have to deal with interrupts. You only need a good communication protocol. There are libraries for the Arduino and Python scripts for the Raspberry Pi.

And you also get the possibility to upload a new sketch for free :wink:
For example with remote access and with a command interface to upload a sketch. That means that you can upload a sketch from your computer via the Raspberry Pi even when the Raspberry Pi is not running a desktop.