from machine import Pin, I2C
import time, ustruct, binascii
from time import sleep
i2c = I2C(0, scl=Pin(9), sda=Pin(8), freq = 400000) #Define the I2C pin and frequency
devices = i2c.scan()
if devices:
for d in devices:
print(hex(d))
as_addr = 0x50
as_reg_addr = 0x1a # Set I2C address
as_reg_save = 0x00 # Save configuration
as_reg_unlock = 0x69 # Unlock the module
data2 = b'x88xB5'
i2c.writeto_mem(as_addr, as_reg_unlock, data2)
sleep(0.5)
data3 = b'x10x00'
i2c.writeto_mem(as_addr, as_reg_addr, data3)
sleep(0.5)
data4 = b'x00x00'
i2c.writeto_mem(as_addr, as_reg_save, data4)
sleep(0.5)