Context : One of the most debated issues about sub-mJy radio sources , which are responsible for the steepening of the 1.4 GHz source counts , is the origin of their radio emission . Particularly interesting , from this point of view , is the possibility of combining radio spectral index information with other observational properties to assess whether the sources are triggered by star formation or nuclear activity . Aims : The aim of this work is to study the optical and near infrared properties of a complete sample of 131 radio sources with S > 0.4 mJy , observed at both 1.4 and 5 GHz as part of the ATESP radio survey . The availability of multi–wavelength radio and optical information is exploited to infer the physical properties of the faint radio population . Methods : We use deep multi–colour ( UBVRIJK ) images , mostly taken in the framework of the ESO Deep Public Survey , to optically identify and derive photometric redshifts for the ATESP radio sources . Deep optical coverage and extensive colour information are available for 3/4 of the region covered by the radio sample . Typical depths of the images are U \sim 25 , B \sim 26 , V \sim 25.4 , R \sim 25.5 , I \sim 24.3 , 19.5 \leq K _ { s } \leq 20.2 , J \leq 22.2 . We also add shallower optical imaging and spectroscopy obtained previously in order to perform a global analysis of the radio sample . Results : Optical/near infrared counterparts are found for \sim 78 \% ( 66/85 ) of the radio sources in the region covered by the deep multi–colour imaging , and for 56 of these reliable estimates of the redshift and type are derived . We find that many of the sources with flat radio spectra are characterised by high radio–to–optical ratios ( R > 1000 ) , typical of classical powerful radio galaxies and quasars . Flat–spectrum sources with low R values are preferentially identified with early type galaxies , where the radio emission is most probably triggered by low–luminosity active galactic nuclei . Considering both early type galaxies and quasars as sources with an active nucleus , such sources largely dominate our sample ( 78 % ) . Flat–spectrum sources associated with early type galaxies are quite compact ( d < 10 - 30 kpc ) , suggesting core-dominated radio emission .