I found a solution, follow the steps:
1 – update the php file mobile-detect.php to the last version(see https://github.com/serbanghita/Mobile-Detect/blob/master/Mobile_Detect.php), you only have to copy and paste the code.
2 – Edit the file wp-config.php. In my case I only want to detect if the browser is a phone or not, so if you have a different situation you’ll need to change the code a little bit.
So, before require_once(ABSPATH . ‘wp-settings.php’); add the following code: https://pastebin.com/kFNx9bZe
Change yourdomain.com to the domain of your website
3 – Edit the W3TC php file: /plugins/w3-total-cache/lib/W3/CacheCase.php, look for the method public function get_group() and change as the following: https://pastebin.com/kU3zTiZx
4 – At the last step you`ll have to go to W3 Total Cache Menu > User Agent Groups and create a new group named -> use_mobile_cache
Let it enabled and the user agents field empty.
Remember: this solution it only detect if the browser is a phone or not and the w3 total cache plugin create 2 differents cache: one for desktop and tablets and other to phones