2

Lets say I have a sensor connected to Arduino Uno Rev3's I2C Bus. I am reading the sensor output and using Serial.print() to send the sensor reading back to a my laptop.

I am trying to understand the bottlenecks that limits the sensor sampling rate received at the laptop.

The sampling rate of the sensor depends on many factors. Lets assume sensors sampling rate is not limited. That would mean I am limited by how much data each intermedia bus can carry before it reaches the laptop. For example, I am limited by I2C bus atmega328p is using to read the sensor data. I am also limited by the UART bus atmega16u2 is using to send the data to my laptop. Am I correct so far? Also, on what bus atmega328p and atmega16u2 are connected over?

Quazi Irfan
  • 156
  • 1
  • 10

2 Answers2

3

If there had been a specific scenario you were considering, it might help to share. There's quite a lot to think about with just theoretical assumptions.

That would mean I am limited by how much data each intermedia bus can carry before it reaches the laptop

Yes, mostly yes. The bandwidth of the entire transmission interface which includes the I2C interface, ATMEGA328P, connection to ATMEGA16U2, and the USB interface would account for the theoretical max sampling rate of the sensor.

For some cases, you may need to consider the latency as well as the bandwidth of the transmission media, which would include the I2C interface, ATMEGA328P, ATMEGA16U2, and the USB interface. The sensor may require some calculations which may result in some delay. The I2C interface or the UART interface could introduce some delay too, especially if it's driven by bit-banging(although probably not with 328P).

Also from 328P's perspective here, it has to receive data from the sensor, make calculations from the incoming raw data if needed, and send over the UART interface to the 16U2. Most of these processes will happen step by step and if the combined processing time takes longer than the delay between each sample coming from the sensor, the 328P itself could theoretically be a bottleneck too.

angrypig7
  • 76
  • 5
2

Also, on what bus atmega328p and atmega16u2 are connected over?

See:

https://www.arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf

They are connected by TxD and RxD.

Without seeing your code (hint) it is extremely difficult to say. Perhaps a faster baud rate would help.

Nick Gammon
  • 38,901
  • 13
  • 69
  • 125