How to create a USB CDC device. (I'm using stm32f103c8 black pill board) and I want to read the data through USB in my raspberry pi as a serial port
You can use the one provided by generating it with STMCubeMx. This is going beyond arduino though. But it is highly feasible.