Best antenna for photon wifi

Im using a photon in a production environment and is installed in a metallic box, ice installed a small stub antenna externally but it keeps disconnecting, what’s the best antenna to use and do i need to enable the external antenna or will it automatically use this?

You have to enable external antenna for the external antenna to be used and be beneficial.

WiFi.selectAntenna() selects one of three antenna modes on your Photon or P1. It takes one argument: ANT_AUTO , ANT_INTERNAL or ANT_EXTERNAL . WiFi.selectAntenna() must be used inside another function like STARTUP(), setup(), or loop() to compile.

You may specify in code which antenna to use as the default at boot time using the STARTUP() macro.

Note that the antenna selection is remembered even after power off or when entering safe mode. This is to allow your device to be configured once and then continue to function with the selected antenna when applications are flashed that don’t specify which antenna to use.

This ensures that devices which must use the external antenna continue to use the external antenna in all cases even when the application code isn’t being executed (e.g. safe mode.)

If no antenna has been previously selected, the ANT_INTERNAL antenna will be chosen by default.

After having turned on the use of the external antenna - assuming that the stub antenna has been mounted outside the metallic box - the length and the direction of the stub or whip antenna do matter and you might need to try to improve the signal by measuring and monitoring this and playing with the orientation.