Arduino i2c scanner (ESP8266)
This is a basic example which will display via the serial monitor the address of any devices connected to your Wemos / Nodemcu. Download code here Code.
Its the same as one used on Arduino’s.

#include "Wire.h"
void setup()
{
Wire.begin();
Serial.begin(115200);
while (!Serial); // Leonardo: wait for serial monitor
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 0="" 0x="" 5="" address="" at="" delay="" devices="" done="" else="" error="" for="" found="" i2c="" if="" n="" ndevices="=" next="" nknown="" o="" pre="" scan="" seconds="" serial.print="" serial.println="" wait="">
16>
No comments