Added i2cScan and ICM-42670P whoami
This commit is contained in:
@@ -19,6 +19,7 @@ lib_deps =
|
||||
arduino-libraries/Arduino_JSON@^0.1.0
|
||||
adafruit/Adafruit MMC56x3@^1.0.1
|
||||
ayushsharma82/ElegantOTA@^3.1.0
|
||||
invensenseinc/ICM42670P@^1.0.0
|
||||
board_build.partitions = partitions.csv
|
||||
monitor_speed = 115200
|
||||
|
||||
@@ -37,6 +38,7 @@ lib_deps =
|
||||
arduino-libraries/Arduino_JSON@^0.2.0
|
||||
adafruit/Adafruit MMC56x3@^1.0.1
|
||||
ayushsharma82/AsyncElegantOTA@^2.2.7
|
||||
invensenseinc/ICM42670P@^1.0.0
|
||||
build_flags =
|
||||
'-D ARDUINO_USB_MODE=0'
|
||||
'-D ARDUINO_USB_CDC_ON_BOOT=1'
|
||||
|
||||
39
src/main.cpp
39
src/main.cpp
@@ -80,6 +80,45 @@ String getLEDState();
|
||||
bool initIMU();
|
||||
void i2cScan();
|
||||
// ----------------------------------------------
|
||||
void portScan(){
|
||||
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");
|
||||
|
||||
}
|
||||
|
||||
void setup() {
|
||||
pinMode(LED_PIN, OUTPUT);
|
||||
|
||||
Reference in New Issue
Block a user