- Sun Jan 17, 2016 7:10 am
#39038
just to get you started:
I2CROM (i tested it with the 24C512)
The example uses addr 0 (16xadr_hi + adr_lo) to write/read the value of databyte
The I2C_adr depends on your hardware. if you tie A0,A1, A2of the mem-chip to ground the address is 80
Code: Select allprint "Created with ESP Basic 1.76"
let I2C_adr = 80
let databyte = 170
let adr_hi = 0
let adr_lo = 0
button "write" [I2C_write]
button "read" [I2C_read]
button "exit" [Exit]
wait
[Exit]
print "end"
end
[I2C_write]
i2c.begin(I2C_adr)
i2c.write(adr_hi)
i2c.write(adr_lo)
i2c.write(databyte)
i2c.end()
wait
[I2C_read]
i2c.begin(I2C_adr)
i2c.write(adr_hi)
i2c.write(adr_lo)
i2c.end()
i2c.requestfrom(I2C_adr,1)
x = i2c.read()
i2c.end()
print x
wait
[img]24C512.png[/img]
To use a RTC like the DS1307 the code is nearly the same. It uses 8bit address so no need to use adr_hi. Change the I2C_adr to 104.
Reading the SHT21 is something completely different as it is not 1-wire compatible.
You do not have the required permissions to view the files attached to this post.