To me the best way to learn it to try things on an actual example. So decided to try interfacing the sensors to the MCU and sending/receiving data from the MPU. So this is from the readme I put together for my app.
A few things that I tried to accomplish with the app:
-
Installing libraries. Local libraries on the pc are not available to the linux side. Have to redown load libraries.
-
How to install packages that you might want to use
-
How to transfer data back and forth
-
And any gotchas
The app reads in data from the BMI270 and the BMM150 on the arduino side and transfers the accl/gyro/mag data to the linux side for process through a Madgwick filter using a AHRS package. Once processed Roll/Pitch/Yaw are transferred back to the Arduino.
Installing libraries
On the left side of AppLab Click on the Add libraries icon. When the pop up appears I had to actually type in the name of the whole name of the library
-
SparkFun BMI270 Arduino Library
-
DFRobot_BMM150
Modify platform.txt so libs can use things like M_PI
-
cd ~/.arduino15/packages/arduino/hardware/zephyr/0.51.0
-
nano platform.txt
-
change compiler.cpp.flags to
Copy
compiler.cpp.flags=-g -Os -std=gnu++17 -c -D_XOPEN_SOURCE=700 {compiler.warning_flags} {compiler.zephyr.macros} "@{compiler.zephyr.cxxflags_file}" {compiler.zephyr.common_ldflags} {compiler.zephyr.extra_ldflags} {compiler.zephyr.common_cxxflags} {compiler.zephyr.extra_cxxflags} -MMD -mcpu={build.mcu} {build.float-abi} {build.fpu}
- save and exit from nano
Add AHRS package to install list
Under Python Files create a requirements.txt file and enter ahrs into the file save and run. This will install the python package
To add Python packages to your application, select the main.py file and click on the “Add file“ icon. Create a requirements.txt file and list the Python packages you need. See Requirements File Format - pip documentation v25.2 for more information.
For more info on the package
Now with that out of the way I then had the MCU (arduino) send data to a telemetry app once I received it from the MCU - Roll/pitch/yaw - and it worked.
To get data back and forth pretty much stuck to the basic bridge function, i.e., Bridge.provide and Bridge.notify. Not sure if this is the best approach so am going to attach the python and arduino sketches. NOTE: Not hooked up with SSD and scp doesnt seem to work without it. Alot of prints are commented out. Guess next thing is maybe try sending things to the web ![]()
Cheers.
python_sketch.txt (2.2 KB)
telemetry.txt (1.3 KB)
arduino_sketch.txt (3.7 KB)
