1

I have a Lolin D1 mini ESP8266 and a 0.66" oled screen soldered on top. I have some running micropython (1.12) examples using the screen to show some text, but I would like to use the screen's I2C buttons as well.

According to the documentation, the screen has a default i2c address 0x3C (60) and buttons are 0x31 (49). If I connect to the REPL and run this:

from machine import Pin, I2C
i2c = I2C(scl=Pin(5), sda=Pin(4), freq=400000)
i2c.scan()

I get [49, 60] as expected.

Now I would like to read the buttons status, so having a look at Wemos' i2c-button-library, it seems that I have to proceed in the following way:

  • Send i2c command GET_KEY_VALUE (0x04) (1 byte) and get 1 ACK
  • Read i2c response (value from 0x00 to 0x04) (1 byte)

So I do:

i2c.writeto(49, b'4')  # returns 1, so I get 1 ACK, correct.
i2c.readfrom(49, 1)    # returns \x02

But all I get is \x02. Even if I read more bytes, I get \x02\xff\xff\xff\xff\xff\xff\xff\xff\xff. This response does not change when I hold the buttons.

What am I doing wrong?

4
  • I'd did a little searching... check this out... not 100% sure if its your issue though. instructables.com/id/… "At first I tried (and failed!) to connect the OLED module using I2C. Then I noticed that the OLED module had a little printed instruction on the back. In order to use it as an I2C module I had to rewire it by soldering and desoldering some resistors on the back. That's when I decided to aim for connecting it using the default configuration: 4 wire SPI." Commented Apr 10, 2020 at 14:44
  • 1
    I think it's not the same case. I am not using SPI (not sure if my module supports it even, as it is not stated in the specs) but I2C, and the oled is working. My problem relies with the I2C butons. Thanks for searching, though. Commented Apr 10, 2020 at 15:15
  • Did you get the official OLED module or a clone? Sometimes the clones are not the exact same. Perhaps add a photo of the board. Commented Apr 17, 2020 at 22:11
  • The original. The problem was that i was writing b’4’ instead of b’x\04’. Commented Apr 17, 2020 at 22:21

1 Answer 1

1

Problem has been solved. I should have sent b’\x04’ instead of b’4’.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for coming back and posting the answer!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.