Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

UART or I2C sensor version?

Status
Not open for further replies.

Od1_fr

New Member
Hello!
The tfmini is an IR lidar sensor. There is a UART and an I2C version, quite at the same price.
For my project, I need 2 tfmini hooked up to an Arduino UNO with a +/- 1m cable.
I've been doing some tests with 2 tfmini UART versions and it works fine following the example "TFmini_Arduino_SoftwareSerial_Multiple" from https://github.com/TFmini/TFmini-Arduino
I need to build more occurrences of my UNO with 2 tfminis, and want to try the I2C version of the tfmini.
As I am no specialist of communication protocols, I'd like to know what could be the theoretical pros and cons of using either of these protocols (mostly regarding reliability and the cables lengths, but I might miss some other important criteria).
Thanks a lot!
 
I2C is for connecting integrated circuits together on the same board - essentially it was created for making television sets - so it's short range, and relatively complicated to use.

UART is for relatively long distance communication, depending on speed and design hundreds of metres, and is very simple to use.

If you're wanting many devices on the same bus, and fairly close to each other, then I2C is probably the way to go, assuming you can set them to enough different addresses?.
 
Thank you Nigel Goodwin for these explanations.
I'll have 2 devices, so I do not NEED I2C. Regarding complexity of use, I'm using Arduino and its tons of libraries, so it's quite hard for me to weight complexity...
My cable length will be about 1 meter.
I guess I'm a bit overthinking it. From what I understand now, there wouldn't be any big differences between i2c and uart for my specific use case.
 
You might want to consider changing to an Arduino that has multiple hardware uarts. I've had problems in the past with software serial.

Mike.
 
As Mike says, hardware UART's are always better, if you have the option.

1 Meter leads should be fine in either case - and as you only need two devices, you could always do one via UART and the other via I2C, completely separating the two.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top