Thank you for visiting nature.com. You are using a browser version with limited support for CSS. To obtain the best experience, we recommend you use a more up to date browser (or turn off compatibility mode in Internet Explorer). In the meantime, to ensure continued support, we are displaying the site without styles and JavaScript.

# Spectrum projection with a bandgap-gradient perovskite cell for colour perception

## Abstract

Optoelectronic devices for light or spectral signal detection are desired for use in a wide range of applications, including sensing, imaging, optical communications, and in situ characterization. However, existing photodetectors indicate only light intensities, whereas multiphotosensor spectrometers require at least a chip-level assembly and can generate redundant signals for applications that do not need detailed spectral information. Inspired by human visual and psychological light perceptions, the compression of spectral information into representative intensities and colours may simplify spectrum processing at the device level. Here, we propose a concept of spectrum projection using a bandgap-gradient semiconductor cell for intensity and colour perception. Bandgap-gradient perovskites, prepared by a halide-exchanging method via dipping in a solution, are developed as the photoactive layer of the cell. The fabricated cell produces two output signals: one shows linear responses to both photon energy and flux, while the other depends on only photon flux. Thus, by combining the two signals, the single device can project the monochromatic and broadband spectra into the total photon fluxes and average photon energies (i.e., intensities and hues), which are in good agreement with those obtained from a commercial photodetector and spectrometer. Under changing illumination in real time, the prepared device can instantaneously provide intensity and hue results. In addition, the flexibility and chemical/bio-sensing of the device via colour comparison are demonstrated. Therefore, this work shows a human visual-like method of spectrum projection and colour perception based on a single device, providing a paradigm for high-efficiency spectrum-processing applications.

## Introduction

Optoelectronic devices that provide light responses and spectral measurements are promising components for use in a wide range of applications, including multifunctional sensing, colour imaging, high-bandwidth optical communications, and in situ characterization techniques1,2,3,4,5,6,7,8,9,10,11,12,13,14. However, the current selection of optoelectronic detectors is used to measure only light intensities (power densities, p)1,2,3,4,5,6,7,8,9. Most photodetectors can be classified into thermal and semiconductive types according to their working principles. The former, combining thermopiles with light absorbers, converts light to heat and then to electrical signals indirectly indicating light power densities10,11,12. The latter, directly converting photons to excitons, provides electrical signals depending on the photon flux φ and energy ε2,7,8. For a constant φ, the response of a semiconductor to ε is dependent on its light absorption A(ε) and photon energy-dependent quantum efficiency η(ε) for the absorbed photons. Both A(ε) and η(ε) exhibit fluctuating curves for semiconductors with indirect bandgaps (e.g., silicon) and step-like curves for those with direct bandgaps. This means that semiconductive photodetectors either give fluctuating responses to ε or provide only limited information about ε. Ordinary semiconductive photodetectors can only output light power densities by combining photon flux and energy (p = εφ) after calibration, and most often, the user must input the current wavelength (e.g., commercial silicon photodiodes). Moreover, a narrowband photodetector is only sensitive to specific lights over a rather small spectral range;3,13 these narrowband photodetectors generally exhibit indiscriminate sensitivity to lights over their detectable spectral range and are blind to the spectrum beyond their detectable wavelengths. Thus, none of the existing photodetectors are able to provide spectral information at the device level. It was recently reported that integrating dozens or hundreds of photodetectors with semiconductors presenting different bandgaps can reconstruct the spectral curves of incident light14,15. Nevertheless, such an approach already requires a chip-level device assembly and signal-processing system, and can generate redundant signals for applications that do not need detailed spectral information.

Our brain perceives light as a combination of colours and intensities, which allows it to process a large number of light signals with high efficiency16,17,18,19. Inspired by this, the projection of spectra into representative indices may enable true and efficient spectrum processing at the device level. Studies on colour perception suggest that while the human eye perceives three distinct wavelengths (red, green, and blue), the human brain projects the colours in terms of hue and intensity, where the colour is best represented by the hue16,18,20. Therefore, a device for spectrum processing and colour perception should be capable of the following: (1) discriminatively collect a light signal in different spectral regions—the more signals from different spectral regions, the higher the hue resolution is and (2) output compressed electrical signals directly indicating the hue and intensity of the incident light.

In this work, we propose a concept of spectrum projection and colour perception through the use of a single device by introducing bandgap-gradient semiconductors as photoactive materials. Since photon absorption can only occur at energies above the bandgap of semiconductors, the devices can sense the spectral content of light signals with high resolution. Halide perovskite films with a continuous gradient of direct bandgaps are developed to demonstrate a device that outputs a signal exhibiting linear responses to both ε and φ. Combining the other output signal that is linearly dependent only on φ, the intensity and hue (i.e., total photon flux and average photon energy) of spectra can be obtained from a single device. The mechanical flexibility of the devices is demonstrated by fabricating them on polymer substrates. The online colour perception is shown by using the device to sense real-time changes in lighting. Finally, sensing applications are demonstrated by using the device to perceive the colour changes of stimuli-sensitive materials that are responsive to chemical/bio-analytes.

## Results

### Design of colour-perception device

Figure 1a shows the diagram of a spectrum containing photons with different energies. The photon flux for a given photon energy εi is defined as φi, and the total power density is given by $$p = \mathop {\sum}\nolimits_i {\varepsilon _i\varphi _i}$$. Statistically, representative indices for a spectrum should include the total photon flux $$\varphi = \mathop {\sum}\nolimits_i {\varphi _i}$$ and the average photon energy weighted by the flux $$\bar \varepsilon _\varphi = \mathop {\sum}\nolimits_i {\varepsilon _i\varphi _i} /\mathop {\sum}\nolimits_i {\varphi _i = p/\varphi }$$. Such indices are critical to spectrum identifications; that is, $$\bar \varepsilon _\varphi$$ can be clearly different for the spectra even with the same p, as illustrated in Fig. 1b. An ideal colour-perception device should be able to discriminatively absorb the photon flux corresponding to each photon energy in the spectrum and project them into output signals that directly indicate $$\bar \varepsilon _\varphi$$ and φ. Accordingly, we propose the device design shown in Fig. 1c. The device consists of two parts and outputs two signals, in which one part uses a semiconductor with a rather small bandgap (SBG) as a photoactive layer and exhibits an output current (I1) determined only by φ in a certain ε region. The other part is composed of semiconductors with gradient bandgaps (GBGs) as a photosensing layer, and a high photon energy ε can lead to a large photoexcited domain (domains with εb ≤ ε can be photoexcited); hence, the photon flux for each photon energy can be distinguished based on the extent of the photoexcited domain. When the bandgap gradient is uniform, a constant ε variation can lead to a fixed change in the photoexcited domain. Thus, this part of the device may present a linear response to ε and is expected to output a current (I2) that reflects the $$\bar \varepsilon _\varphi$$ of spectra. Combining the two output currents (I1 and I2), the spectral information may be projected into statistical spectral indices $$\bar \varepsilon _\varphi$$ and φ. On the other hand, the human visual system only perceives red, green, and blue and projects these colours in terms of hue (Fig. 1d). Labelling the flux of red, green, and blue photons as R, G, and B, respectively, the hue is defined as:

$$h = \frac{1}{{2\pi }}{\mathrm{atan2}}\left( {\sqrt {3}\left({G - B}\right), R - G - B}\right)$$
(1)

Figure 1e shows that the hue and $$\bar \varepsilon _\varphi$$ of a spectrum composed of R, G, and B are strikingly similar from the red to blue region. Therefore, except for the unphysical red–purple–blue quadrant, it is expected that a device measuring $$\bar \varepsilon _\varphi$$ will yield a fairly good approximation for the hue of light and thus achieve colour perception.

Semiconductors with GBGs can be achieved with compositionally graded alloys or compounds. All-inorganic halide perovskites (CsPbX3) exhibit tunable direct bandgaps over the whole visible range (1.7–3.1 eV), outstanding optoelectronic properties and solution processability2,3,6,21,22,23,24,25,26,27. Compared to organic–inorganic hybrid perovskites (e.g., MAPbX3 and FAPbX3), all-inorganic perovskites exhibit better robustness and environmental stability28. Although the cubic perovskite phase of CsPbI3 is relatively unstable, CsPbI3 can remain in the cubic perovskite phase at room temperature for a period of time, while exhibiting excellent optoelectronic properties29. Furthermore, CsPbI3 perovskites obtained from a halide exchanging CsPbBr3 present better phase stability than directly synthesized perovskites30. Thus, we use CsPbX3 perovskites to demonstrate this proof-of-concept. A halogen-exchange method via dipping is developed to obtain perovskite films with a continuous halide-composition gradient as shown in Fig. 2a. Figure 2b shows the fluorescence microscopy photos of a series of CsPbBr3 films on SiO2 exchanged with CsI solutions after the dipping process. According to the pictures, the photoluminescent hue of the exchanged films is spectrally continuous, changing from green to red under UV light (namely, rainbow perovskites). Similarly, the hue of CsPbBr3 films exchanged with CsCl solutions varies gradually from green to dark blue (Fig. 2c). Since the photoluminescence (PL) colours of perovskites depend mainly on their bandgaps3,21,31, these PL measurements are strong evidence that these rainbow perovskite films present continuously varying bandgaps. In this dipped exchange process, the bottom sections of the CsPbBr3 films undergo halide exchange with the CsCl or CsI solution for a longer duration than the top sections, spontaneously forming perovskite films with a gradient halide composition, i.e., GBGs. Interestingly, the length of the GBG range (LGBG) can be increased by increasing the dipping speed. From left to right in Fig. 2b, the dipping speed increases from 1 to 5 mm/s, and thus, the corresponding LGBG increases from 35 μm to several millimetres. The micromorphologies of the rainbow perovskites are observed by scanning electron microscopy (SEM). Figure 2d presents the cross-section SEM image of the rainbow perovskite, showing a film thickness of ~100 nm. This thin film ensures uniform halogen exchange between the surface and the bulk of the film31. At different positions on the rainbow perovskite (marked in Fig. 2e), the SEM images present similar morphologies of connected grains with rather high coverage (Fig. 2f and Supplementary Fig. S1). These results reveal that the effect of the dipping process on the perovskite micromorphology is limited. The energy dispersive spectroscopy (EDS) linear and mapping scans of elemental distributions were also carried out on the GBG films around the marked positions (Fig. 2g and Supplementary Fig. S1). At position , clear distributions of Br, Cs and Pb can be observed, while the presence of I is negligible. From position to , the concentration of Br continuously decreases and that of I continues to increase, while the amounts of Cs and Pb remain constant. No obvious halide-phase separation was found according to the EDS mapping images. This result indicates successful halogen exchange during the dipping process.

When the exchanging solutions are diluted or the GBG perovskites are fabricated on polymer films, the LGBG can be further increased. According to the UV–visible absorption, crystalline behaviour and PL spectrum (Supplementary Figs. S2 and S3), these rainbow perovskite films with a large LGBG also display more spread-out bandgap gradients. The XRD spectrum around position “Br” clearly shows characteristic diffraction peaks at 15.2 and 30.7°, which can be attributed to the (100) and (200) orientations of the cubic CsPbBr3 crystal. After exchange with Cl or I ions, the XRD peaks exhibit obvious shifts to larger or smaller 2θ values (Supplementary Fig. S2c). This is ascribed to the changed lattice constants incurred by the exchange between the Br of CsPbBr3 and the Cl or I in the solution31,32. In brief, the above results indicate that the CsPbX3 film mainly retains a cubic crystal phase and direct bandgap after undergoing the halogen-exchange process via dipping. The weak diffraction peaks at ~27° for the Br/I perovskite and at ~27 and 45° for the Br/Cl perovskite can be assigned to a few orthorhombic and non-perovskite CsPb2X5 phases that are formed during the dipping process33. The mechanism of the dipping exchange process is discussed in Supplementary Fig. S4. Overall, a successful fabrication of GBG semiconductor films is displayed.

To further investigate the optoelectronic characteristics of the GBG semiconductor along the direction of the bandgap gradient, multiple devices are fabricated at different locations on the rainbow perovskite film with an LGBG of ~4 mm. The photoconductivity response curves under monochromatic light exhibit a sharp cutoff for wavelengths varying from 470 to 690 nm, which is consistent with the bandgap gradient (Supplementary Fig. S5). However, the devices with ion-exchanged perovskites exhibit a high resistance, which may be due to the formation of a few non-cubic-perovskite phases as mentioned above33. The difference in the conductivities of the GBG composites is likely to deteriorate the hue perception of the devices. Thus, an organic semiconductor, dioctylbenzothieno [2,3-b] benzothiophene (C8BTBT), is introduced to construct heterojunctions with the rainbow perovskites34,35, and similar conductivities are then achieved on the heterojunctions of rainbow perovskites with different bandgaps (Supplementary Figs. S6S8). Note that we aim to demonstrate the colour-perception devices, thus, the conducting and intensity-sensing properties of the rainbow perovskites are not optimized here.

### Linear response to photon energy and device modelling

Br/I rainbow perovskite films with an LGBG of ~1.5 mm are employed to fabricate the heterojunctions, and only single devices are built on the GBG films, as shown in Fig. 3a. The devices, with an electric current direction parallel to the bandgap-gradient direction (i.e., parallel devices), are named Devices I, II and III, corresponding to electrode intervals of 0.5, 1, and 1.5 mm, respectively. According to the time-dependent current curves (I–t) of Device I under pulsed monochromatic illumination at different wavelengths (Fig. 3b), the photocurrent decreases with increasing wavelengths from 520 to 560 nm. Figure 3c shows the current versus wavelength (I–λ) curves of the three devices under different monochromatic lights at a constant power density. All the devices exhibit quasi-linear current variation as a function of the light wavelengths in some regions; furthermore, the quasi-linear region widens, and the corresponding slope gradually decreases with the electrode interval. For a given LGBG, a large electrode interval means a wide range of varying bandgaps covered by the device. Thus, because Device III covers the whole Br/I GBG film, it exhibits a linear wavelength-responsive region from 520 to 700 nm. The linear scaling of the maximum conductivity suggests that the current differences between the three devices are mainly due to their different electrode intervals, rather than the differences in the film conductivities. An excellent sample for sample reproduction is found for the devices, as shown in Fig. 3d. The stability of the GBG device is also investigated by measuring the I–λ curves of the device under different ageing conditions. The device shows limited I–λ curve changes after many cycles of light switching (at different intensities), under an applied bias or after being stored in atmosphere for different periods of time, thereby indicating decent stability (Supplementary Fig. S9). On the other hand, the effect of the conducting current direction (parallel or orthogonal) on the wavelength-responsive performance of the device is limited (Supplementary Fig. S10). An effective conductivity (σ*) is introduced for the entire GBG device, and σ* is derived as a function of photon energy (ε) under a constant power density, as shown in Fig. 3e. Then, physical models for the devices are proposed (see Supplementary Information)36, which eventually gives:

$$\sigma ^ \ast = \frac{{\xi \sigma _d}}{{kl}}\left( {\varepsilon - \varepsilon _0} \right)\varphi + \sigma _d$$
(2)

where ξ is an experimental constant related to the dark carrier surface density and free-carrier lifetime, σd is the dark conductivity, k is the bandgap gradient, and l and ε0 are the length and the smallest bandgap of the GBG film employed by the device, respectively. This equation means that for a constant photon flux φ, the devices should show an ideal linear response to ε (I~ε). In Fig. 3f, the σ*ε dataset with constant illumination power p in the quasi-linear region is recasted with constant φ (φ = p/ε). The curves can be well fitted to a straight line when φ is constant, which supports physical modelling. According to the model, the linear photon energy response also benefits from the heterojunction device structure. The photogenerated charge carriers from the rainbow perovskite transfer into the uniformly conductive C8BTBT layer and then conducts, thereby avoiding the influence of the conductivity difference in the rainbow perovskites (Supplementary Figs. S11 and S12 and Tables S1 and S2).

Then, the photogenerated current (Iph, equal to light current minus dark current) of the device under the given voltages can be expressed as:

$$I_{ph} \propto \left( {\varepsilon - \varepsilon _0} \right)\varphi = p - \varepsilon _0\varphi$$
(3)

which suggests that the photocurrent is not solely determined by p despite the fact that it combines ε and φ (I f (p)). Thus, the device can distinguish different light hues even with the same p, and the ε and φ of the light can be obtained by combining the device with any conventional photodetector. For non-monochromatic light, the total photocurrent in devices is the sum of the contribution of each monochromatic light source:

$$I_{ph} = \mathop {\sum}\limits_i {I_{phi}} \propto \mathop {\sum}\limits_i {\left( {\varepsilon _i - \varepsilon _0} \right)\varphi _i = \left( {\overline {\varepsilon _\varphi } - \varepsilon _0} \right)\varphi }$$
(4)

which directly indicates the statistical spectral indices (here φ is the total photon flux of the spectra). This means that the GBG device is able to project spectra and directly provide average photon energies, i.e., the hue. A GBG device covering the full visible spectrum can be further obtained by dipping the perovskite film half in the CsCl solution and half in the CsI solution, with optimized dip-processing parameters to ensure a good match of the bandgap gradients for both the Br/Cl and Br/I parts.

### Spectrum projection and colour perception

Figure 4a shows spectral curves of 20 radiations measured by a commercial spectrometer, distributed in the range of 520–670 nm (1.85–2.38 eV). Since the spectrometer can only provide relative and imprecise light intensities, the spectral curves are normalized according to the more accurate power densities measured by a light power density metre. A GBG heterojunction device containing a Br/I rainbow perovskite film with an LGBG of ~0.5 mm is used here (Fig. 4b). The calibration of the GBG device is first carried out by reading Iph under different monochromatic lights with varying ε or φ (Fig. 4c). Both the Iph− ε and Iph − φ curves appear to be linear in our experimental ε and φ regions, and the calibration parameters for the device are obtained accordingly (see the Supplementary Information). The device is then employed to measure the 20 radiations and provide the corresponding Iph presented in Fig. 4d, together with the power densities. The different radiations with the same power densities (e.g., Radiation 1 and 11 with p = 0.15 mW cm−2, Radiation 2, 3, 5 and 7 with p = 0.14 mW cm−2, Radiation 4 and 13 with p = 0.09 mW cm−2, and Radiation 6 and 14 with p = 0.05 mW cm−2) clearly exhibit different Iph values, indicating that the radiations that are undistinguishable with commercial light power density metres can be identified by our device. Furthermore, the statistical spectral information of the radiation, including $$\bar \varepsilon _\varphi$$ and φ, can be obtained from Iph and p, as shown in Fig. 4e. For comparison, the average photon energy weighted by the power density ($$\bar \varepsilon _p$$) obtained from a spectrometer is also shown. The values of $$\bar \varepsilon _\varphi$$ and $$\bar \varepsilon _p$$ for each radiation are close to each other, and both are located in the mid-region of the corresponding spectrum (see the Supplementary Information). This result reveals that the output Iph of the GBG device reliably indicates the $$\bar \varepsilon _\varphi$$ value of the radiation. The results of $$\bar \varepsilon _\varphi$$ and $$\bar \varepsilon _p$$ show slight deviations for some spectra, which can be ascribed to (1) the two average photon energies ($$\bar \varepsilon _\varphi$$ and $$\bar \varepsilon _p$$) are weighted by different parameters, i.e., the former (obtained with the GBG device) is weighted by photon flux, and the latter (obtained with a spectrometer) is weighted by power density and (2) the photosensitivity and spectral resolution of the GBG device can be further improved.

Then, a device consisting of two parts that employ the GBG film and the SBG CsPbI3 film as photoactive layers is fabricated with a rainbow perovskite (Fig. 5a). Similar to conventional direct-bandgap semiconductive photodetectors, the SBG part exhibits a linear response to φ and very limited current changes as a function of ε in our experimental regions (Fig. 5b). The device can thus project the spectrum and perceive colours by combining the two photogenerated currents of the SBG and GBG parts (Iph-1 and Iph-2). Figure 5c shows time-dependent lights with randomly varying colours and intensities (i.e., radiations with changing spectra in real time), which are generated by a xenon lamp filtered with two tunable grating monochromators. Figure 5d exhibits Iph-1 variations from the SBG part of the device under the changing light. Since Iph-1 is only sensitive to φ, φt curves are calculated accordingly. Moreover, the GBG part of the device under the lights changing in real time provides online Iph-2t curves. The $$\bar \varepsilon _\varphi$$t curves, namely, the online colour-varying information, can be simultaneously obtained from the known φ and the Iph-2t curves (Fig. 5e). In addition, the track of changing lights with monotonically increasing (decreasing) photon energies is shown in a hue coordinate system, in which the scale of the radial axis represents light intensity. Figure 5f exhibits the pre-set light-changing situations, and Fig. 5g shows the measured results from the device. In all cases (Fig. 5c–g), the results obtained from the device are similar to the expected results, indicating reliable measurements. To the best of our knowledge, this is the first study to show online colour perception on a single device.

Note that humans perceive mixed red (~1.8 eV) and blue (~2.8 eV) colours as purple; hence, our device may be unable to distinguish between the “mixed purple” and yellow (~2.3 eV) signals since they can have the same average photon energy. An extra electrode deposited in the middle of the green region on the GBG device can overcome this issue by providing average photon energies of the red–green and green–blue regions, respectively. It is also worthwhile to compare our device with the conventional pixel sensor in charge-coupled device (CCD) cameras, which consists of several photodetectors integrated with red, green, and blue filters. The CCD pixel device collects spectral information in three different wavelength ranges (mimicking human eyes) and then provides the hue by combining the R, G, and B values. Thus, the obtained hue highly depends on the optical properties of the R, G, and B filters. In contrast, our device discriminatively collects spectral information in many (theoretically infinite) different wavelength ranges and provides an average photon energy. The obtained average photon energy is an intrinsic parameter of spectra, which can be further transformed into a hue. Moreover, the device configurations of the two methods are completely different. The CCD pixel sensor requires at least three photodetectors integrated with three different optical (RGB) filters, whereas our devices only require a bandgap-gradient semiconductor. The advantages of colour sensors utilizing our method include a high spectrum resolution, low cost, simple patterning and scaling down, simple fabrication on flexible substrates, and simple customization, while eliminating the need to find good filters.

### Demonstration of device flexibility and chemical/bio-sensing

The mechanical flexibility is also demonstrated by fabricating GBG devices on polymer substrates (Supplementary Fig. S13). Figure 6a shows an image of the device array under UV illumination, showing spectrally gradient PL colours and mechanical flexibility. The flexible devices also exhibit IV curves responsive to light wavelengths, and the IV curves remain the same when the devices are in a bent state (Fig. 6b). The currents of the flexible devices under light at various wavelengths exhibit only slight changes after undergoing hundreds of bending cycles (Fig. 6c), thereby indicating decent flexibility. The flexibility may further extend the applicability of the device37,38.

Finally, chemical/bio-sensing by applying the colour-perception device is demonstrated. The colorimetric chemical/bio-assay setup is shown in Fig. 6d: chemical/bio-analytes will modify the colour of the sensing material, and the GBG device will convert the colour change to an electrical signal. For this simple proof of concept, we use a pH testing paper that turns from red to green for pH values from 1 to 9. When using a single silicon photodiode output current ISi-PD, such colour differences are not detectable, as shown in Fig. 6e. A spectrometer is then employed to measure the spectra of the pH testing papers under the same illumination, which can distinguish the testing papers with different colours by presenting different peak positions of the spectral curves (Fig. 6f). However, this method not only requires bulky equipment but also generates spectral information that is redundant for sensing applications. The response of the hue sensor is shown in Fig. 6g. Our device can clearly distinguish between the various pH values. Therefore, the hue sensor effectively achieves colorimetric chemical/bio-sensing with only a single device and by generating only one or two current signals.

## Discussion

In conclusion, we proposed a concept of spectrum projection and colour perception on a single cell inspired by human visual perception and manufactured such a device by developing bandgap-gradient rainbow perovskites. The GBG part of the device can project the spectrum into the average photon energy and photon flux, while the SBG part can only indicate the photon flux of the spectrum. Thus, the intensity and colour (hue) of the spectrum can be obtained from a single device by combining the two output signals, which are in good agreement with those obtained from a commercial photodetector and spectrometer. Online colour perception in a real-time light-varying environment was demonstrated by a single device. Furthermore, flexible devices were obtained by depositing rainbow perovskites on a polymer substrate. Simple chemical/bio-sensing was further shown by applying the device in a colour comparison experiment.

## Materials and methods

### Preparation and characterization of rainbow perovskite films

First, pure CsPbBr3 perovskite films were prepared by spin-coating the precursor solution (2 mmol of CsBr and 2 mmol of PbBr2 in 5 ml of dimethyl sulfoxide)) at 3000 rpm for 1 min on SiO2- or polylactide (PLA)-coated Si wafers, followed by drying at 70 °C for 30 min in a N2 atmosphere. The PLA films were fabricated by spin-coating PLA solution (Natureworks Co., Ltd., Unitied States, 4032D, 50 g/L in chloroform) onto the wafer at 2000 rpm for 30 s, followed by heating at 60 °C for 2 h. Then, the rainbow perovskite films were obtained by dipping the CsPbBr3 films (on a wafer or PLA) in the CsCl/CsI methanol solutions at a concentration of 4, 8 or 16 g/L. The dipping speeds of the CsPbBr3 films in the solution were 1, 2, 3, or 5 mm/s, and the pulling speed was 5 mm/s for all GBG films (Dip Coater, SYDC-100, SANYAN Co., Ltd., China). The fluorescence microscopy photos were taken by using a fluorescence microscope (LW300LFT-LED, Cewei Guangdian Co., Ltd., China) with an excitation light at 365 nm. The images of the rainbow perovskites were taken by a digital camera under UV lamp illumination with a wavelength at 365 nm. SEM images were obtained from a field-emission electron microscope (Zeiss SIGAMA HD, Germany) operated at 5 kV. EDS images were taken by a Zeiss Gemini SEM500 field-emission scanning electron microscope with an Aztec X-Max Extreme EDS detector (Oxford Co., Ltd., Britain). UV–vis absorption spectra for the GBG films on quartz substrates were measured on a Lambda 750 UV–visible spectrophotometer. PL spectra were recorded by an F-320 spectrophotometer (Gangdong Sci.&Tech. Co., Ltd., China). X-ray diffraction (XRD) was carried out on a Bruker (Unitied States) Advance D8 X-ray Diffractometer with a Cu Kα radiation source (1.54 Å) at 40 kV. The rainbow perovskites with rather large LGBG values were cut into small pieces for the UV–vis, PL and XRD characterizations at different positions.

### Fabrication of the devices

The devices in Supplementary Fig. S5a were fabricated by using Br/Cl or Br/I rainbow perovskites on a wafer with an ~4 mm LGBG as photosensing layers. Au electrodes (70 nm) were thermally evaporated onto the GBG films through a shadow mask under a vacuum of 8 × 10−4 Pa. The width (W) and length (L) of the device was 500 and 100 µm, respectively. The orthogonal heterojunction devices (Supplementary Fig. S6a) were fabricated by thermally evaporating a 150 nm C8BTBT film on top of the Br/I GBG film with an ~2 mm LGBG using a shadow mask, followed by deposition on the electrodes as mentioned above. Similarly, the parallel heterojunction devices shown in Fig. 3a were obtained by employing Br/I GBG films on a wafer with an ~1.5 mm LGBG and electrode intervals of 0.5, 1, and 1.5 mm. Other parallel and heterojunction devices were obtained by using the same method. The flexible heterojunction devices shown in Fig. 6a were prepared by depositing the Br/I GBG film on PLA film and PET substrate, followed by the evaporation of the C8BTBT and Au electrodes (W = 500 µm and L = 100 µm).

### Characterization of the devices

All electrical characteristics were measured on a Cascade (Unitied States) Summit 11000M probe station by using an Agilent (Unitied States) B1500A semiconductor device analyser in air at room temperature. The monochromatic and broadband lights were generated by either a 300 W xenon lamp filtered with two tunable grating monochromators (Omno 330150, NBeT Co., Ltd., China) or LEDs and bandpass filters in a range of wavelengths (Thorlabs Co., Ltd., Unitied States). All monochromatic lights were fixed with a full-width at half maximum of approximately 10 ± 2 nm. The power densities of the radiation were measured using a standard photodiode power density metre with the input of light (Thorlabs S130VC). The curves in Fig. 4a were obtained by employing an F-320 spectrophotometer (Gangdong Sci.&Tech. Co., Ltd., China), and the intensities of the curves were further normalized according to the power densities measured by a Thorlabs S130VC instrument, that is, the integral area of each curve was normalized to be proportional to the measured power density of the corresponding radiation. The performance of the flexible devices in the bent state was characterized while the devices were tightly bent around a cylinder with a radius of 5 mm. The pH sensing experiments were carried out by testing the GBG device under an Omno 330150 light source filtered with differently coloured pH testing papers.

## Data availability

The data that support the conclusions within this paper and the other findings of this study are available from the corresponding authors upon reasonable request.

## References

1. 1.

Adinolfi, V. & Sargent, E. H. Photovoltage field-effect transistors. Nature 542, 324–327 (2017).

2. 2.

Dou, L. T. et al. Solution-processed hybrid perovskite photodetectors with high detectivity. Nat. Commun. 5, 5404 (2014).

3. 3.

Fang, Y. J. et al. Highly narrowband perovskite single-crystal photodetectors enabled by surface-charge recombination. Nat. Photon. 9, 679–686 (2015).

4. 4.

Gan, X. T. et al. Chip-integrated ultrafast graphene photodetector with high responsivity. Nat. Photon. 7, 883–887 (2013).

5. 5.

Goossens, S. et al. Broadband image sensor array based on graphene-CMOS integration. Nat. Photon. 11, 366–371 (2017).

6. 6.

Saidaminov, M. I. et al. Planar-integrated single-crystalline perovskite photodetectors. Nat. Commun. 6, 8724 (2015).

7. 7.

Saran, R. & Curry, R. J. Lead sulphide nanocrystal photodetector technologies. Nat. Photon. 10, 81–92 (2016).

8. 8.

Wu, X. H. et al. Pursuing polymer dielectric interfacial effect in organic transistors for photosensing performance optimization. Adv. Sci. 4, 1700442 (2017).

9. 9.

Wu, X. H. et al. Distinguishable detection of ultraviolet, visible, and infrared spectrum with high-responsivity perovskite-based flexible photosensors. Small 14, 1800527 (2018).

10. 10.

Lu, F. et al. Thermopile detector of light ellipticity. Nat. Commun. 7, 12994 (2016).

11. 11.

Hsu, A. L. et al. Graphene-based thermopile for thermal imaging applications. Nano Lett. 15, 7211–7216 (2015).

12. 12.

Li, W. et al. A front-side microfabricated tiny-size thermopile infrared detector with high sensitivity and fast response. IEEE Trans. Electron Devices 66, 2230–2237 (2019).

13. 13.

Lin, Q. Q. et al. Filterless narrowband visible photodetectors. Nat. Photon. 9, 687–694 (2015).

14. 14.

Yang, Z. Y. et al. Single-nanowire spectrometers. Science 365, 1017–1020 (2019).

15. 15.

Sun, H. X. et al. In situ formed gradient bandgap-tunable perovskite for ultrahigh-speed color/spectrum-sensitive photodetectors via electron-donor control. Adv. Mater. 32, 1908108 (2020).

16. 16.

Dacey, D. M. et al. Melanopsin-expressing ganglion cells in primate retina signal colour and irradiance and project to the LGN. Nature 433, 749–754 (2005).

17. 17.

Guo, C. L. & Zhang, L. M. A novel multiresolution spatiotemporal saliency detection model and its applications in image and video compression. IEEE Trans. Image Process. 19, 185–198 (2010).

18. 18.

Wang, H. L. et al. A ferroelectric/electrochemical modulated organic synapse for ultraflexible, artificial visual-perception system. Adv. Mater. 30, 1803961 (2018).

19. 19.

Gu, L. L. et al. A biomimetic eye with a hemispherical perovskite nanowire array retina. Nature 581, 278–282 (2020).

20. 20.

Theeuwes, J. Perceptual selectivity for color and form. Percept. Psychophys. 51, 599–606 (1992).

21. 21.

Saidaminov, M. I. et al. Perovskite photodetectors operating in both narrowband and broadband regimes. Adv. Mater. 28, 8144–8149 (2016).

22. 22.

Hutter, E. M. et al. Direct-indirect character of the bandgap in methylammonium lead iodide perovskite. Nat. Mater. 16, 115–120 (2017).

23. 23.

Cho, H. et al. Improving the stability of metal halide perovskite materials and light-emitting diodes. Adv. Mater. 30, 1704587 (2018).

24. 24.

Kojima, A. et al. Organometal halide perovskites as visible-light sensitizers for photovoltaic cells. J. Am. Chem. Soc. 131, 6050–6051 (2009).

25. 25.

Burschka, J. et al. Sequential deposition as a route to high-performance perovskite-sensitized solar cells. Nature 499, 316–319 (2013).

26. 26.

Feng, J. G. et al. Single-crystalline layered metal-halide perovskite nanowires for ultrasensitive photodetectors. Nat. Electron. 1, 404–410 (2018).

27. 27.

Protesescu, L. et al. Nanocrystals of cesium lead halide perovskites (CsPbX3, X = Cl, Br, and I): novel optoelectronic materials showing bright emission with wide color gamut. Nano Lett. 15, 3692–3696 (2015).

28. 28.

Liang, J. et al. All-inorganic perovskite solar cells. J. Am. Chem. Soc. 138, 15829–15832 (2016).

29. 29.

Swarnkar, A. et al. Quantum dot-induced phase stabilization of α-CsPbI3 perovskite for high-efficiency photovoltaics. Science 354, 92–95 (2016).

30. 30.

Yuan, J. Y. et al. Metal halide perovskites in quantum dot solar cells: progress and prospects. Joule 4, 1160–1185 (2020).

31. 31.

Hoffman, J. B. et al. Transformation of sintered CsPbBr3 nanocrystals to cubic CsPbI3 and gradient CsPbBrxI3-x through halide exchange. J. Am. Chem. Soc. 138, 8603–8611 (2016).

32. 32.

Li, X. M. et al. CsPbX3 quantum dots for lighting and displays: room-temperature synthesis, photoluminescence superiorities, underlying origins and white light-emitting diodes. Adv. Funct. Mater. 26, 2435–2445 (2016).

