Hello,
I have a scale that I would like to use on the AVR128DA48. This QWIIC scale board made by sparkfun does the trick with an arduino but doesnt seem to work with the 128DA board. Pin PC3 and PC2 are the I2C pins but no luck. Here is the example code of theirs im using thats modfied slightly:
#include <Wire.h>
#include <EEPROM.h> //Needed to record user settings
#include "SparkFun_Qwiic_Scale_NAU7802_Arduino_Library.h" // Click here to get the library: http://librarymanager/All#SparkF...
NAU7802 myScale; //Create instance of the NAU7802 class
//EEPROM locations to store 4-byte variables
#define Serial Serial1 // for Curiosity AVR128DA48
#define LOCATION_CALIBRATION_FACTOR 0 //Float, requires 4 bytes of EEPROM
#define LOCATION_ZERO_OFFSET 10 //Must be more than 4 away from previous spot. Long, requires 4 bytes of EEPROM
bool settingsDetected = false; //Used to prompt user to calibrate their scale
//Create an array to take average of weights. This helps smooth out jitter.
#define AVG_SIZE 4
float avgWeights[AVG_SIZE];
byte avgWeightSpot = 0;
void setup()
{
delay(4000);
Serial.begin(9600);
Serial.println("Qwiic Scale Example");
Wire.begin(PIN_PC2, PIN_PC3);
Wire.setClock(400000); //Qwiic Scale is capable of running at 400kHz if desired
if (myScale.begin() == false)
{
Serial.println("Scale not detected. Please check wiring. Freezing...");
while (1);
}
Serial.println("Scale detected!");
readSystemSettings(); //Load zeroOffset and calibrationFactor from EEPROM
myScale.setSampleRate(NAU7802_SPS_320); //Increase to max sample rate
myScale.calibrateAFE(); //Re-cal analog front end when we change gain, sample rate, or channel
Serial.print("Zero offset: ");
Serial.println(myScale.getZeroOffset());
Serial.print("Calibration factor: ");
Serial.println(myScale.getCalibrationFactor());
}
The serial monitor reads
Qwiic Scale Example
Scale not detected. Please check wiring. Freezing...
This means the I2C is not connected properly. Anyone know what I am missing here?