unable to initialize a NAU7802

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
adavid7
 
Posts: 120
Joined: Fri Jul 04, 2014 7:32 pm

unable to initialize a NAU7802

Post by adavid7 »

I am using a NAU7802 board and am unable to initialize it in the call to the begin() method, as in the nau7802_test example.

I poked around in the library to see exactly why, and it is failing on this check in the Adafruit_NAU7802.cpp code (line 57):

Code: Select all

 if ((rev_reg.read() & 0xF) != 0xF) 
Any idea what's going on? I'm using a Metro.

Thanks.

.Andy

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: unable to initialize a NAU7802

Post by mikeysklar »

Which model metro are you using? 328p or a modern 3v based model?

Are you getting a valid i2c connection? Try running this i2c scan code to see if the 0x2A address for the NAU7802 appears.

Code: Select all

// --------------------------------------
// i2c_scanner
//
// Modified from https://playground.arduino.cc/Main/I2cScanner/
// --------------------------------------

#include <Wire.h>

// Set I2C bus to use: Wire, Wire1, etc.
#define WIRE Wire

void setup() {
  WIRE.begin();

  Serial.begin(9600);
  while (!Serial)
     delay(10);
  Serial.println("\nI2C Scanner");
}


void loop() {
  byte error, address;
  int nDevices;

  Serial.println("Scanning...");

  nDevices = 0;
  for(address = 1; address < 127; address++ ) 
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    WIRE.beginTransmission(address);
    error = WIRE.endTransmission();

    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16) 
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");

      nDevices++;
    }
    else if (error==4) 
    {
      Serial.print("Unknown error at address 0x");
      if (address<16) 
        Serial.print("0");
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");

  delay(5000);           // wait 5 seconds for next scan
}
https://learn.adafruit.com/scanning-i2c ... es/arduino

User avatar
adavid7
 
Posts: 120
Joined: Fri Jul 04, 2014 7:32 pm

Re: unable to initialize a NAU7802

Post by adavid7 »

I'm using this Metro adafruit.com/product/2488, as in the attached photo. And yes, it finds the I2C device:

Code: Select all

12:04:38.759 -> Scanning...
12:04:38.790 -> I2C device found at address 0x2A  !
12:04:38.823 -> I2C device found at address 0x77  !
12:04:38.856 -> done
I have another I2C sensor connected also (a BME680).
Image
Attachments
IMG_5604.jpg
IMG_5604.jpg (248.58 KiB) Viewed 148 times

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: unable to initialize a NAU7802

Post by mikeysklar »

Having the BME680 present is not ideal for troubleshooting, but I think I see the issue. This looks like a library problem that is still open for Arduino side only.
The CircuitPython library resets and enables the board in its init:
...
The Arduino library attempts to read the chip rev register before the reset and enable. Moving the check to after those calls gets it working:
https://github.com/adafruit/Adafruit_NAU7802/issues/5

User avatar
adavid7
 
Posts: 120
Joined: Fri Jul 04, 2014 7:32 pm

Re: unable to initialize a NAU7802

Post by adavid7 »

OK, thanks for this info and the Github link. I've just updated my library with the new version (1.0.2) and it works.

Now I have a question about using the 7802 with one of these strain gauges: adafruit.com/product/4630.

The sample program in the library (nau7802_test) works just fine, but I can't find any info on how to interpret the numbers it reports from nau.read().

How do you correlate those reading values with the weight it is detecting on the strain gauge?
Thanks.

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: unable to initialize a NAU7802

Post by mikeysklar »

There are two CircuitPython guides that shows how to calculate grams based on the read_raw_value / calibration[‘offset’].

https://learn.adafruit.com/nau7802-pet- ... food-scale
https://learn.adafruit.com/clue-coffee- ... de-details

Since you are using Arduino there will be some differences, but I believe the API and techniques for deducing weights will be very similar.

User avatar
adavid7
 
Posts: 120
Joined: Fri Jul 04, 2014 7:32 pm

Re: unable to initialize a NAU7802

Post by adavid7 »

Thanks, that's very helpful. Especially the coffee scale project is a well-documented and explained one.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”