Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Hardware
  3. UART or I2C sensor version?

UART or I2C sensor version?

Scheduled Pinned Locked Moved Hardware
7 Posts 5 Posters 507 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • od1O Offline
    od1O Offline
    od1
    wrote on last edited by
    #1

    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!

    mfalkviddM 1 Reply Last reply
    0
    • od1O od1

      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!

      mfalkviddM Offline
      mfalkviddM Offline
      mfalkvidd
      Mod
      wrote on last edited by mfalkvidd
      #2

      @od1 i2c supports multiple devices on the same cable (if the devices can configure address).
      Uart can support longer cables, but both can support 10m.

      Both can be used with software (bit-banging) which means you are not limited to the hardware serial/i2c.

      1 Reply Last reply
      1
      • od1O Offline
        od1O Offline
        od1
        wrote on last edited by
        #3

        Hi @mfalkvidd and thanks for your quick answer :)

        1 Reply Last reply
        0
        • alowhumA Offline
          alowhumA Offline
          alowhum
          Plugin Developer
          wrote on last edited by
          #4

          This is a matter of personal taste, but I always prefer serial devices.

          • They are easier to connect with simple wiring, since you can use any pin as software serial.
          • I also like that if you use multiple serial devices, you can keep the code you need to a minimum. I usually only implement (read: copy-paste) the commands that I really need. E.g. for GSM modems of for serial TFT screens. That can save some space.
          • Finally, I get the feeling what with serial it's easier to integrate in future unknown scenarios. E.g. attach a sensor to a USB-to-serial device.

          I'd love to hear counter arguments to this actually.

          Nca78N 1 Reply Last reply
          0
          • alowhumA alowhum

            This is a matter of personal taste, but I always prefer serial devices.

            • They are easier to connect with simple wiring, since you can use any pin as software serial.
            • I also like that if you use multiple serial devices, you can keep the code you need to a minimum. I usually only implement (read: copy-paste) the commands that I really need. E.g. for GSM modems of for serial TFT screens. That can save some space.
            • Finally, I get the feeling what with serial it's easier to integrate in future unknown scenarios. E.g. attach a sensor to a USB-to-serial device.

            I'd love to hear counter arguments to this actually.

            Nca78N Offline
            Nca78N Offline
            Nca78
            Hardware Contributor
            wrote on last edited by
            #5

            @alowhum your are also missing the longer cables as uart is more resistant to interference.

            The limits I see are:

            1. when you need to use software serial with high baudrate, I don't think a poor uno will handle well multiple software serials at 115k ?
              If it has to process the data and store/send it, it might miss some data as software serial has no hardware input buffer.
              Of course if sensors don't need to run simultaneously then this will not be a problem.

            2. pin usage. Each sensor using 2 pins can be a limit. Should not be in this case on a uno, but I have the problem on ESP32, I had to make a daughter board with an attiny to convert uart sensors to i2c, now I can have as many as I want.

            1 Reply Last reply
            1
            • scalzS Offline
              scalzS Offline
              scalz
              Hardware Contributor
              wrote on last edited by scalz
              #6

              exactly.
              like mfalkvidd and nca78 said, i2c is a bus, not the case of the serial comm you use. and serial devices are usually not very low power.

              again I agree, serial sw is maybe ok for a simple device, else it has very poor performance. bad idea for lcd fast refresh, or sampling sensors etc. I avoid it as much as I can (I think I don't have any projects using it though)

              same as nca78 I have a few projects when I use all esp32 pins, and I use serial, i2c and spi a lot, even canbus, ..hopefully I have not used serial interface only!

              better use the right tech for a project ;)

              1 Reply Last reply
              0
              • alowhumA Offline
                alowhumA Offline
                alowhum
                Plugin Developer
                wrote on last edited by
                #7

                @nca and @scalz Thanks! Very interesting, good points.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                14

                Online

                11.7k

                Users

                11.2k

                Topics

                113.1k

                Posts


                Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • MySensors
                • OpenHardware.io
                • Categories
                • Recent
                • Tags
                • Popular