I am working on ESP8266 basic and want to implemenation I2C functionality
the I2C chip I am using is 24c32
We have written a code which is able to scan the device address but I am unable to read and wrtie to the device.
Kindly help us with the same
cls
button "i2c Find" [I2C_find]
button "i2c Read" [I2C_read]
button "i2c Write" [I2C_Write]
wait
[I2C_find]
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>"
got_address = address
endif
next
wait
[I2C_Write]
i2c.begin(got_address)
i2c.write(0)
delay 5
i2c.write(150)
i2c.end()
wprint "write complete"
wait
[I2C_read]
i2c.begin(got_address)
i2c.write(0)
i2c.end()
i2c.begin(got_address)
i2c.requestfrom(got_address,1)
delay 5
i2c_read = i2c.read()
i2c.end()
print i2c_read
wprint "read complete"
wait
Thanks and regards.
SIddharth