Within this directory are a set of examples for different platforms the goal being to show the developer how to use the driver on each platform. The driver should be platform agnostic and the API should be the same regardless of whether you are on MCU or Linux/Mac. However what will change is the setup of the I2C bus.
When working on a desktop environment the sensor will be attached via FT232H Breakout Board
The different set ups are shown below in the architectural diagram:
When working with Desktop Linux you may find you need to install the following in order to work with the FT232H breakout board.
sudo apt update
sudo apt install libftdi1 libftdi1-dev
When working with MacOS you will need to install the following packages:
brew install libftdi
If you are having trouble it may be worth looking into:
or subsequently brew might not install correctly the libftdi library. It may be worth unlinking and linking the library using the following command:
brew unlink libftdi && brew link libftdi
When listing usb devices you might find lsusb
useful to which you will need to do the following:
sudo apt update
sudo apt install lsusb
brew install lsusb
When running the examples you can choose whether or not you are using the default features or not. The default in this case is using the F232H breakout Board. If for example you are on an embedded linux target such as Raspberry Pi 4 you can use the rpi
feature that will use the on board i2c hardware. This will swap the setup_i2c
method and allow the examples to work as expected.
cargo build
cargo run --example example_1_basic_readings # Choose your example to run here
cargo run --example example_1_basic_readings --no-default-features --features rpi # Run on Raspberry Pi using I2C
As the library adheres to the embedded-hal, the library should be able to run in no-std
environment. A esp32c3 example is shown here. Due to it using a baremetal environment its recommended to go to that directory and call cargo run
from within it and flash the code on to the device.
The examples provided for std
targets are heavily based off the corresponding Arduino/C++ Library written by Sparkfun linked here.
When working with FT32H, you must find the right device id, this can be done by using lsusb
:
❯ lsusb
Bus 003 Device 001: ID 1e91:4002 1e91 OWC Thunderbolt 3 Dock SD Card Reader Serial: 000000001616
Bus 003 Device 002: ID 1e91:4001 1e91 OWC Thunderbolt 3 Audio Device
Bus 003 Device 007: ID 0403:6014 Future Technology Devices International Limited Composite Device # This is the device here!!
Bus 000 Device 001: ID 1d6b:XHCI
XHCI
XHCI
1100 Linux Foundation USB 3.1 Bus
Bus 000 Device 001: ID 1d6b:1100
XHCI Linux Foundation USB 3.0 Bus
These numbers should match the numbers inside here.