Supporting software to stream IMU (ICM-42688-p) connected to ESP32 via SPI onto desktop computer via serial or WiFi. Serial/UDP IO is handled in C++ and exposed to Python with pybind11.
Linux / MacOS
After cloning this project onto your computer:
- Build C++ driver with Python bindings (requires Boost):
mkdir build
cd build
cmake ..
makeOnce the package builds successfully, you can install the esp32comm Python package as described below.
Windows
Compilation of this package has been tested on a Windows 10 machine. The environment was setup as follows. Explicit versions used are listed, but these steps are expected to work with reasonably recent versions of these tools.
- Install git bash (2.30.1)
- Install CMake (3.19.5)
- Install Python (3.9.1)
- Install Visual Studio Community or Professional (Pro 2019, v16.8.5 with MSVC 14.28.29333)
- Install Boost (1.75.0,
boost_1_75_0-msvc-14.2-64.exe)
Once the development environment is setup, use git bash (or cmd) to run the following commands
$ git clone https://github.com/plusk01/esp32comm # clone this repo in your preferred directory
$ cd esp32comm
$ mkdir build
$ cd build
$ cmake -DBUILD_SHARED_LIBS=OFF ..
$ cmake --build . --target ALL_BUILD --config Release # or open in VS: start esp32comm.sln
$ cmake --build . --target pypkg --config Release # to tar python pkgOnce the package builds successfully, you can install the esp32comm Python package as described below.
Installing Python Package from Source
Install the built-from-source Python package with pip:
cd build
make pip-installFlash ESP32 with firmware_serial/firmware_serial.ino sketch for serial comm and firmware_udp/firmware_udp.ino for WiFi/UDP.
See an IMU data plot in real-time with python -m esp32comm.plotimu. Alternatively, you can see the frequency spectrum with python -m esp32comm.plotfreq
To create new or change existing messages, changes need to be made in esp32comm.h and in serial_driver.cpp. For these changes to appear in Python, py_teensyimu.cpp also needs to be changed. For an example of necessary changes, see this commit where two new messages (IMU_NoMag and IMU_3DOF) were added.
If messages are changed, this project must be built from source.