wifi headless setup

Problem:
you need to setup the wifi connection and you don't have a display to do it trough graphic interface.

Solution:
You can plug the microSD card into a computer,a new Disk Unit will be available, there you can create a new file (wpa_supplicant.conf) for the wifi configuration file with the details example as you can see later in this same post.
If you have access to the command line ( you have a display ), you can do it using the command line tool once you are connected using ssh, just open the file wpa_supplicant.conf using the following commands:
# manual edition of the filesudo nano
  sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
# launch the config setup tool
 sudo raspi-config


Just edit the file with the correct SSID and password in the file that have to lloks like:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=<Insert 2 letter ISO 3166-1 country code here>
network={
 ssid="<Name of your wireless LAN>"
 psk="<Password for your wireless LAN>"
}

Source:
https://www.raspberrypi.org/documentation/configuration/wireless/headless.md

Hardware:
For old raspberry PI, you will need an wifi USB key like this:
TP-Link TL-WN725N Adaptador WiFi USB inalámbrico Nano, Compatible con Raspberry Pi, N 150 Mbps, Botón WPS, AP soft Windows10/8.1/8/7/XP, Mac OS X 10.7-10.11, Linux, negro