// https://github.com/jordibinefa/IoT-02/tree/master/codes
// things.cat
//
// Code written by Jordi Binefa. 20200405
// Based on: https://playground.arduino.cc/Main/I2cScanner?action=sourceblock&num=1
#include <Wire.h>
#include "IoT-02_pinout.h"
#include "IoT-02_common.h"
void setup() {
Wire.begin(I2C_SDA, I2C_SCL);
vSetupIO();
Serial.begin(115200);
Serial.println(__FILE__);
}
void loop() {
byte error, address;
int nDevices;
Serial.println("Scanning I2C devices attached at IoT-02 board...");
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
}
esp:VIN
esp:GND.2
esp:D13
esp:D12
esp:D14
esp:D27
esp:D26
esp:D25
esp:D33
esp:D32
esp:D35
esp:D34
esp:VN
esp:VP
esp:EN
esp:3V3
esp:GND.1
esp:D15
esp:D2
esp:D4
esp:RX2
esp:TX2
esp:D5
esp:D18
esp:D19
esp:D21
esp:RX0
esp:TX0
esp:D22
esp:D23
ledW:A
ledW:C
r28:1
r28:2
r29:1
r29:2
ledR:A
ledR:C
r30:1
r30:2
ledY:A
ledY:C
r31:1
r31:2
ledG:A
ledG:C
sw1:1
sw1:2
sw1:3
r1:1
r1:2
r2:1
r2:2
sw2:1
sw2:2
sw2:3
ldr1:VCC
ldr1:GND
ldr1:DO
ldr1:AO
oled1:DATA
oled1:CLK
oled1:DC
oled1:RST
oled1:CS
oled1:3V3
oled1:VIN
oled1:GND