1
\$\begingroup\$

I am using Load Cell (FX29 Data Sheet) and Arduino for measuring force. Every time I disconnect and reconnect Arduino from USB I get one of the following readings on serial monitor:

  1. Correct expected values
  2. Zero value (sensor returns "0" value and does not increment)
  3. Maximum possible reading i.e. 16383 for 14 bits

I'm not able to understand the reason. What could be the possible directions for debugging the issue?

Circuit Diagram: enter image description here

\$\endgroup\$
10
  • 1
    \$\begingroup\$ The problem could be in the schematics, PCB design, wiring between modules, or how the modules are grounded or powered and from which kind of supply. Can you post any details? \$\endgroup\$
    – Justme
    Commented Jun 10 at 12:30
  • 3
    \$\begingroup\$ Write something that puts a test value on the serial, independent of the load cell. Does that work with making/breaking USB connection? Get the load cell reading few LSBs (or few MSBs) to light some LEDs, independent of the serial monitor. Does either of those work 100%, or fail sometimes, or fail 100%? This is called binary search - split the failing process in two, and try to see which half has the problem. Rinse and repeat. Of course, you may have a problem in both halves. Or the problem goes away completely when you split the process. Those possibilities make for more interesting problems. \$\endgroup\$
    – Neil_UK
    Commented Jun 10 at 12:44
  • \$\begingroup\$ how is your code initiailising the I2C? \$\endgroup\$
    – Neil_UK
    Commented Jun 10 at 12:58
  • \$\begingroup\$ Thanks Neil, this makes sense. I have limited experience with electronics. The sensor has I2C output, is it possible to read it without using serial connection? \$\endgroup\$
    – Siddhesh
    Commented Jun 10 at 12:58
  • \$\begingroup\$ If you plan on always powering the Uno from an external supply, and wish to use USB for only data & monitoring, then it's worth looking at the schematic of the Uno for the possibility of permanently disconnecting USB power. This worked for me when using the Mega. For the Mega, all I had to do was remove the USB-B, F1, fuse. Let me know if you'd like more details, or if you'd like me to investigate if the Uno is similar. \$\endgroup\$ Commented Jun 10 at 13:01

1 Answer 1

1
\$\begingroup\$

From the code that you are based on:

  Wire.requestFrom(curAddress, 2); //Requests two bytes of data 
  byte msb = Wire.read();
  byte lsb = Wire.read();

This code send a request for reading two bytes from the I2C slave, it then immediately read the input buffer without checking whether the data is actually available or not, as the result you will get whatever in the i2c buffer instead of the actual reading. The following code is a more reliable implementation:

  Wire.requestFrom(curAddress, 2, true);  // true - send STOP at end of data transfer
  while (Wire.available() != 2) {};       // wait until two bytes are received
  int16_t dataVal = (int16_t) ( (Wire.read() & 0x3f) << 8 ) | Wire.read();
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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