I am using a Raspberry PI Zero W with a small housing. The OBD2 port is connected with a simple USB cable (TTL converter). That works great to me. Since I am a shell script man this is what I did:
# Set Serial Line parameter
stty -F /dev/ttyUSB0 0:0:1002:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0
# Read line in background
tail -f /dev/ttyUSB0 >$LOG &
# send commands to line
echo >/dev/ttyUSB0
sleep 1
echo time >/dev/ttyUSB0
sleep 1
echo bms interface >/dev/ttyUSB0
sleep 2
echo performance >/dev/ttyUSB0
sleep 2
......
# stop writing to log file
pkill -P $$
# delete non-printable characters
strings $LOG >$FILE
# Do what you please with the log file $FILE (analyze, store params to mysql database, FTP to your server, ...)
I am sure it will be no rocket science to apply this logic to any script langue you prefer to work with. The Raspberry PI is permanently connected to OBD2 and USB and stores data to a mysql database. This way I learned a lot about the bike. I also tested a simple 2G hat to permanently connect the device to the internet, but learned, that the PI Zero with the additional hat draws too much power from the Zero USB port and malfunctions. For now I only store data in a local database and synchronize if connected with WIFI.