By all means I respect wanting to roll your own version of this. But if you would like to buy something to detect vehicles from your rear, there is something that already exists and is used commonly by cyclist. You may however need a bike computer as well, so it might get a bit expensive...
https://www.amazon.com/Garmin-Varia-Rearview-Radar-Light/dp/...