-->
Page 1 of 6

I2C help needed

PostPosted: Sun Dec 13, 2015 10:28 am
by viscomjim
I am working on a project to show the use of a 4 digit I2C display that I successfully was able to implement using the micromite. This chip is also programmed in basic, so I am trying to port over this project to the ESP. If I can figure out why this code is not working, it will make for a pretty cool project for Mikes website.

The following is a very stripped down bit of code just to show what I need to get working on the esp.

This program works with the display on the micromite...

Code: Select allI2C OPEN 100,100     'OPEN I2C PORT

‘CONFIGURE DISPLAY
I2C WRITE &H70, 0, 1, &H21
I2C WRITE &H70, 0, 1, &H81
I2C WRITE &H70, 0, 1, &HEF

I2C WRITE &H70, 0, 2, &H00, &H06 ‘FIRST DIGIT
I2C WRITE &H70, 0, 2, &H02, &H5B ’SECOND DIGIT
I2C WRITE &H70, 0, 2, &H06, &H4F ‘THIRD DIGIT
I2C WRITE &H70, 0, 2, &H08, &H66 ’FORTH DIGIT

END


The four lines toward the end are sending 2 bytes each to the display to show a number on each digit. Again, this code does work.

This is what I converted it to for the esp and can not for the life of me figure out why it won't work... I do have 4.7k pull-ups on the gpio's and am using GPIO0 for SDA and GPIO2 for SCL.

Code: Select allmemclear

address = 112  'HEX 70

i2c.begin(address)
i2c.write(33)    ‘HEX 21
i2c.write(129)  ’HEX 81
i2c.write(239)  ‘HEX EF
i2c.end()

delay 10

i2c.begin(address)  ’FIRST DIGIT
i2c.write(0)
i2c.write(6)
i2c.end()
delay 10

i2c.begin(address)  ‘SECOND DIGIT
i2c.write(2)
i2c.write(90)
i2c.end()
delay 10

i2c.begin(address)  ’THRID DIGIT
i2c.write(6)
i2c.write(79)
i2c.end()
delay 10

i2c.begin(address)  ‘FORTH DIGIT
i2c.write(8)
i2c.write(102)
i2c.end()
delay 10

end

Re: I2C help needed

PostPosted: Sun Dec 13, 2015 11:31 am
by matherp
Don't know if it is the answer but you are missing the brackets on the i2c.end for the 4 digits

Re: I2C help needed

PostPosted: Sun Dec 13, 2015 11:34 am
by Mmiscool
Yes
With out the patenthacys it would not interpreter or exicute that line as a function.

Re: I2C help needed

PostPosted: Sun Dec 13, 2015 11:39 am
by viscomjim
Hi Matherp and Mike, good catch, but no difference. I am at a loss.

EDIT, I fixed the code in the first post on this thread to reflect the change.

Does the esp use addressing differently than the micromite? On the uMite, the display works at address &H70, should this be different on the esp?