Sensirion / arduino-i2c-scd4x

Arduino library for Sensirion SCD4x sensors
BSD 3-Clause "New" or "Revised" License
47 stars 19 forks source link

Will there be an example for connecting multiple sensors? #31

Closed lemorage closed 3 months ago

lemorage commented 4 months ago

The example usage code is quite great for newbies, however, after I connected more than one sensor to the Arduino board, my program crashed. And the provided error log is "Wrong CRC Found", which makes me lose my head. I wonder if there will be some example code to show how to interact with multiple sensors?

Love4yzp commented 4 months ago

Hi, have you checked the pins? they should not be in conflict.

abrauchli commented 4 months ago

Is your question with multiple scd4x on the same bus or other sensors? I²c only allows one same address per bus. Scd41 is 0x62. If you have two devices replying to a query, CRC issues are expected unless they both reply the exact same answer. I didn't see how to reconfigure the address but you can use another bus if available or otherwise use a multiplexer device.

lemorage commented 4 months ago

Yes, exactly. I have more than one sensor on the same bus, and scd41 is 0x62 by default. They get into conflicts when I try to run the example code. I know we could change the I2C address using a multiplexer, but can we also change the address in our program?

qfisch commented 4 months ago

Hello @lemorage , You are not the first person to request an example using several sensors. We unfortunately did not find the tie yet to do it. I will try to push it out of the backlog.

The general rule for using several of the same sensor:

  1. Check if sensor supports several i2C addresses.
  2. If not, your board might have more than one i2C bus.
  3. If not, you need to use a multiplexer which will distribute the messages across the sensors.

I hope it helps Quentin

lemorage commented 4 months ago

@qfisch Cool, I'll try to see if these options solve the problem, anyway it seems this must be something related to the hardware stuff, not something we can do through programming.

Look forward to any updates on the progress.

qfisch commented 3 months ago

Hello @lemorage ,

We finally released an article on Hachster.io about that topic. There is even an attached example code that can be used and modified for your project.

I hope it will help you, Q