one sensor with multiple protocol

Thread Starter

Embededd

Joined Jun 4, 2025
197
I have a bit of a weird question, and I’d really like to hear how someone with practical experience would approach it.

Suppose you have a temperature sensor that can provide temperature data through four interfaces: UART, SPI, I2C, and CAN. You need to connect it to an MCU and simply read the room temperature. Since all four interfaces can give you the same temperature value, which one would you actually choose, and more importantly, what would be your reason for rejecting the others?

Personally, I would probably remove CAN first, but my reason is not very strong. I mainly associate CAN with automotive and distributed/robust communication, so it feels unnecessary for a simple temperature sensor connected directly to an MCU. But I’m not sure if that is a good technical reason.

Then between SPI, UART, and I2C, I would probably remove SPI because it generally needs more signal lines than I2C, especially when multiple devices are involved. That leaves UART and I2C.

If saving pins is the main concern, I might choose UART because it only needs TX and RX, whereas I2C needs SDA and SCL. But I also know this is probably oversimplifying the decision

how would you make this decision. Which interface would you choose in this particular situation, and what would be your reason for rejecting the other three?
 

RH3

Joined Nov 14, 2016
3
My first consideration would be what type of sensor and its location in relation to the MCU.

Then does it need two-way communication/handshaking?

In the case of a remote wired sensor does it autonomously send data or does it need to be polled?

Is there more than one sensor sitting on the same wired path?

Is a wired sensor’s environment noisy?

So, the choice of the most appropriate protocol may be dictated by the type of sensor, data transmission path and electrical environment. There will be one protocol that stands out as the most suitable.
 

panic mode

Joined Oct 10, 2011
5,152
what environment? what temperature range? what accuracy?
for simple DIY automation and easy connectivity i would use ESP01 (Really small and has WiFi), and connect to it one or several DS18B20.
 

Thread Starter

Embededd

Joined Jun 4, 2025
197
My question was more about the interface selection itself, rather than choosing the sensor.

Let’s assume:

  • the sensor is very close to the MCU, on the same PCB
  • only one sensor is connected
  • normal indoor environment, say 0–50°C
  • around ±1°C accuracy is sufficient
  • the sensor supports UART, SPI, I2C and CAN equally well
  • I only need to read the temperature periodically, say once per second
  • no special need for long-distance communication or multiple nodes
  • cost and availability are not part of the decision

If all four interfaces can provide the same temperature data under these conditions, which one would you choose and why would you reject the other three?
 

MrChips

Joined Oct 2, 2009
35,007
My question was more about the interface selection itself, rather than choosing the sensor.

Let’s assume:

  • the sensor is very close to the MCU, on the same PCB
  • only one sensor is connected
  • normal indoor environment, say 0–50°C
  • around ±1°C accuracy is sufficient
  • the sensor supports UART, SPI, I2C and CAN equally well
  • I only need to read the temperature periodically, say once per second
  • no special need for long-distance communication or multiple nodes
  • cost and availability are not part of the decision

If all four interfaces can provide the same temperature data under these conditions, which one would you choose and why would you reject the other three?
Based on the additional information you have provided, my choice is I2C.
 

Thread Starter

Embededd

Joined Jun 4, 2025
197
Based on the additional information you have provided, my choice is I2C.
What makes you choose I2C in this particular case? I'm more interested in the reasoning behind the choice and why you would reject UART, SPI and CAN under these assumptions.

For example, is it mainly because of pin count, addressing, bus capability, simplicity, or something else?
 
Top