-1
\$\begingroup\$

I have connected 3 sensors and they are connected to the I2C line of ATMEGA2560 as shown in figure. In normal condition, they are working fine and providing accurate sense value.

But, when one of the sensor becomes faulty (short), it is affecting the other sensors also. Thus, due to the fault in one one the sensors the other two sensors value are also affecting. How can I solve the problem?

Block Diagram AM2315 VEML6075 TSL2561 Schematic

Level Shifter

\$\endgroup\$
  • \$\begingroup\$ Do you have information about the sensor available? \$\endgroup\$ – hacktastical Aug 24 at 11:21
  • \$\begingroup\$ we are using Tsl2561, VEML6075, AM2315 sensors. \$\endgroup\$ – Aakash Dey Aug 24 at 11:27
  • \$\begingroup\$ In a later comment you said you're using an AM231[5] module, so not a "bare" sensor. This makes the current schematic above misleading, because the other components on that module are not shown. Also the schematic doesn't show the I2C level shifter (or shifters - it's not clear if you have one or two of them) in the correct place. (a) Please add links to the exact sensor modules you are using. (b) Show the I2C level-shifter(s) in the correct place. (c) You said "I have supplied 3.3V, to VEML6075 and TSL2561" - this is not what the schematic shows. Please fix all schematic errors. \$\endgroup\$ – SamGibson Aug 24 at 19:27
  • \$\begingroup\$ @SamGibson, I have updated the block diagram according to the schematic. \$\endgroup\$ – Aakash Dey Aug 26 at 4:42
  • \$\begingroup\$ What do you mean by "faulty"? Is the involved sensor just locked up, or is it damaged? \$\endgroup\$ – the busybee Aug 26 at 6:07
3
\$\begingroup\$

The individual devices should be directly connected to the I2C bus without resistors.

Then, add pull-ups to VDD on the I2C lines. I2C requires this to function. The drivers are open-drain type so they rely on the pull-ups to make a logic ‘1’.

Choose a value low enough to give a reliable rise time for the bus capacitance. Typical values are about 1 to 2K ohms.

Once you know that you have good signal integrity, the next place to look is to make sure that you don’t have a protocol issue. This may require further debug, using simpler tests for each device and some experiments with timing adjustments. For example, you may need to add a bit of delay for the ACK cycle to complete.

In the recent past I’ve used debugging hardware like the Total Phase ‘Aardvark’ to help diagnose issues like this. Aardvark can work as a master, allowing you to exercise the bus without software and validate the basic function. It can also monitor the bus while another master is running.

Otherwise you need to either learn software or get help from that side to tweak the driver.

\$\endgroup\$
  • \$\begingroup\$ I have earlier tried with the configuration, you are taking about. In that case also I was facing the same issue. \$\endgroup\$ – Aakash Dey Aug 24 at 10:38
  • 1
    \$\begingroup\$ I2C cannot work without pull-ups. Perhaps there is another issue? Try just one device connected and see if that works. \$\endgroup\$ – hacktastical Aug 24 at 10:41
  • \$\begingroup\$ Also, typical I2C pull-ups are 1-2k ohm. Try a lower value than 4.7k. \$\endgroup\$ – hacktastical Aug 24 at 10:43
  • \$\begingroup\$ The resistors are pulled up (not shown in figure). The sensors are working fine in normal cases. But when one sensors become faulty, the other sensors are also affecting and this is my problem/ \$\endgroup\$ – Aakash Dey Aug 24 at 10:45
  • \$\begingroup\$ Do you have an address clash? \$\endgroup\$ – hacktastical Aug 24 at 10:46
1
\$\begingroup\$

There are two options

  1. Solution 1: Clocking.
    When there is a bus stuck condition is detected on SDA (to low) Micro Controller can try to send Many clock cycles in excess (This can be done by changing the port type of SCL line to GPIO and toggle the clock pin until SDA gets released
  2. Solution 2: Reset
    You can reset the slave device. If the device has a reset pin you can drive it to bring it to default state. If the slave device doesn't have a reset pin, you can use a low cost analog Switch to power the slave device. GPIO of MCU can be connected to enable pin of the Analog Switch. Toggling this pin will provide a Power on Reset.
  3. Please update your schematics shown. I think you have drawn it wrong
  4. When you say short condition to VCC do you mean SDA is high? Or you are saying you are measuring resistance. Is the short present when the power is removed?
\$\endgroup\$
  • \$\begingroup\$ OK. I will test as per as your solution 1 and let you know the results. As no reset pin is available in the sensors, I will add analog switch in my next design version as per as your solution 2. I have also updated the block diagram. \$\endgroup\$ – Aakash Dey Aug 26 at 4:53
  • \$\begingroup\$ Yes, Sometimes I have found the i2C lines are short with VCC even if the power is removed. In that case, I found that the the Gate and Source of the MOSFET used in Level shifter ( see the 2nd image) is short.So, the I2C line is showing short with VCC. But my concern is 1) the short circuit of the I2C line with GND and 2) short circuit of SCL and SDA pins. \$\endgroup\$ – Aakash Dey Aug 26 at 5:01
0
\$\begingroup\$

I agree with the other answer that it should be direct connection with only 1 resistor per line acting as pullup, but for now lets deal with the short

As a quick work around, as your using a device with a lot of pins, you may be able to use one of the arduino libraries that emulate I2C, or if your working closer to the hardware, just bit-bang the communication for that one chip, this way you can move the problem sensor off to its own separate I2C wiring that will not interfere with the other 2 when it plays up.

e.g. https://playground.arduino.cc/Main/SoftwareI2CLibrary/

Edit: through piecemeal info, this is either what it is, or what it should be based on the information given Updated schematic

\$\endgroup\$
  • \$\begingroup\$ I am from hardware. So, what can I do from hardware side to solve the problem. \$\endgroup\$ – Aakash Dey Aug 24 at 11:05
  • \$\begingroup\$ If you cannot alter the software at all, then lets reduce what can cause issues, first your SCL line should only be driven by the micro for most chips, so you can have a series limiting resistor on the SCL line of any devices that may cause issues, for SDA, you would either need an analog switch, or similar to physically disconnect a problematic sensor from the bus, Could you please clarify what exactly is causing a sensor to short out, that may help to give you a detailed resolution. \$\endgroup\$ – Reroute Aug 24 at 11:08
  • \$\begingroup\$ Is it possible to solve the issue from hardware side? If not, Please provide me some guidance, what I should change in the coding side. I will try my best. \$\endgroup\$ – Aakash Dey Aug 24 at 11:11
  • \$\begingroup\$ In one of the sensors the I2C lines are showing short.In some of the cases, One of the line is showing short. It is not the case that exactly that pin is short, In some cases both are short, In some cases either of them is short with VDD or GND \$\endgroup\$ – Aakash Dey Aug 24 at 11:14
  • \$\begingroup\$ A short to VDD on an I2C pin seems weird, as most I2C chips can only pull down the signal lines, never up, the micro can if its set up incorrectly, but something very odd much be going on with those sensors, In this case you have 2 main options, isolate via hardware, e.g. an analog switch IC that can disconnect problem sensors that you control via the micro, or software, by moving 2 of the sensors to software I2C like in my answer link, so if one fails, you can either disconnect it, or stop talking to it A variant on this would be switching there power rails to reset them if that helps \$\endgroup\$ – Reroute Aug 24 at 11:31

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.