Embedded data pipeline: STM32 Nucleo + HY-SRF05 ultrasonic sensor, PlatformIO firmware, Python serial logger and visualizer.
Recording and graphing data retrieved over a serial bus using an STM32 Nucleo board, an HY-SRF05 Ultrasonic Range Sensor Module, Platform IO, and Python
In the Platform IO folder, two files can be found. platformio.ini is the configuration file for the Nucleo F446RE board being used to gather data from the HY-SRF05 sensor. main.cpp contains the setup and loop function for the board to receive input from the sensor.
In the main folder, three files can be found. Main.py contains the main function. This function contains a simple menu and calls to the other files in the Main folder and their functions. RecordData.py sets up serial bus recording as well as csv file creation to store the recorded data. DisplayData.py contains the function necessary to graph the files in the Recordings folder.
In the recordings folder, within the Main folder, there are sample recordings so that if you don't have a sensor and a board, you can still run and test the code.
This code can be modified to read any data from any platformio supported board. The main.cpp file will need to be modified the most of all the files depending on what sensor you are using. Pins will have to be reconfigured and most of the loop code will need to be completely rewritten. The board used here has an Arduino header that made the process a little easier.
In RecordData.py, you will need to change the serial port to whatever your port is. You can find this port on UNIX machines with ls /dev/tty.* in terminal. On Windows machines, you will have to run cmd, go into Powershell and enter [System.IO.Ports.SerialPort]::getportnames() . You will also, if you are on a windows machine, have to change the import from PurePosixPath to PureWindowsPath as well the instance on line 28.
The Recordings folder must be within the Main folder.
For display only mode, comment lines 2 and 10, and uncomment line 11 in main.py