Hello, I am attempting to make a system wherein I take humidity/temperature readings from multiple points in reptile habitats and then turn on/off heat sources/misters to regulate the proper environments.
I've come across the problem of needing the SCL/SDA pins (A4/A5) for each of them, and I'm looking to hook up anywhere from 6-12 sensors. Is there a workaround for this or will I have to do a single sensor per uno?
Those sensors use what is called the I2C bus, and you can connect many sensors to one pair of SCL/SDA lines.
Each sensor has to have a unique device address, so check the data sheet for the AHT10 sensor to see if it supports a configurable address.
You also have to be aware of the rule for a pullup resistor on each of SDA and SCL. They are normally in the range of 2.2K to 10K, but can't be too low or too high. Only one set is needed for several modules. Unfortunately, module manufacturers do not standardize the presence of pullup resistors, so you have to check whether they are present, and what value they have. It is sometimes necessary to remove them.
Finally, you need a logic level shifter to connect 5V Arduinos to 3.3V sensors (or the other way around). Sometimes those are built in to sensor modules as well, and again you have to check.
As mentioned, if you get an i²c multiplexer like this:
then you can connect up to 8 of your sensors.
If you need more than 8 and your sensors are like this
then you can connect 2 sensors to the same SDA/SCL pins, but you have to do a tricky bit of soldering on one of the two. You need to move the tiny resistor to the left in the image above. But this will let you connect up to 16 of your sensors.
If you don't like the idea of having to move those resistors, then you can use 2 of the multiplexers for up to 16 sensors.
Next problem: i²c bus cannot be very long. You may be able to go 2m if you are lucky, but there is no guarantee. I²c is meant to connect chips together that are on the same PCB.
Thank you. I ordered some and they came today. Not yet at the point in the project I will be needing them, but hopefully they work! Just wish I had a smaller soldering tip lol.
Thanks for the information. That level of soldering is beyond me at the moment, in both terms of skill and equipment. I don't envision I'll need more than 8, but what would happen if I connected a multiplexer to the first multiplexer? Would this relate to the issue of the I2c bus not being very long?
That might work, but I wonder if there is another way to do this. By using extra pull-up resistors and slowing the i²c speed down, you might be able to extend the distance.
There are also active extender modules that are available.
Teasing aside, I apologize for not coming back to this until now, been working on the rest of the code as the acceptance of external input will be the last step, hopefully as easy as replacing stand-in variables with the input. (Read: I will find a way to break it and try for days to learn I put a comma in the wrong place, again xD). Would you have an active extender module that you would recommend? Still not certain I'll need more than 8, but it would be nice to know what to do if I decide to go that way.