Skip to content
Discussion options

You must be logged in to vote

All the answers can be found here https://docs.micropython.org/en/latest/library/machine.I2C.html#machine-softi2c
Just some quick example of how it should be:

from machine import Pin, I2C

DEV_ADDR = 0x18
RANGESEL = 0x0F
XOUT1 = 0x02
XOUT2 = 0x03

i2c = I2C(scl=Pin(YOUR_SCL_PIN_NUMBER), sda=Pin(YOUR_SDA_PIN_NUMBER), freq=100000) # i2c init
i2c.writeto_mem(DEV_ADDR, RANGESEL, b'\x3') # selecting 2g. Hex "0x3" is the same as binary "0011"
xout1_reply = i2c.readfrom_mem(DEV_ADDR, XOUT1, 1) # read from device DEV_ADDR by XOUT1 memory address 1 byte. Same for XOUT2

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Bernd54Albrecht
Comment options

@uGinn-R
Comment options

Answer selected by Bernd54Albrecht
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants