You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I confirmed the arduino teensy 4.0 could see the FDC1004 at its 0x50 address by running:
#include <Wire.h>
void setup() {
Wire.begin();
Serial.begin(9600);
while (!Serial); // for Leonardo/Micro/Zero
Serial.println("\nI2C Scanner");
byte error, address;
int nDevices = 0;
Serial.println("Scanning...");
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");
}
}
void loop() {
// nothing to do
}
I
2C Scanner
Scanning...
I2C device found at address 0x50 !
done
When running the following code to output from every address:
#include <Wire.h>
// FDC1004 I2C address
#define FDC1004_I2C_ADDRESS 0x50
void setup() {
Serial.begin(9600);
Wire.begin();
// Wait for Serial monitor to open
while (!Serial) {
; // wait for serial port to connect.
}
Serial.println("Reading FDC1004 registers...");
}
void loop() {
// Register addresses to read
uint8_t registersToRead[] = {
0x00, // MEAS1_MSB
0x01, // MEAS1_LSB
0x02, // MEAS2_MSB
0x03, // MEAS2_LSB
0x04, // MEAS3_MSB
0x05, // MEAS3_LSB
0x06, // MEAS4_MSB
0x07, // MEAS4_LSB
0x08, // CONF_MEAS1
0x09, // CONF_MEAS2
0x0A, // CONF_MEAS3
0x0B, // CONF_MEAS4
0x0C, // FDC_CONF
0x0D, // OFFSET_CAL_CIN1
0x0E, // OFFSET_CAL_CIN2
0x0F, // OFFSET_CAL_CIN3
0x10, // OFFSET_CAL_CIN4
0x11, // GAIN_CAL_CIN1
0x12, // GAIN_CAL_CIN2
0x13, // GAIN_CAL_CIN3
0x14, // GAIN_CAL_CIN4
0xFE, // Manufacturer ID
0xFF // Device ID
};
for (uint8_t reg : registersToRead) {
readAndPrintRegister(reg);
delay(100); // Short delay between reads
}
Serial.println("------");
delay(1000); // Delay before starting over
}
void readAndPrintRegister(uint8_t reg) {
Wire.beginTransmission(FDC1004_I2C_ADDRESS);
Wire.write(reg);
Wire.endTransmission(false); // End transmission but send a restart to keep the bus active
Wire.requestFrom(FDC1004_I2C_ADDRESS, 2); // Request 2 bytes for the register value
if (Wire.available() == 2) {
uint16_t value = Wire.read() << 8; // Read MSB
value |= Wire.read(); // Read LSB
Serial.print("Register 0x");
if (reg < 0x10) {
Serial.print('0'); // Print leading zero for single digit hex numbers
}
Serial.print(reg, HEX);
Serial.print(": 0x");
Serial.println(value, HEX);
} else {
Serial.print("Failed to read register 0x");
Serial.println(reg, HEX);
}
}
We see that I can read values from all of the other addresses.
I couldn't get the library to run, so I used my own code.
I confirmed the arduino teensy 4.0 could see the FDC1004 at its 0x50 address by running:
I
When running the following code to output from every address:
We see that I can read values from all of the other addresses.
I have attempted to connect a number of things to channels 1-4, with no change from 0.
The text was updated successfully, but these errors were encountered: