Introduction {#Sec1}
============

What if the front surface of a solar cell were functionalized to work as an optical sensor? This question was asked and answered a long time ago in previous published results. The answer includes materials and sensitized coatings to selectively detect some specimens and substances using solar cells. The published results report applications for optical sensing^[@CR1]^, gas sensing^[@CR2],[@CR3]^, refractive index sensing^[@CR4]--[@CR7]^, chemical sensing^[@CR8]^, and multi-functional sensors^[@CR9]^. The advantage is clear: the signal is directly generated by the solar cell and, ideally, there is no need for sophisticated and voluminous read-out elements (goniometers and spectrometer for angular and spectral interrogation techniques)^[@CR10]--[@CR12]^.

The measurement of the variation in the index of refraction is one of the most successful strategies for optical sensing of a variety of compounds^[@CR13]--[@CR17]^. Basically, the optical sensor becomes a refractometric sensor. This approach can be applied to self-powered sensors based on solar cells^[@CR3]^. Although this side effect application of solar cells may seem exotic, we will show how nanophotonic structures boost the capabilities of perovskite-based solar cells for their use as refractometric sensors. This transformation from a solar cell to a sensor also implies a discussion to properly describe the performance of the system as a dedicated refractometric sensors, or as a solar cell.

In this contribution, we numerically analyze and propose a modified perovskite solar cell to work as a refractometric sensor for gases. Silicon solar cells could be considered as a first choice because of its stability and durability. However, in the last decade, perovskite cells have demonstrated a fast performance enhancement in terms of efficiency and durability^[@CR18]--[@CR20]^. Although there are some problems still to be solved (reliability, degradation, etc.)^[@CR21]^, these devices are one of the most promising players in photovoltaic technologies, and perovskite solar cells are currently considered as one of the possible silicon substitutes. An interesting use for the device presented in this contribution is in environmental research applications, as well as in industrial inert atmospheres or laboratory clean rooms^[@CR22],[@CR23]^. As a simple sensor fore gases, it may help to detect volatile compounds with potential environmental hazard, and to monitor air quality parameters and gas composition^[@CR24]--[@CR33]^. The measurement of the index of refraction of air, as an ubiquitous gas, is of interest since long ago^[@CR34]--[@CR36]^. Several proposals have been presented to monitor air quality and composition^[@CR23],[@CR29]--[@CR31]^. It is also known, that the index of refraction of air, or any other gas or gas mixture, depends on physical parameters (temperature and pressure) and chemical composition (humidity, presence of natural or artificial specimens). Then, a refractometric sensor can check if some preset conditions are fulfilled, or a known specimen varies its concentration. To do that, several optical technologies have been applied to sense refractometric changes in gases. For example, we can find interferometric systems^[@CR14],[@CR37]--[@CR40]^ plasmonic devices^[@CR31],[@CR41]--[@CR43]^, or sensor based on specialized fibers and photonic crystals^[@CR23],[@CR26],[@CR32],[@CR44],[@CR45]^. Our system, based on the selective resonances generated by subwavelength metallic gratings on a modified perovskite cell can provide an alternative. The capabilities of optical gas sensors rely on the accuracy and resolution of the involved optical instruments. A high-performance sensor requires high quality optical subsystems, making the device more complex and expensive. The sensor proposed in this contribution delivers an electric signal to voltage, or current, meters, that are, by far, more available at lower cost.

Figure [1a](#Fig1){ref-type="fig"} shows a typical layer structure used for perovskite solar cells illuminated from the substrate^[@CR46],[@CR47]^. In the same figure we have also evaluated the spectral absorption for two values of the index of refraction of the media in contact with the front surface (see Fig. [1b](#Fig1){ref-type="fig"}). Our first approach is to consider air as the analyte (*n*~*a*~ = 1), and slightly change its index of refraction while we monitor the response of the system. The details of this calculation are given in the following section 2. In energy harvesting applications, the performance of the cell is parameterized with its efficiency, which is related to the short-circuit current, or the short-circuit density current, delivered by the cell, *I*~*sc*~ or *J*~*sc*~, respectively. This current is proportional to the optical absorbed power at the active layer of the cell, that also depends on the spectral composition of the radiation. In our analysis, we can numerically evaluate the absorbed power within the perovskite layer, $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${A}_{{\rm{p}}{\rm{e}}{\rm{r}}{\rm{o}}{\rm{v}}}$$\end{document}$, and therefore obtain the opto-electronic response of the cell^[@CR48]^. This signal is also dependent on the index of refraction of the medium in front of the cell that becomes the analyte. Therefore, we evaluate the sensitivity of the cell as a sensor, which is defined as the change of a physical property of the device with respect to an environmental change. In this case, we use the responsivity of the cell, *R* (in mA/W), as the parameter that changes with the refractive index of the analyte, *n*~*a*~.^[@CR49],[@CR50]^. In Fig. [1c](#Fig1){ref-type="fig"} we represent the change in responsivity, R, as a function of the index of refraction of the analyte when the system is illuminated at *λ* = 600 nm and 50 mW/cm^2^ in irradiance. When *I*~sc~ is used to define the sensitivity, $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${S}_{B}=\partial {I}_{{\rm{s}}c}/\partial {n}_{a}$$\end{document}$, we find a value of $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${S}_{B}\mathrm{=190}$$\end{document}$ mA/RIU (where RIU means refractive index units). However, when using responsivity, we obtain $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${S}_{B}=\partial R/\partial {n}_{a}\mathrm{=70}$$\end{document}$ mA/(W.RIU). We use responsivity because of its robustness and flexibility to define the sensitivity independently from the power of the source illuminating the cell. As it is being demonstrated, this idea shows potential that it is worth exploring. Therefore, the next step is to change the design of the cell and improve its optical sensor's performance, while maintaining the structure of a working perovskite solar cell. This approach would allow an easy implementation, so customized solar cells could work as refractometric sensors. A similar approach has been successfully proved when adapting a CMOS device for sensing^[@CR51]^, and when perovskite photodetectors are used in visible light communication systems^[@CR52]^. The solar cells becomes closer to a photodetector when the delivered electric signal varies for changes in *n*~*a*~, acting like a sensor. Then, the performance parameters commonly used in sensing (sensitivity, figure of merit, FOM) may not be directly applicable here, so the capabilities of the system should be related with detection figures of merit as responsivity, noise equivalent power, detectivity, etc^[@CR52],[@CR53]^.Figure 1(**a**) Layer structure of a perovskite solar cell. The cell is illuminated through the SiO~2~ (glass) substrate. From top to bottom: air, glass (SiO~2~, $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${t}_{{\rm{S}}i{O}_{2}}\mathrm{=3}$$\end{document}$ mm), top electrode (ITO, $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${t}_{{\rm{I}}TO}\mathrm{=70}$$\end{document}$ nm), buffer layer (TiO~2~, $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${t}_{{\rm{T}}i{O}_{2}}\mathrm{=30}$$\end{document}$ nm), active layer (perovskite, $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${t}_{{\rm{p}}{\rm{e}}{\rm{r}}{\rm{o}}{\rm{v}}{\rm{s}}}\mathrm{=300}$$\end{document}$ nm), buffer layer ($\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${t}_{{\rm{s}}{\rm{p}}{\rm{i}}{\rm{r}}{\rm{o}}}\mathrm{=160}$$\end{document}$ nm), and bottom electrode ($\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${t}_{{\rm{A}}u}\mathrm{=200}$$\end{document}$ nm). (**b**) Spectral absorption of active layer for two indices of refraction of the outer medium, n~*a*~ = 1.0 and *n*~*a*~ =1.1. (**c**) Responsivity, *R* as a function of *n*. The sensitivity of this device is given by the slope of the linear fit: *S*~*B*~ = 70 mA/(W.RIU).

Materials and methods {#Sec2}
=====================

The performance as a refractometric sensor of a planar perovskite solar cell with an Indium Tin Oxide (ITO) top contact is not competitive. However, we can improve the device by replacing the ITO top electrode by a nanostructured metallic layer. Also, we move the SiO~2~ substrate (or any other substrate, including flexible materials) behind the non transparent gold electrode to expose the front surface to the analyte. In this way, we mostly preserve the structure of the solar cell and act only on the surface of a flipped, almost-finished, functional device. This arrangement allows a flexible substrate, and has been used in similar devices^[@CR54]--[@CR56]^. The geometry and material choice for the top contact, presented in Fig. [2a](#Fig2){ref-type="fig"}, is a metallic thin layer (in our case, a silver layer with a thickness of *t*~*m*~ =150 nm), where periodic slits are etched to trigger funneling light mechanisms at selected wavelengths^[@CR57]^. The sub-wavelength period of the grating, $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$p=375$$\end{document}$ nm, precludes the existence of high-order diffraction modes. Consequently, the aperture is also subwavelength, having a width $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\rm{GW}}=50$$\end{document}$ nm, and showing a high aspect ratio with a height equal to the thickness of the metallic layer ($\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\rm{GH}}={t}_{m}=150AS$$\end{document}$ nm), meaning that the slit reaches the TiO~2~ buffer layer. We have used COMSOL Multiphysics as a computational electromagnetism tool. The reliability of this approach has been proved in several analysis of nanophotonic devices, involving a variety of situations and physical mechanisms^[@CR58]--[@CR61]^. The calculation is made in two steps. First, a linearly polarized monochromatic wave illuminates the structure from the air. The magnetic vector is oriented along the direction of the slits, i.e., perpendicular to the plane represented in Fig. [2c](#Fig2){ref-type="fig"}. Then, the energy absorbed at the active layer is calculated using the material parameters of every layer in the structure. This is a 2D simulation because we consider an extruded geometry along the direction of the slits. The period of the subwavelength grating is repeated using periodic boundary conditions. The result is the identification of several peaks in the spectral absorption, which correspond to selective resonances of the nanostructured subwavelength grating. The second step transforms this absorbed power assuming that each photon generates a hole-electron pair that is collected by the top and bottom electrodes (assuming a collection efficiency equal to 1). This combined mechanism (selective absorption + current generation), and a monochromatic illumination allow refractometric sensing. Figure [2b](#Fig2){ref-type="fig"} shows the spectral absorption at the active layer for the proposed structure and geometry. This spectral shape is clearly different from the one belonging to a conventional perovskite solar cell (see Fig. [1b](#Fig1){ref-type="fig"}), and shows three maxima in the spectral absorption, located at $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\lambda }_{{\rm{I}}}=385$$\end{document}$ nm, $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\lambda }_{{\rm{II}}}=715$$\end{document}$ nm, and $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\lambda }_{{\rm{III}}}=783$$\end{document}$ nm. It shows more peaks at different wavelengths, but these three are the most relevant in the analyzed spectral range. If we compare Figs. [1b](#Fig1){ref-type="fig"} and [2b](#Fig2){ref-type="fig"}, we see a relative low value in absorption for the modified cell. The main reason for this decreased absorption is the high reflection caused by the silver non-transparent top electrode that replaces the ITO layer. Since our goal is not energy harvesting, instead of enhancing the total photo-generated current generated by a broadband spectrum, we aim to increase the variation of the photo-current delivered by the device with respect to a change in the index of refraction. The device is illuminated with a monochromatic laser source centered at one of the maximum absorption wavelengths. This increases the variation of the current when changing the index of refraction. The next optimization step is to find the geometry of the apertures that maximizes the short-circuit current of the solar cell at each peak. When done, this optimization will provide higher values in absorption for each wavelength, as we will show in the following section (see also Fig. [3](#Fig3){ref-type="fig"}).

To understand the origin of each peak, we plot the Poynting vector and the electric field vector maps (see inset in Fig. [2a,c](#Fig2){ref-type="fig"}). The observed maxima have different field distributions along the structure, where resonances II and III generate stronger fields within the active layer. The peak at $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\lambda }_{{\rm{I}}}$$\end{document}$ is related to plasmonic resonances caused by the periodic narrow slit. This origin is supported by the presence of hot spots in the electric field distribution at the metal/air interface (see Fig. [2c](#Fig2){ref-type="fig"}). The radiation at $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\lambda }_{{\rm{II}}}$$\end{document}$ funnels through the gap until reaching the active layer^[@CR62]^. The peak at $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\lambda }_{{\rm{III}}}$$\end{document}$ corresponds to the strongest field distribution at the active layer. However, as we will see when analyzing its behavior with respect to the index of refraction of the analyte, this peak does not shift significantly in wavelength when changing the index of refraction, and should not be caused by a plasmonic resonance but by selective transmission through the apertures^[@CR62]^.Figure 2(**a**) Layer structure of a perovskite solar cell where the top electrode has been replaced by a nanostructured metallic layer having a thickness of $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${t}_{{\rm{A}}g}\mathrm{=150}$$\end{document}$ nm. A periodic grating with subwavelength period, *p* = 375 nm, and apertures, GW = 50 nm, allows light funneling towards the active layer of the cell. The inset at the left show three maps of the Poynting vector where we see how the power is directed towards different portions of the solar cell for $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\lambda }_{{\rm{I}}}$$\end{document}$, $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\lambda }_{{\rm{I}}{\rm{I}}}$$\end{document}$, and $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\lambda }_{{\rm{I}}{\rm{I}}{\rm{I}}}$$\end{document}$. (**b**) Spectral reflectance of the structure (black dotted line), and spectral absorption of the active layer (red solid line). Both the spectral absorption and reflectance show three peaks (I, II, and III) at $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\lambda }_{{\rm{I}}}\mathrm{=385}$$\end{document}$ nm, $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\lambda }_{{\rm{I}}{\rm{I}}}\mathrm{=715}$$\end{document}$ nm, and $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\lambda }_{{\rm{I}}{\rm{I}}{\rm{I}}}\mathrm{=783}$$\end{document}$ nm. (**c**) Electric field distribution for the same wavelengths considered in (**a**,**b**). The three resonances show their maximum amplitude at different layers within the solar cell.Figure 3Maps of the absorption at the perovskite active layer, $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${A}_{{\rm{perov}}}$$\end{document}$, in terms of the height (GH) and width (GW) of the slits, maintaining the thickness of the metal layer, and the grating period. Each map corresponds to one of the three spectral resonances centered at $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\lambda }_{{\rm{I}}},{\lambda }_{{\rm{II}}}$$\end{document}$, and $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\lambda }_{{\rm{III}}}$$\end{document}$. There are two maxima for $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\lambda }_{{\rm{II}}}$$\end{document}$, labeled as \# II-wide and \# II-narrow according to the width of the slit. The value of $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${A}_{{\rm{perov}}}$$\end{document}$ is given for every optimum design. We have represented these plots using colormaps with different ranges to emphasize the variations for each case. Therefore, the comparison between maps should consider the applicable ranges. The optimum designs are marked and labeled as in Table [1](#Tab1){ref-type="table"}.Table 1Optimized geometrical parameters of the low-order diffraction grating.*λ* \[nm\]label*p* \[nm\]GW \[nm\]GH = *t*~*m*~ \[nm\]385\# I37580125715\# II-narrow37540140\# II-wide375150110783\# III37575140.

Optimization {#Sec3}
------------

We focus on engineering an opto-electronically interrogated device able to sense changes in the index of refraction of the analyte. We will show the geometry of the design and the operation wavelengths where the proposed system provides the largest variation of the electric signal with respect to the index of refraction of the environment. In some cases, the spectral shift of the optical response of the optimized geometry allows to operate the device using spectral interrogation techniques.

The common geometry and material arrangement of a perovskite solar cell can be seen in Fig. [1a](#Fig1){ref-type="fig"}. This basic design is modified at the top surface: the ITO transparent electrode is replaced by a nanostructured metallic layer (see Fig. [2a](#Fig2){ref-type="fig"}). When including it on top of the active persovskite layer, the absorption drops. It decreases because the metallic coating is highly reflective and also dissipates energy causing losses. However, at some selected wavelengths, the absorption at the active layer, and consequently the output signal delivered by the cell, increases due to this subwavelength grating. The slits grooved on the metallic coating generate funneling and plasmonic resonances that selectively increase the amount of energy reaching the perovskite layer. The analysis of the system requires the definition of a function of merit for optimization purposes. In this case, we select the amount of energy absorbed by the perovskite active layer as the function of merit. The reason for this choice is the direct relation between the signal delivered from the cell and the absorption at the perovskite layer. The evaluation of the optical parameters is made using the high-frequency module of the multiphysic computational package Comsol Multiphysics. Due to the geometry selected in this analysis, that is an extruded 2D arrangement, the calculation can be made in 2D, allowing a faster and more reliable optimization. The structure is excited with a plane wavefront under normal incidence conditions, and having a total irradiance of 50 mW/cm^2^. The state of polarization is perpendicular to the extruded direction (the electric field vector is contained within the plane where the electric field maps in Fig. [2c](#Fig2){ref-type="fig"} are plotted, TM polarization). Periodic boundary conditions are set on both sides of the unit cell to represent an infinite array of nanoslits. Each portion of the structure is defined geometrically and optically using its complex refractive index. The photo-generated current is calculated through the absorption of the incident radiation at the active layer.

The optimization is made by a parametric sweeping of the geometry of the nanostructure (GW and GH). In practice, we maximize the optical absorption at the solar cell active layer, $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${A}_{{\rm{p}}{\rm{e}}{\rm{r}}{\rm{o}}{\rm{v}}}$$\end{document}$. We maximize it for those wavelengths generating a large absorption at the active layer because they will generate a large electric signal, which is better suited to sense environmental changes. After optimizing this variable, we have obtained the spectral absorption for the three wavelengths of interest. The actual parameters that maximize absorption are given in Table [1](#Tab1){ref-type="table"} for each wavelength. So, we have maximized the amount of energy absorbed at the perovskite active layer through the combination of plasmonic resonances, funneling effects and selective transmission, by varying the geometrical parameters of the slits. In Figure [3](#Fig3){ref-type="fig"} we represent the maps of the absorption at the perovskite active layer, $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${A}_{{\rm{perov}}}$$\end{document}$, in terms of the width (GW) and height (GH) of the slits, for each wavelength of the resonances identified previously (see labels in Table [1](#Tab1){ref-type="table"}).

Results and Discussion {#Sec4}
======================

We can see that the maximum absorption, $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${A}_{{\rm{perov}}}=\mathrm{94 \% }$$\end{document}$ (see Fig. [3b](#Fig3){ref-type="fig"}), is obtained for a wide slit at $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\lambda }_{{\rm{II}}}=715$$\end{document}$ nm. The colormap of these plots has been normalized independently for each wavelength. Obviously, to compare the results among them, it is necessary to consider the maximum value for each one. Figure [4](#Fig4){ref-type="fig"} shows the spectral absorption of the optimized devices for each wavelength previously selected (see Fig. [3](#Fig3){ref-type="fig"} and Table [1](#Tab1){ref-type="table"}). We see how the absorbed power is significantly larger after optmization.Figure 4Spectral absorption in the active layer for the optimum geometrical parameters at the three resonant wavelengths. the absorption in the active layer for the design with the arbitrary selected geometry is included for each case to show the effect of the optimization process.

To explore the capabilities of the proposed device for spectral and opto-electronic interrogation methods, we have evaluated the spectral absorption for each optimized case, and for two different values of the index of refraction, *n*~*a*~ = 1.0 and 1.1. This range is much larger than the expected variations in the index of refraction, and explores how this device behaves when adding nebulized liquids in the atmosphere, or when the analyte is under extreme values of pressure and temperature^[@CR38]^. Besides, this extended range reveals better how the spectral absorption changes with respect to the index of refraction (as shown in Fig. [5](#Fig2){ref-type="fig"}). In our calculation, we have considered the gases as non-absorptive (meaning a negligible value of the imaginary part of the index of refraction). We have also neglected the contribution of scattering, but this simplification should be raised if nano- and micrometer size particles were taken into account^[@CR63]^. In Fig. [5](#Fig5){ref-type="fig"}, we show how each design undergoes a spectral shift, Δ*λ*, and absorption intensity change, Δ*I*, as the refractive index changes. In this last case, a variation in the absorption at the active layer translates in a change in the photo-generated current, and hence in responsivity. A larger Δ*λ*, or Δ*I*, means a higher sensitivity because it generates a larger measurable change when the index of refraction varies. However, the measurement method is different: Δ*λ* is obtained through a spectral interrogation scheme, and Δ*I* is measured using an opto-electronic set-up where the electric signal delivered by the cell is processed by an external circuit. In this case, the electronic output signal of the device senses the variation of the refractive index, which means an opto-electronic interrogation.Figure 5Spectral absorption for the four optimized designs at the three resonant wavelengths. These absorptions are calculated for two values of the index of refraction of the analyte, $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${n}_{a}\mathrm{=1.0}$$\end{document}$ and 1.1. The vertical blue dotted line represents the wavelength of resonance for $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${n}_{a}\mathrm{=1.0}$$\end{document}$, and 1.1. Δ*λ*, is the spectral shift of the resonance when varying the index of refraction, and Δ*I* shows the variation in absorption at the perovskite active layer.

We simulate our device's performance to measure the index of refraction of gases (with index of refraction very close to 1.0). The system works with a monochromatic light source tuned to the selected resonant wavelength of each one of the designs ($\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\lambda }_{{\rm{I}}},{\lambda }_{{\rm{II}}-{\rm{narrow}}}={\lambda }_{{\rm{II}}-{\rm{wide}}},$$\end{document}$ or $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\lambda }_{{\rm{III}}}$$\end{document}$). To properly compare the four designs, the light source illuminates the device with the same irradiance of 50 mW/cm^2^. This value is achievable using regular diode lasers. At the same time, the spectral width of the resonance is large enough compared with the typical linewidth of commercial laser diodes (well below 0.1 nm), to consider the light source as purely monochromatic (as a delta function in *λ* that samples the absorbed spectral). This irradiance generates a photo-current, $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${I}_{{\rm{sc}}}$$\end{document}$, that is retrieved from the cell and delivered to an electronic read-out circuit. When changing the index of refraction of the analyte, the current varies, and so does the delivered signal. The photo-current is used to calculate the responsivity, R, which is defined as^[@CR64]^:$$\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\rm{R}}(\lambda )=\frac{{I}_{{\rm{sc}}}}{{P}_{{\rm{input}}}(\lambda )},$$\end{document}$$where $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${I}_{{\rm{sc}}}$$\end{document}$ is the ideal photo-generated short-circuit current, and $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${P}_{{\rm{input}}}(\lambda )$$\end{document}$ is the incident light power that is delivered by the monochromatic source.

The change in the responsivity with respect to *n*~*a*~ is presented in Fig. [6](#Fig6){ref-type="fig"}. As pointed out in the introduction section, the sensitivity of this sensor can be defined as the variation of R with respect to the index of refraction of the analyte, *n*~*a*~^[@CR49],[@CR50],[@CR65]^:$$\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${S}_{B}=\frac{\partial {\rm{R}}}{\partial {n}_{a}},$$\end{document}$$and the Figure of Merit (FOM) is also redefined in terms of the responsivity, *R*^[@CR49],[@CR50]^:$$\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\rm{FOM}}=\frac{{S}_{B}}{R}\mathrm{}.$$\end{document}$$Figure 6Variation of the responsivity, *R*, as a function of the index of refraction of the analyte, *n*~*a*~, for the four optimum design selected in this paper. Plots (**c**,**d**) zoom in the region $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${n}_{a}\in [1.000,1.001]$$\end{document}$, where the index of refraction of gases typically vary, for designs \# I and \# II-narrow. The red lines limit the range in the index of refraction where the variation in the current can be linearly fitted, meaning a constant value of the sensitivity of the device, $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${S}_{B}$$\end{document}$.

These definitions are adaptations of those applicable to plasmonic sensors interrogated in wavelength or angle of incidence, as it happens with Kretschmann and Otto configurations.

The evaluation of the sensitivity for the four designs presented in this paper, can be made using Eq. ([2](#Equ2){ref-type=""}). Table [2](#Tab2){ref-type="table"} summarizes the performance of the four designs in terms of sensitivity and FOM (Eqs. ([2](#Equ2){ref-type=""}) and ([3](#Equ3){ref-type=""})). This table also includes the variations $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\varDelta \lambda $$\end{document}$ and $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\varDelta {A}_{{\rm{perovs}}}$$\end{document}$, that are applicable for a spectral interrogation method, or an opto-electronic technique, respectively. Our proposal is to measure using electric parameters, where $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${I}_{{\rm{s}}{\rm{c}}}$$\end{document}$ is proportional to $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${A}_{{\rm{perov}}}$$\end{document}$, and therefore, the sensitivity is given using its definition in terms of $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\rm{R}}$$\end{document}$. Figure [6](#Fig3){ref-type="fig"} plots the responsivity for the four designs treated in this contribution. For the first peak at $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\lambda }_{{\rm{I}}}$$\end{document}$, the change in photo-current when varying the index of refraction is large, in accordance with a 60% change in the absorption at the active layer (see Fig. [5a](#Fig2){ref-type="fig"} and Table [2](#Tab2){ref-type="table"}). This means a high sensitivity to refractive index changes, but results in a limited dynamic range since the current decays sharply (see Fig. [6a](#Fig3){ref-type="fig"}). The spectral absorption of the second peak at $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\lambda }_{{\rm{I}}{\rm{I}}}$$\end{document}$ (see 6a, \# II-narrow case), generates a smaller spectral shift while maintaining a significant variation in intensity. Its responsivity is high and linear within the studied range in the index of refraction (see 6b). This expanded range in linearity is desiderable, and compared to the previous design at $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\lambda }_{{\rm{I}}}$$\end{document}$, makes this design operationally more robust and stable. Figure [6c,d](#Fig6){ref-type="fig"} contains a detailed zoom of the responsivity in the range $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${n}_{a}\in \mathrm{[1.000,1.001]}$$\end{document}$ that comprises the expected variations in the index of refraction of air or controlled atmospheres. We have selected designs \# I and \# II-narrow because they show a better behavior (higher $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${S}_{B}$$\end{document}$). We can see, that these designs, even in this narrow range, provide competitive values of sensitivity. The corresponding performance values are also shown in Table [2](#Tab2){ref-type="table"}. The spectral absorption for designs \# II-wide, and \# III presents a lower value of $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\Delta I$$\end{document}$ (see Fig. [5c,d](#Fig2){ref-type="fig"}) that corresponds with a lower value of sensitivity (see Fig. [6c,d](#Fig3){ref-type="fig"}, and Table [2](#Tab2){ref-type="table"}). Even more, in the design \# III at $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\lambda }_{{\rm{III}}}\mathrm{=783}$$\end{document}$ nm, the spectral shift, $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\Delta \lambda $$\end{document}$, is negligible and precludes its operation using spectral interrogation methods. This fact is in agreement with the physical interpretation of this peak as a selective transmitance through the slits^[@CR62]^. The FOM results summarized in Table [2](#Tab2){ref-type="table"} are moderate compared with previously reported figures^[@CR1]--[@CR4],[@CR6]--[@CR9]^.Table 2Performance parameters for the four designs.Design typeΔλ~r*es*~\[nm\]Δ*A*~perov~\[%\]*S*~*B*~\[mA(W.RIU) ^−1^\]FOM\[RIU ^−1^\]FOM ^\*^\[RIU ^−1^\]Planar cellNA1.4700.15NA\# I33.260.0349017.717700\# I (zoom)------232012.212200\# II-narrow17.531.823305.55450\# II-narrow (zoom)------22905.45380\# II-wide16.55.44440.82824\# III015.010602.242240

FOM for angular and spectral interrogation systems is defined as the ratio between sensitivity, $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${S}_{B}$$\end{document}$, and the capability of the system to distinguish a variation in the signal. This resolution capability is given as the full width at half maximum (FWHM) of the measured lineshape (in terms of angle or wavelength). The case treated in this paper generates an electric signal, the current delivered by the perovskite cell, that senses the variation in the index of refraction. This current will be affected by noise and fluctuations due to the intrinsic variations of the sensor, and related with the stability and noise level of the light source, the detector, and the signal acquisition electronics. Most of these variations can be accounted for and controlled. In the end, all this uncertainties are summarized in a variation of the responsivity, $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\Delta R$$\end{document}$. which plays the same role as the FWHM used to define FOM for spectral or angular interrogation. A modification of the figure of merit adapted to this measurement procedure would be defined as:$$\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${{\rm{FOM}}}^{\ast }=\frac{{S}_{B}}{\Delta {\rm{R}}},$$\end{document}$$where the ^\*^ superscript is given here to distinguish this definition from the one given in Eq. ([3](#Equ3){ref-type=""}). In the practical case that we treat here, when comparing the denominator in Eq. ([3](#Equ3){ref-type=""}) with $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\Delta {\rm{R}}$$\end{document}$, we can conclude that the definition given in Eq. ([3](#Equ3){ref-type=""}) clearly underestimates the FOM for our system.

From the definition of responsivity (Eq. ([1](#Equ1){ref-type=""})), we can derive its uncertainty, $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\sigma }_{{\rm{R}}}$$\end{document}$, that can be used in Eq. ([4](#Equ4){ref-type=""}), considering $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\Delta {\rm{R}}={\sigma }_{{\rm{R}}}$$\end{document}$, as:$$\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\Delta R={\sigma }_{{\rm{R}}}=\sqrt{{\left(\frac{\partial {\rm{R}}}{\partial {I}_{{\rm{sc}}}}\right)}^{2}{\sigma }_{{I}_{{\rm{sc}}}}^{2}+{\left(\frac{\partial {\rm{R}}}{\partial {P}_{{\rm{input}}}}\right)}^{2}{\sigma }_{{P}_{{\rm{input}}}}^{2}}=\sqrt{\frac{{I}_{n}^{2}}{{P}_{{\rm{input}}}^{2}}+{{\rm{R}}}^{2}{\left(\frac{\Delta {P}_{{\rm{input}}}}{{P}_{{\rm{input}}}}\right)}^{2}},$$\end{document}$$where $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\varDelta {P}_{{\rm{input}}}/{P}_{{\rm{input}}}$$\end{document}$ describes the stability in power of the illuminating light source. Assuming and accurate measurement of the current, we have taken its uncertainty as the noise in intensity of the photodetector $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\sigma }_{{I}_{{\rm{sc}}}}={I}_{{\rm{n}}}$$\end{document}$. The uncertainty of the illuminating power has been written in terms of the relative power stability of the source, $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\sigma }_{{P}_{{\rm{input}}}}=\varDelta {P}_{{\rm{input}}}$$\end{document}$. The device described in this contribution is quite close to a photodetector. Therefore, as it has been already proposed for perovskite based detectors^[@CR53]^, we should consider photodetection quality parameters to assess the performance of the device. Among these parameters, the noise equivalent power, NEP, is defined as $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\rm{NEP}}={I}_{n}/{\rm{R}}$$\end{document}$, and evaluated for perovskite detectors as $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\rm{NEP}}\mathrm{=4.6}\times {10}^{-12}$$\end{document}$ W at a wavelength $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\lambda =700$$\end{document}$ nm^[@CR53]^. When taking the worst-case scenario with the largest value in responsivity evaluated in this paper ($\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$R=539$$\end{document}$ mA/W at $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\lambda =715$$\end{document}$ nm), we obtain an estimation of the maximum noise in intensity: $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${I}_{n}={\rm{NEP}}\times R=2.5\times {10}^{-3}$$\end{document}$ pA. Taking into account this very small value of $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${I}_{n}$$\end{document}$, we find that the largest contribution to the variation in responsivity is coming from the second term in Eq. ([5](#Equ5){ref-type=""}). This means that, after neglecting the first term within the square root in Eq. ([5](#Equ5){ref-type=""}), we obtain$$\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\Delta {\rm{R}}={\sigma }_{{\rm{R}}}\simeq ={\rm{R}}\frac{\Delta {P}_{{\rm{input}}}}{{P}_{{\rm{input}}}},$$\end{document}$$meaning that the relative variation in responsivity is equal to the relative variation in input power: $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\Delta {\rm{R}}/{\rm{R}}=$$\end{document}$ $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\Delta {\rm{P}}}_{{\rm{input}}}{/{\rm{P}}}_{{\rm{input}}}$$\end{document}$. Using this approximation and combining Eqs. ([3](#Equ3){ref-type=""}) and ([4](#Equ4){ref-type=""}), it is possible to obtain a relation between $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${\rm{FOM}}$$\end{document}$ and $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${{\rm{FOM}}}^{\ast }$$\end{document}$ as:$$\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${{\rm{FOM}}}^{\ast }={\left(\frac{\Delta {P}_{{\rm{input}}}}{{P}_{{\rm{input}}}}\right)}^{-1}\times {\rm{FOM}},$$\end{document}$$showing that both performance parameters are proportional, and the proportionality constant depends on the stability in power of the light source, i. e., a more stable light source means a larger multiplicative term in Eq. ([7](#Equ7){ref-type=""}). A value of $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\Delta {P}_{{\rm{input}}}/{P}_{{\rm{input}}}{\mathrm{=10}}^{-3}$$\end{document}$ is attainable with the current laser diode technology. This means that $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${{\rm{FOM}}}^{\ast }\mathrm{=1000}\times {\rm{FOM}}$$\end{document}$. This previous discussion makes possible a conservative evaluation of $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$\Delta {\rm{R}}$$\end{document}$ that we have included in the last column of Table [2](#Tab2){ref-type="table"}, where we have found that $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${{\rm{FOM}}}^{\ast }$$\end{document}$ reaches a significant maximum value of $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${{\rm{FOM}}}^{\ast }\mathrm{=17700}\,{{\rm{RIU}}}^{-1}$$\end{document}$, which is competitive with existing technologies. Within the range $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${n}_{a}\mathrm{=[1.000,1.001]}$$\end{document}$, this value is FOM^\*^ = 12200. This value would mean a capability of measuring change in the index of refraction as low as $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$$8\times {10}^{-5}$$\end{document}$ RIU, that may account for variations in the index of refraction of air^[@CR5],[@CR14],[@CR34]--[@CR36],[@CR39],[@CR45]^.

Conclusions {#Sec5}
===========

The device proposed in this paper is able to sense variations of the index of refraction of the analyte using the electric signal delivered by a modified perovskite solar cell. Although a standard perovskite cell could work as an unsophisticated refractometric sensor, its design still allows improvement for this application. To take advantage of perovskite's cell technologies, instead of designing a complete pervoskite sensor, we have just modified the front surface of the cell. This modification consists of a regular pattern of nanoslits engraved on a silver layer. This nanostructure substitutes the front ITO electrode in a flipped configuration where the substrate moves towards the back contact, exposing the analyte to the front metallic layer. This modified arrangement is responsible for the spectral selectivity of the system. Besides, the geometrical parameters are selected within feasible and fabricable ranges to maximize the signal obtained from the device. This optimization considers the analyte as a gas medium with index of refraction close to 1. The device is illuminated with a monochromatic source tuned at one of the resonant wavelengths. The short-circuit current generated by the device feeds the measurement electronics to provide a signal that senses the changes in the index of refraction of the analyte. We have adapted the definitions of sensitivity and FOM to the case of an opto-electronic interrogation method. These results help us to identify which of the resonant wavelengths and designs works better as a refractometric sensor. The evaluation of the FOM shows a relevant value as large as 17.7 RIU ^−1^ that, however, it is still moderate when compared with existing technologies. Moreover, this system gets rid of complicated, voluminous, and expensive elements used when spectral interrogation is necessary. On the other hand, if the definition of the figure of merit uses photodection parameters, the values of FOM should be replaced by a modified FOM ^\*^ where the resolution in responsivity is given in terms of the limitations of the sensor taken as a photodetector. When doing this, we find a value of this modified figure of merit as large as $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${{\rm{FOM}}}^{\ast }$$\end{document}$ = 17700 $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${{\rm{RIU}}}^{-1}$$\end{document}$ ($\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${{\rm{FOM}}}^{\ast }$$\end{document}$ = 12200 $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${{\rm{RIU}}}^{-1}$$\end{document}$ within the range $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${n}_{{\rm{a}}}=\mathrm{[1.000,1.001]}$$\end{document}$). From the previously obtained results, it seems that designs \# I and \# II-narrow are the most promising alternatives. In any case, the choice of one of the four designs will depend on the availability of light sources, the reliability of the fabrication, and the selection of a higher performance in terms of the FOM (or FOM^\*^), or an expanded linear behavior.

Summarizing the finding of this paper, we are proposing a refractometric sensor that modifies a perovskite solar cell. This modification takes the form of a subwavelength metallic grating acting as the front contact of the cell. All the system (light source, sensor, and acquisition electronics) can be packed together within a tiny volume allowing miniaturization. The detection uses the electric signal delivered by the cell. This approach does not require any goniometer or spectrometer, making the device easier to operate. When considering a modified figure of merit, $\documentclass[12pt]{minimal}
                \usepackage{amsmath}
                \usepackage{wasysym} 
                \usepackage{amsfonts} 
                \usepackage{amssymb} 
                \usepackage{amsbsy}
                \usepackage{mathrsfs}
                \usepackage{upgreek}
                \setlength{\oddsidemargin}{-69pt}
                \begin{document}$${{\rm{FOM}}}^{\ast }$$\end{document}$, to describe the behavior of the device, the reported values are very competitive with existing technologies.

**Publisher's note** Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

The research included in this paper has been possible through a grant from the Ministry of Higher Education of Egypt, through a collaboration grant between the Egyptian institution and the University Complutense of Madrid. This work has been supported by Comunidad de Madrid under the SINFOTON2-CM Research Program (S2018/NMT-4326-SINFOTON2-CM) and the Spanish Ministry of Economy, the Agencia Estatal de Investigación and European Unionâ€™s FEDER under the TEC2016-77242-C3. The authors also thank to Irene Alda for her critical reading and English style corrections of the manuscript.

All the authors, M.H.E., A.C., B.R, and J.A., contributed equally to this paper.

The authors declare no competing interests.
