Thor96 is an NXP i.MX8MQ board produced by eInfoChips, an Arrow company. It is part of 96boards.org Consumer Edition line.
The first step is to obtain a stable system. The one provided by manufacturer on sdcard proved to be unstable.
Step 1. Get software on the board.There can be two ways:
1.1 Official Yocto BSP. Download the release files from https://github.com/ArrowElectronics/I.IMX8_Thor96/releases/tag/Prod_Rel_v2.3. Build Yocto and write it to sdcard. Informations on how to build are here: https://www.96boards.org/documentation/consumer/thor96/
1.2 Use only needed steps for building kernel, u-boot and then use whatever Linux you need. Follow steps from https://github.com/iohe/thor96
Step 2. Hook SPS30 to Thor96 board.Read specs and learn that SPS30 does not function with Thor96 1.8V.
Since multiple voltage level translators were available, after reading specs it was determined that SparkFun Level Translator Breakout - PCA9306 v2 would be a good choice. Its specs claimed it is very good for I2C protocol. Other Level Translators were available and determined not fit for this project: TXB0104, because of lack of I2C support.
Hook Thor96, PCA9306 and SPS30, and optionally, a Logic analyzer then start system. Connections must match the wiring diagram from the project.
Fun fact: Thor96 already has on i2c-0 bus a device on 0x69 address.
Therefore, we need to use i2c-1 bus, hence the connections.
Step 3. Read SPS30 data.Connect Thor96 board to internet, install Rust language and cargo. Follow steps from here: https://rustup.rs/
Then, compile SPS30-i2c rust driver and test it by running its example. Remember to change in example to use i2c-1 bus.
Output will be gibberish, but always same! Time for some debugging!
Step 4. DebugAttach logic analyzer and inspect a capture. Looks like the speed of the bus is not correct, as also the output. Timing is certainly not 100khz, the only speed supported by SPS30.
od -bc /proc/device-tree/i2c\@XXXXXX/clock-frequency
Clock for i2c-1 was 384000! Checking the source device tree, there was the setting:
+&i2c1 {
+ clock-frequency = <384000>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_i2c1>;
+ status = "okay";
Check linux source file arch/arm64/boot/dts/freescale/fsl-imx8mq-thor96.dts and change speed to 100000. Recompile dts and copy dtb to first partition of sdcard. Reboot.
Recheck example and verify that it works ok now.
For awesome pics published to Azure IoT Hub, check out this project:
https://www.hackster.io/david-gherghita/air-quality-monitor-using-raspberry-pi-4-and-sps30-03cb42
Comments
Please log in or sign up to comment.