-->
Page 1 of 3

ESP8266 with 24C32 memory IC + esp8266basic

PostPosted: Mon Jan 09, 2017 1:53 am
by siddharthtaunk
Hi,

We want to interface t5he 24c32 i2c eeprom IC with the esp85266 and using esp8266basic. We have tested the hardware with arduino and it works fine. Now we are trying to interface it with the esp8266 but only the I2C find function works. We are not sure whether the writing or the reading is happening properly or not. Kindly shed some light of the issue. I preset here with the code

Code: Select allcls

let eeprom_address = 0
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
      print "Found I2C device at address: 0x" & hex(address)
      print " - > " & address
      print " <br>"
      got_address = address
endif
next
wait

[I2C_Write]
 print "writing to address " & got_address
 i2c.begin(got_address)
 i2c.write(eeprom_address >> 8)
 i2c.write(eeprom_address)
 i2c.write("A")
 i2c.end()
 print "write complete"
wait

[I2C_read]
  print "reading from address " & got_address
  i2c.begin(got_address)
  i2c.write(eeprom_address >> 8)
  i2c.write(eeprom_address)
  i2c.end()

  i2c.requestfrom(got_address,1)
  if i2c.available() then
     i2c_read = i2c.read()
     i2c.end()   
     print  "the data is " & i2c_read
  end if
  print "read complete"
wait


please help

regards.
Siddhath

Re: ESP8266 with 24C32 memory IC + esp8266basic

PostPosted: Mon Jan 09, 2017 3:54 am
by Mmiscool
Hello,

I glanced at your source code.

Looks like your button statements are misformatted.

Need to ad a comma between the text for the button and the target branch label otherwise it won't do any thing.

Code: Select allbutton "i2c Find", [I2C_find]

Re: ESP8266 with 24C32 memory IC + esp8266basic

PostPosted: Mon Jan 09, 2017 3:58 am
by siddharthtaunk
Hi,

Adding a ',' is not helping
still the same results

Re: ESP8266 with 24C32 memory IC + esp8266basic

PostPosted: Mon Jan 09, 2017 4:00 am
by Mmiscool
What version of esp basic are you using?