Bluetooth HC-06 disconnects after a few minutes.

HC-06 is in AT mode by default. About the only way you can get this wrong on the big internet is by following the wrong instructions. Reply #6 sounds normal. Any problem there is not Arduino.

You might find the following background notes useful.

http://homepages.ihug.com.au/~npyner/Arduino/GUIDE_2BT.pdf
http://homepages.ihug.com.au/~npyner/Arduino/BT_2_WAY.ino

Since you have mentioned a specific time, 20 sec, when this runs, perhaps it is time to see the code.