0

I have two different sensors which have SCL and SDA connections which I am trying to connect to an Arduino nano. From what I understand, connecting both of these sensor to the A5 and A4 pins doesn't make any sense, considering that I need to collect data continuously from both sensors. Moreover, there are no other pins with the same functionality as A5 and A4. I am a beginner learning about microcontrollers, but it seems to me like the best practice to follow here would be to use two Arduino nanos. Is this this the only way, or is there another method I am not aware of?

9
  • you can't even collect data continuously from one sensor ... the data is transmitted serially ... there is always a delay between readings
    – jsotola
    Oct 22, 2022 at 0:09
  • 1
    which sensors are you talking about? ... what data throughput are you expecting?
    – jsotola
    Oct 22, 2022 at 0:09
  • 1
    I2C is a bus, it allows multiple sensors to be connected (as long as they have different address) to the same bus using the two wires. Y
    – hcheung
    Oct 22, 2022 at 0:58
  • @jsotola I have two different temp sensors. By continuous I meant I need to be collecting data every 10 ms.
    – nova
    Oct 22, 2022 at 1:04
  • 1
    Your question does not have enough detail for a good answer. Please edit the question (don't reply in a comment) and add the following information: (1) What are the part numbers of the two sensors? (2) How far apart are they from the Arduino, and each other. (3) How often do you want to collect the data?
    – Nick Gammon
    Oct 22, 2022 at 5:38

1 Answer 1

1

The whole point of the I2C bus is to allow multiple sensors or devices to be connected, as long as they have different I2C addresses. The addresses are usually built into the part, and often they have some provision for selecting an address from a range.

Whilst you can't simultaneously collect data from two sensors at once, you can certainly query them in quick succession. You need to connect SDA, SCL, Ground and +5V to each sensor, and the Arduino.

Your code would do something like:

  • Query sensor at address 42
  • Query sensor at address 43
  • Do something with the data
  • Wait a bit before doing it again

You could look at Wikipedia for some general information about I2C, and I also have a page about I2c that might help you.

Note that you also need a pull-up resistor on both SDA and SCL (that is, two resistors), a typical value would be 4.7k (connect the 4.7k resistors between SDA/SCL and your +5V line).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.