Re: I2C Scanner example
Posted: Thu Aug 04, 2016 8:02 am
It's a nEXT Evo board, big brother (or sister) of this one + AN-1 extension board
-->
Open Community Forum for ESP8266, Come share Arduino and IoT (Internet of Things)
https://www.esp8266.com/
i2c.setup(4,5)
for address = 1 to 127
i2c.begin(address)
stat = i2c.end()
if stat < 1 then
'print stat
wprint "Found I2C device at address: 0x" & hex(address)
wprint " - > " & address
wprint " <br>"
endif
next
wait
memclear
let address = 82 '82 which is what was scanned
i2c.setup(D3,D4)
i2c.begin(82)
i2c.write(64)
i2c.write(0)
i2c.end()
'delay 10
i2c.begin(82)
i2c.write(0)
i2c.end()
i2c.requestfrom(82,6)
b1 = (val(i2c.read()) xor 23) + 23
b2 = (val(i2c.read()) xor 23) + 23
b3 = i2c.read()
b4 = i2c.read()
b5 = i2c.read()
b6 = i2c.read()
print b1
print b2
print b3
print b4
print b5
print b6