How to use gravity sensor SEN0409 with unihiker
Hello everybody,
i wrote a script for my Raspberry 5 using pyQt5 and LIS Series Python Library for get acceleration from two DFRobot_LIS2DW12 devices [0x18 et 0x19].
I get the accelerations values, display to the widget and send it via websocket to another computer.
Now i want to do the same thing with an uniker board. Somebody have a small exemple for me? When i try, i have errors when i set the I2c channel.
By examining the source code of the pinpong library on pypi, you can see that there are five functions in pinpong for I2C data read and write:
- writeto(i2c_addr, value)- writeto_mem(i2c_addr, reg, value)- readfrom(i2c_addr, read_byte)- readfrom_mem(i2c_addr, reg, read_byte)- readfrom_mem_restart_transmission(i2c_addr, reg, read_byte)
This library has a version for Raspberry Pi. You can port the Raspberry Pi library to a version compatible with UNIHIKER. Generally, you only need to modify the initialization and I2C read/write functions. You can refer to the library I've ported:you:https://github.com/liliang9693/DFRobot_SGP40/tree/master/Python
If you read the information on this page: https://www.unihiker.com/wiki/system-framework , you will understand that the I2C interfaces of unihiker are provided from MCU. That means i2cdetect or usage of
LupinThat means i2cdetect or usage of smbus and similar will be very tricky (if possible)! I recommend to think in direction of: from machine import Pin, I2C!
Use the i2cdetect tool to check if your LIS2DW12 devices are properly connected to the I2C bus
lia.ifat