33. 33.

Zeng, J. P. et al. Combination of solution-phase process and halide exchange for all-inorganic, highly stable CsPbBr3 perovskite nanowire photodetector. Science China. Materials 62, 65–73 (2019).

34. 34.

Tong, S. C. et al. High-performance broadband perovskite photodetectors based on CH3NH3PbI3/C8BTBT heterojunction. Adv. Electron. Mater. 3, 1700058 (2017).

35. 35.

Li, L. et al. Interfacial electronic structures of photodetectors based on C8BTBT/perovskite. ACS Appl. Mater. Interfaces 10, 20959–20967 (2018).

36. 36.

Petritz, R. L. Theory of photoconductivity in semiconductor films. Phys. Rev. 104, 1508–1516 (1956).

37. 37.

Wu, W. Q. et al. Flexible photodetector arrays based on patterned CH3NH3PbI3-xClx perovskite film for real-time photosensing and imaging. Adv. Mater. 31, 1805913 (2019).

38. 38.

Hu, W. et al. High-performance flexible photodetectors based on high-quality perovskite thin films by a vapor-solution method. Adv. Mater. 29, 1703256 (2017).

39. 39.

Lee, H. M. et al. Near-infrared photoresponsivity of ZnON thin-film transistor with energy band-tunable semiconductor. ACS Appl. Mater. Interfaces 10, 30541–30547 (2018).

40. 40.

Haider, A., Kizir, S. & Biyikli, N. Low-temperature self-limiting atomic layer deposition of wurtzite InN on Si(100). AIP Adv. 6, 045203 (2016).

41. 41.

Ma, H. P. et al. Composition and properties control growth of high-quality GaOxNy film by one-step plasma-enhanced atomic layer deposition. Chem. Mater. 31, 7405–7416 (2019).

42. 42.

Ding, X. W. et al. Nitrogen-doped ZnO film fabricated via rapid low-temperature atomic layer deposition for high-performance ZnON transistors. IEEE Trans. Electron Devices 65, 3283–3290 (2018).

43. 43.

Zhu, X. X. et al. Broadband perovskite quantum dot spectrometer beyond human visual resolution. Light. Sci. Appl. 9, 73 (2020).

44. 44.

Li, G. J. et al. Silicon nanomembrane phototransistor flipped with multifunctional sensors toward smart digital dust. Sci. Adv. 6, eaaz6511 (2020).

## Acknowledgements

This work was supported by the National Natural Science Foundation of China (61874029) and the National Key Technologies R&D Programme of China (2015ZX02102-003).

## Author information

Authors

### Contributions

X.W. and S.-J.D. conceived the idea. X.W. designed the experiments. M.-N.Z. carried out the material synthesis, device fabrication and characterization with the assistance of X.-L.W. and F.X. A.R. and X.W. performed the device modelling. X.W. and S.-J.D. wrote the paper. All authors contributed to the discussion of the results and preparation of the paper.

### Corresponding authors

Correspondence to Xiaohan Wu or Shi-Jin Ding.

## Ethics declarations

### Conflict of interest

The authors declare that they have no conflict of interest.

## Rights and permissions

Reprints and Permissions

Zhang, MN., Wu, X., Riaud, A. et al. Spectrum projection with a bandgap-gradient perovskite cell for colour perception. Light Sci Appl 9, 162 (2020). https://doi.org/10.1038/s41377-020-00400-w

• Revised:

• Accepted:

• Published:

• ### Design, synthesis, and characterization of pyridine-containing organic crystals with different substitution positions using solvothermal method

• Jiasheng Wu
• , Jiacheng Zou
• , Xiangxue Zhuge
• , Zhitai Jia
• , Na Lin
•  & Chunxue Yuan

CrystEngComm (2021)

• ### High-bandwidth light inputting multilevel photoelectric memory based on thin-film transistor with a floating gate of CsPbBr3/CsPbI3 blend quantum dots

• Junxiang Pei
• , Xiaohan Wu
• , Jingyong Huo
• , Wen-Jun Liu
• , David Wei Zhang
•  & Shi-Jin Ding

Nanotechnology (2021)

• ### Miniaturization of optical spectrometers

• Zongyin Yang
• , Tom Albrow-Owen
• , Weiwei Cai
•  & Tawfique Hasan

Science (2021)

• ### Strategies of modifying spiro-OMeTAD materials for perovskite solar cells: a review

• Guanhua Ren
• , Wenbin Han
• , Yanyu Deng
• , Wei Wu
• , Zhuowei Li
• , Jiaxin Guo
• , Hongchang Bao
• , Chunyu Liu
•  & Wenbin Guo

Journal of Materials Chemistry A (2021)

• ### Substitutions and dislocations enabled extraordinary n-type thermoelectric PbTe

• Cheng Qin
• , Lixun Cheng
• , Youwei Xiao
• , Cuilian Wen
• , Binghui Ge
• , Wen Li
•  & Yanzhong Pei

Materials Today Physics (2021)