Introduction

Materials with complex 3D morphologies and promising properties are eminently desirable for many applications, including catalysts, sensors, and optoelectronic devices. Correspondingly, accurate control over morphology, composition, and uniformity is required during synthesis. Various bottom-up and top-down approaches have been employed to construct such 3D arrangements. However, either shape or composition can be accurately tuned using existing self-assembly approaches. In other words, obtaining both favourable spatial structure and preferred chemical composition simultaneously at the nano/microscale is challenging for many valuable material systems while relatively accessible for others. This is because several parameters must be precisely tuned, including chemical reaction equilibria, reaction thermodynamics and kinetics, crystal nucleation and growth, surface functionalizing ligands1,2,3,4.

For example, metal carbonates (MCO3; M = Ca2+, Ba2+, Sr2+, etc.) are a family of naturally occurring biominerals that can be manufactured in a variety of crystalline shapes and morphologies by means of environmentally friendly biological and bio-inspired mineralization routes5,6,7,8,9,10,11,12,13,14. However, the resulting carbonate hierarchical materials have restricted functionalities because of their limited intrinsic chemical compositions. On the other hand, many promising functional advanced materials are challenging to assemble into complex shapes. Halide perovskites (HPs), for instance, have emerged as a remarkable new class of materials with outstanding optoelectrical properties over the last decade. They possess promising optoelectrical properties such as suitable and tunable bandgap, balanced carrier mobility, defect tolerability, high photoluminescence quantum yields, etc., which lead to their rapid and remarkable development15. Although their versatility of synthesis and relatively simple scale-up are promising for many usages, spatially assembled HPs nano/microstructures are critically required for integrated advanced applications1,16. HP nanoparticles are routinely synthesized in organic solvents and with organic ligands (most of them are harmful to the environment). The caveat, though, is that complex 3D nano/microstructures of HPs are difficult to organize by conventional synthesis routes, as the crystallization of HPs is a remarkably rapid phenomenon, making it challenging to explore and monitor their growth pathway. Likewise, 3D patterning of HP thin films generally requires advanced techniques with specific instruments that are complicated, non-efficient, sluggish, arduous, and challenging to scale up1,17,18,19,20,21,22,23,24,25,26,27.

In solar energy conversion applications, it is well known that the optoelectronic properties of HPs are strongly contingent on their structural and morphological dimensionality28. Hence, developing novel approaches for rapid, straightforward, and scalable construction of spatial assemblies of HP individual nano/microparticles and thin films is highly in demand.

To circumvent the abovementioned challenges and obtain nano/micromaterials with specific composition and desirable features (e.g., size and shape), post-synthetic modifications of complex preformed 3D structures can be applied. For a long time now, researchers and scientists have smartly employed chemical reaction principles to convert naturally available and widely abundant materials into more valuable and functional compounds for advanced applications while preserving the valuable properties of the primary material29. For instance, metals and metal oxides have already been synthesized using oxidation/reduction reactions by converting both biological and synthetic materials30,31,32. Ion exchange is another powerful and versatile approach to tune the material composition and obtain many precious compounds, such as semiconductors, which can hardly be fabricated synthetically using conventional routes. Thereby, ionic micro/nanostructures can be converted into a broad variety of compositions with the advantage of preserving the original morphology3,33,34,35,36,37,38. There are two types of ion exchange reactions (IERs): cation exchange and anion exchange, with the latter being more difficult due to the larger size and lower diffusivity of anions3,34,36,39. Technically, the chemical transformation of present 3D arrangements into a particular composition provides control over both the chemistry and spatial geometry. Succinctly in the IER processes, the cation or anion sublattice of a pre-programmed nano/microstructure is substituted with different ions to manufacture superior material that possess exceptional morphology and homogeneity. The IER procedure is applicable for either partial compositional conversions through either cation or anion substitutions or full transformations by combining sequential cation–anion IERs1,3,5,39,40.

Effective and independent control over structure and composition during IER conversion depends on many factors, including but not limited to (1) the existence of fine nanocrystals (preferably 5–50 nm) to provide improved chemical reactivity, (2) the accommodation of volume changes during transformation by material scaffold, (3) the minimization of dissolution/recrystallization reactions to hinder/terminate formation of new nuclei and nanocrystals growth to avoid morphological alterations, (4) atomistic unit cell conformity with minimal rearrangements of the crystal lattice, (5) proper solid-state diffusion of reactants, (6) fast transport of ions toward and away from the nanoparticles within the whole assembly as well as precise control over (7) reagents concentrations, (8) pH (in case of solution conversion), (9) temperature1,3,5,40.

There are several examples of applying IER methods to obtain advanced materials with preserved structures41. Hendrikse et al. has recently studied the transformation of barium carbonates (BaCO3) from coral-, spiral-, vase-, and post-like shaped BaCO3/SiO2 composites into cadmium-, iron-, manganese-, and nickel-sulfides and oxides by a two-step IER process40. IER process is applied not only for ionic compounds but also to assemble materials with covalent characteristics. Beberwyckc and colleagues employed cation IER to synthesize III–V semiconductors, i.e., GaAs, InAs, GaP, and InP, from II–V nanocrystals, i.e., cadmium pnictides while maintaining original monodispersity and shape42. Powell et al. converted roxbyite-type Cu2−xS nanocrystals to wurtzite-type CoS and MnS via a cation IER. These are metastable polymorphs (in bulk systems), though they could be formed by IER thanks to the conservation of features of cation and anion sublattices43.

Substitution of halide ions in HPs is somewhat simple and occurs at room temperature owing to spontaneous migration of halide ions. It has been applied to the formation of lead HP nanocrystals of different shapes to adjust their emission color. Moreover, cation IER has also been employed to acquire mixed cation HP nanocrystals with distinct optoelectrical features16,44. Likewise, it has been demonstrated that the formation of spatially arranged HPs with interesting optoelectronic properties can be facilitated via IER from metal carbonates due to the crystal lattice similarities29,45. Holtus et al.5 has recently converted pre-programmed metal carbonate microstructures into HPs with the morphological and crystallinity retention of the initial micro-architectures. The process consists of introducing lead into the structure by cation IER, followed by anion exchange of carbonate group with halide moieties, together with rapid methylammonium insertion to produce HPs5. From a more recent work from the same group by Helmbrecht et al.1, ion exchange lithography was used to spatially pattern MAPbBr3 and FAPbBr3 semiconductors films by printing ion exchange “inks” on a reactive nanoparticle “canvas”. In this regard, a precisely controlled transformation of an electrically insulating canvas into semiconducting HPs happens through printing, painting, and spraying reactive inks on an ion exchange reactive canvas. Besides, they demonstrated that the ion exchange lithography methodology could be incorporated into the construction of optoelectronic devices such as light-emitting diodes1.

Molecular self-assembly using biological macromolecules provides means for bottom-up fabrication methods to nucleate, bind and organize novel nanostructured inorganic materials at low costs and with a wider range of morphologies. Inspired by biomineralization in nature, biomolecules and biomaterials, such as proteins and microorganisms, can provide nucleation sites to bind and organize nanocrystals and be rationally designed to enhance materials affinity and control the growth of nanocrystals46,47,48,49,50. These bio-species may serve as ‘natural’ reaction vessels and nanoscale bio-templates for directing the synthesis of materials with novel and complex morphologies. In this regard, various functional protein–inorganic composites with complex and well-defined structures have been synthesized. Proteins as simple as bovine serum albumin (BSA) can direct the growth of inorganic nanocrystals. For instance, protein templates have organized gold nanoparticles, quantum dots, and oxides at the nanoscale50,51,52. Copper phosphate nanoflowers were synthesized via ion nucleation by BSA, leading to the formation of branched petal-like shapes. In this case, simple electrostatic interactions contribute to nucleating ions, the protein acting as a biological ligand53. Likewise, fibrous proteins, such as collagen, chitin, filamentous phages, and amyloid fibers, represent bio-scaffolds of interest to synthesize nanowire-shaped objects54,55.

To the best of our knowledge, there have been rare reports of designing biomolecules-HP complexes so far56,57,58. Therefore, inspired by previous studies and nature, we aim to implement biomaterials (proteins, viruses) as nucleation templates to produce metal carbonates with desirable morphologies followed by subsequent IER to form HP nano/microstructures while preserving the original shape obtained by biomineralization. Using this methodology, we target towards (i) controlling the structure of HPs at the nano- and microscale, (ii) greener synthesis of HP nanostructures, and (iii) producing optically active nano/microcomposites. Our fabrication strategy provides a systematic, versatile, and customizable approach towards a wide range of HP morphologies with independent control over the chemical compositions, i.e., applying different halide ions. Also, we determine the effect of reaction time on conversion and structural evolutions during both IER steps, which has not been investigated before for HPs5. Finally, we showcased the capability of our bioinspired HPs for practical environmentally friendly usages by applying synthesized HP nano/micro-structures for humidity sensing applications. This method enables the conversion of bioinspired materials into semiconductors, equipping biological and programmable synthetic morphologies with the performance of artificial perovskite-based semiconductors.

Results and discussion

Biomineralization of metal carbonates

Biomineralization, as a nature-inspired approach in the sense of employing biological or bioinspired compounds as templates or growth modifiers, provides possibilities to produce nano/microscale crystals with incredibly diverse morphologies. Here we used biomineralization to form metal carbonates with various morphologies that we then converted to HPs while maintaining the original shape. Figure 1a shows the morphological variety of BaCO3 nano/microstructures synthesized by using bio-template method. While the shape of synthesized nano/microstructures can be hardly changed by merely altering synthesis parameters such as temperature and precursors concentrations (Fig. S1), employing bio-templates provides simple but powerful tools to produce complex nano/microstructures like stars, dumbbells, elongated morphologies, hierarchical, porous rods and branched mesoporous shapes (Fig. 2 and S2). In addition, bio-templates and synthesis parameters can be used simultaneously to control the complexity of the morphologies better and acquire desirable shapes. Besides BaCO3, we also synthesized calcium carbonate (CaCO3) nano/microstructures (Fig. 1b). CaCO3, as an abundant metal carbonate found in nature, has various polymorphs ranging from amorphous (amorphous CaCO3 (ACC)) to crystalline and from anhydrous (calcite, aragonite, and vaterite) to differently hydrated (calcium carbonate monohydrate and calcium carbonate hexahydrate)59,60,61. Calcite crystallizes in the hexagonal crystal system, forming face-centered rhombohedral unit cells62. On the other hand, aragonite occurs in the orthorhombic system but shares similar crystal structures with calcite in the sense of having alternating layers of carbonate and calcium ions perpendicular to the c axis. These structural similarities between aragonite and calcite lead to their similar thermodynamic stabilities. However, other distinct properties of the two phases result from the elevation of some carbonate ions in the c direction observed in aragonite, which gives rise to the formation of two layers of carbonate ions with different orientations61. Vaterite, generally as an intermediate polymorph during the transition from ACC to calcite, crystallizes in the hexagonal system with carbonate ions oriented parallel to the c axis. It is a loosely packed but much more complicated crystalline structure59,61. Here, CaCO3 3D assemblies are prepared with the same procedure using soluble starch and dispersed curli fibers54,63 as bio-templates (Fig. 1b). Similarly, the bio-templates can significantly alter the morphology of CaCO3 samples from cubic shapes (no template used) into spherical porous sponges, hierarchical, elongated rods, irregular particles, flowers, and hollow porous spheres. Temperature and precursor concentrations can be tuned together using bio-templates to better control the obtained morphologies and acquire broad types of nano/microstructures (Fig. S3-4). It is worth mentioning that we selected the current biomolecules to provide diverse types, different template structures, and comprehensive functionalities. Starch and BSA are cheap, abundant, and widely used biopolymers and proteins, respectively. The M13 bacteriophages are filamentous structures with a high aspect ratio (880 nm by 6.5 nm) of interest to produce elongated or branched carbonate shapes52,64. Curli fibers are fibrous proteins that can form spider web-like arrangements, hydrogels, and film, with the ability to be genetically engineered to obtain distinct functionalities54,63,65.

Figure 1
figure 1

Diversity of carbonate nano/microstructures formed with bio-templates. (a) Various BaCO3 nano/microstructures synthesized with (i) no bio-template, (ii) starch, (iii, iv) M13 bacteriophage, and (v, vi) BSA. (b) Different CaCO3 nano/microstructures formed with (i) no template, (ii, iii) starch, and (iv–vi) dispersed curli fibers.

Figure 2
figure 2

BaCO3 nano/microstructures with different morphologies synthesized with various solution temperature and precursors concentration using BSA as bio-template (scale bars: 1 µm).

The formation mechanism of various metal carbonate morphologies has been extensively studied before, so we did not intend to investigate it here. Briefly, the final structures and morphologies of MCO3 largely depend on the synthesis technique employed as well as the controlling factors such as pH, temperature, reaction time, solvent ratio, M2+ :CO32- ratio, mixing mode, substrate surface roughness, and the presence of additives as crystal growth templates (i.e., additive type and concentration), which have direct impacts on the crystal nucleation and growing process (Fig. S5-9). For example, the surface roughness of the chosen templates is important, as it affects the heterogeneous nucleation process by influencing the atom adhesion onto the substrate, the interfacial energy, and the surface energy. The impacts of additives and pH are correlated; namely, the addition of additives would result in a pH variation in the solution, which further improves the function of the additives, giving rise to the formation of various morphologies. The concentration ratio of M2+ and CO32− changes the electrostatic attractions between the positively and negatively charged groups in the solution while controlling the nucleation rate. The reaction temperature also has huge impacts on the polymorph, size, and morphology of MCO3 particles. More specifically, the energy of the reactive environment rises with an increasing temperature, which facilitates the formation of high surface energy aragonite (in case of calcium carbonate) crystals with a typical elongated rod-/needle-like shape6,8,61,62,66,67,68,69,70,71. Overall, in this work, the temperature increase is beneficial for particle growth and coarsening and pore size increase (Fig. S5-9), while the number of branches and branches’ diameter decrease by raising the synthesis temperature (Fig. S7). Also, very high temperatures (≈ 100 °C) cause the rough surface of particles and damaged morphologies. In terms of precursors concentration, the higher the precursors ratio, the larger the particles and pores size, as well as the more course the structures. While the number of nucleation sites is constant (i.e., template concentration), a higher concentration of precursors leads to faster grain growth and bigger particles (Fig. S5-9). All these controlling parameters mentioned above have intertwined effects on the formation of various morphologies; hence, they must be carefully controlled during the synthetic process to obtain the desired structures.

IER conversion to HPs

The conversion of metal carbonates into halide perovskite needs two IER steps which must be performed cautiously to preserve the original morphologies. We first started by converting barium carbonate (BaCO3) nano/microstructures, as it only crystallizes in the orthorhombic system at ambient temperature51,52. For the first IER, Pb2+ substitutes M2+ in MCO3 because PbCO3 is thermodynamically more stable (lower solubility in water than other MCO3)5. However, the dissolution of MCO3 and the subsequent nucleation and growth must be avoided to maintain the initial structure during IER. This means the conversion of MCO3 into PbCO3 has to be completed as fast as possible to hinder nucleation and growth of new PbCO3 particles by using high concentrated Pb(NO3)2 solution (near saturation) to force the cation exchange reaction towards the PbCO3 production5. Figure 3a represents XRD results of conversion of BaCO3 into PbCO3 over IER time from 1 to 10 min. Interestingly, strong PbCO3 peaks appear even after a very short period, which is an indication of the fast kinetic of cation IER. As time passes, progressively more BaCO3 are converted into PbCO3, and characteristic XRD peaks of PbCO3 become stronger. Eventually, after 10 min, the majority of BaCO3 is converted into PbCO3, and its XRD representative peaks are almost vanished. SEM micrographs (Fig. 3b) illustrate microstructure evolution of the formation of PbCO3 through cation IER. All converted PbCO3 samples demonstrate almost identical morphologies to the original BaCO3, proving a successful conversion reaction with well-maintained original structures. Furthermore, EDX elemental mapping (Fig. 3c) displays that Pb is homogeneously distributed all over the surface of the sample, meaning that the conversion reaction was unselective and uniform. Ba2+ ions are also present in the EDX elemental mapping. This is due to the formation of a core–shell structure, with BaCO3 in core and PbCO3 on the surface of the nano/microstructures.

Figure 3
figure 3

BSA-templated BaCO3 nano/microstructures converted to PbCO3. (a) XRD spectra for different conversion reaction time (1–10 min). Arrows show BaCO3 peak positions that are vanishing over IER process. (b) SEM micrographs of BaCO3 and converted PbCO3 with preserved original nano/microstructures (scale bars = 2 µm). (c) EDX elemental mapping of converted PbCO3 nano/microstructure after 3 min of conversion reaction time (scale bars = 1 µm).

In the final step, the anion IER is responsible for converting PbCO3 into MAPbBr3. This step also needs to be performed carefully to preserve the original shape of the metal carbonate. However, as anions have a larger size and lower diffusivity, the anion IER is more difficult and critical than cation IER. In fact, anion IER contains an intermediate step of formation of PbX2 composition prior to the full conversion into the halide perovskite5. Therefore, it requires well-established insertion of CH3NH3X and rearrangement of the crystal unit cell during anion IER, making it more difficult and slower than the former cation IER. Unlike the previously reported anion IER of PbCO3 to HPs in the gaseous form5, we fulfilled this step in liquid form using IPA. The liquid phase transformation can accelerate the reaction rate; however, precise control over the reaction is required to retain the fine features during the conversion5. In liquid phase conversion, the solvent should only dissolve the MAX salt but not dissolve the HPs. In addition, adequately high vapor pressure and partial wetting ability of the solvent are necessary to enable complete evaporation and diffusion inside the pores of the particles, respectively. Therefore, IPA is selected as an appropriate solvent1. Figure 4a shows the XRD results of anion IER versus reaction time from 5 min to 24 h. Small characteristic peaks of MAPbBr3 start to appear after 5 min of reaction and the peaks intensities gradually increase over reaction time as more PbCO3 are converted into MAPbBr3. However, the reaction is not complete even after 24 h, representing the slower rate as well as higher complexity of anion IER. To prove the formation of MAPbBr3, converted MAPbBr3 samples at different IER times were excited by a laser with 405 nm wavelength, and the emission of the particles was measured (Fig. 4b). Photoluminescence (PL) intensities of the converted MAPbBr3 samples increase with the rising of the anion IER time up to 30 min, resulting from the formation of more MAPbBr3 on the surface of the particles, then decrease by a further increase of IER time. The position and full width at half maximum (FWHM) of PL peaks are about 535 and 25 nm, respectively, which are consistent with optical properties of stoichiometric MAPbBr3 compound and indicate the full conversion of BaCO3 samples into MAPbBr3 nano/microstructures (Fig. S10). However, 15 nm redshift in PL spectra is observed over IER time. This might come from the fact that at a shorter IER time (≤ 30 min), the formed HP layer on the surface is very thin (in nanoscale range), and it progressively becomes thicker until it forms a bulk HP layer. SEM results depict the microstructures of the original BaCO3 and converted PbCO3 and MAPbBr3 samples (Fig. 4c). All morphologies resemble the original BaCO3 shape, offering effective conversion from metal carbonates into halide perovskite compound with preserved morphologies.

Figure 4
figure 4

Conversion of BSA-templated BaCO3 nano-/microstructures into MAPbBr3. (a) XRD spectra for different conversion reaction time from 5 min to 24 h. (b) PL spectra of converted MAPbBr3 nano/microstructures at different conversion reaction time from 5 min to 24 h. (c) SEM micrographs of BaCO3, PbCO3 and converted MAPbBr3 with well-maintained original morphologies at different IER time (scale bars = 3 µm). (d) EDX elemental mapping of converted MAPbBr3 after 30 min conversion reaction time (scale bars = 2 µm).

Figure 4d and S11 show EDX elemental mappings of converted MAPbBr3 samples with different morphologies at different anion IER times. Uniform conversion into MAPbBr3 composition is shown by the homogenous distribution of Pb and Br ions all over the surface of the samples. In addition, Ba ions (in the core) are also present due to the core–shell form of structures resulted in IER. The formation of core–shell structures results from the IER initiated at the surface of metal carbonate particles and from the fact that Pb2+ ions (and later CH3NH3+ and Br- ions) diffuse into BaCO3 particles gradually over time. However, transformation inside BaCO3 particles is more challenging, and if the reaction time is too short, some BaCO3 particles may still exist in the core. The remaining BaCO3 is not problematic as BaCO3 is in the samples' inner parts (core). It can also be helpful to maintain the original morphologies by functioning as a scaffold and prohibiting the destruction of the 3D architectures40. In terms of applications, the existence of BaCO3 core is neutral as in most applications such as sensing properties of HPs, the surface properties of the samples determine the performance.

Interestingly, although the most obtained CaCO3 samples were in calcite form, they all could be converted effectively into MAPbBr3 nano/microstructures. Fig. S12 represents green light emissions under UV light irradiation of successful conversion of CaCO3 samples into MAPbBr3 synthesized with starch as bio-template at different temperatures and precursors concentrations. EDX elemental mappings of two converted MAPbBr3 samples with different morphologies reveal the uniform distribution of Pb2+ and Br- ions together with Ca2+ (from the core of the converted particles) while the original morphologies are well maintained (Fig. S13a). However, as the synthesized CaCO3 nano/microstructures have calcite type of atomic structure (hexagonal crystal system), the conversion into halide perovskite with the orthorhombic unit cell is more challenging, and the chance of structural distortion is higher compared with when the unit cell of metal carbonate is also orthorhombic (i.e., aragonite polymorph). Therefore, there are more possibilities to deviate from uniform conversion, and some other particles might start to form during the ion exchange reactions due to dissolution of metal carbonates and subsequent nucleation and growth of new particles on the surface (Fig. S13b). However, appropriate conversion reaction kinetics by using optimized concentrations of conversion solutions as well as reaction time and temperature can minimize the formation of new particles and assist the preservation of original morphologies.

The shape-preserving mechanism during ion exchange, complete chemical and structural transformation, rearrangement of the crystal unit cell, and minimum distortion of the crystal lattices are critical requirements for the successful conversion. In the first step, PbCO3 forms by replacing metal cations with Pb2+ ions within the carbonate material via cation IER. Higher thermodynamic stability of the resulting PbCO3, similar orthorhombic crystal structures of both MCO3 and PbCO3 as well as high concentration of Pb2+ and minimum dissolution- recrystallization of MCO3 guarantee the fast and complete conversion with minimized distortion of the unit cell. Secondly, the resulting PbCO3 architectures are converted directly into the HPs in a one-pot transformation via exposing the PbCO3 microstructures to a high concentration of dissolved CH3NH3X to push the reaction towards the consumption of the intermediate PbX2 phase and the formation of the HPs at room temperature1,5,72. This is a more challenging step due to the nature of anionic IER that anions are larger species with lower diffusivity. Fortunately, the carbonate anion can perform as a good leaving group for introducing the desired halide, and the intermediate PbX2 phase crystal unit cell resembles that of PbCO3 and many other carbonate compounds MCO3 (orthorhombic crystal structure). PbX2, PbCO3, and MCO3 possess the same metal ions crystal positions and relatively similar unit cell dimensions, thus facilitating the IER and maintaining the 3D morphology, fine features, and crystallinity of the preliminary structure. Moreover, the negative Gibbs free energy of formation of acquired HPs in comparison with the employed precursors and PbX2 spontaneously drives the transformation process1,5,40,72. Apart from the aforementioned parameters, other important control considerations during the entire IER procedure include pH, temperature, and the molar ratio of halides and organic cations5,40,73,74,75. The presented results confirm that many carbonate micro/nanostructures can be initially produced and subsequently converted into HP materials.

To establish the versatility of our method, we converted metal carbonate samples into HPs with different halide anions to produce MAPbI3 and MAPbCl3 beside the MAPbBr3 compositions (Fig. 5 and S14). Results show that HPs with different halide groups and various emission colors can be formed by selecting the corresponding MAX precursor in IPA solution. The emission wavelength as well as FWHM of MAPbCl3, MAPbBr3, and MAPbI3 compositions are 406, 25, 546, 25, 792, 50 nm, respectively, consistent with previously reported characteristics. Consequently, the color of the light-emitting architectures, together with their band gaps, can be adjusted over the entire visible range while the original structure is well-preserved.

Figure 5
figure 5

Conversion of nano/microstructures with different perovskite compositions. (a, b) PL and absorption spectra of MAPbCl3, MAPbBr3, and MAPbI3 samples obtained by IER of metal carbonate nano/microstructures. (c) EDX elemental mapping of converted (i) MAPbCl3, (ii) MAPbBr3, and (iii) MAPbI3 samples using M13 bacteriophage, BSA, and starch, respectively (scale bars = 2 µm).

Device fabrication

Despite the instability of HP compounds against environmental factors, i.e., oxygen, illumination, moisture, temperature, etc., it has been shown to be beneficial for sensing applications. In this regard, a number of gases, metal ions, pesticides, organic molecules as well as temperature sensors based on HP materials have already been manufactured76. Chen et al. developed a visible-light photoelectrochemical biosensor for the detection of dopamine based on TiO2/CsPbBr1.5I1.5/Nafion electrode from 0.1 to 250 μM77,78. Maity et al. 79 has recently innovated a paper-based color change visual sensor made up of CH3NH3PbI3 as the active material to detect ammonia gas. The mechanism involved is the color change of black CH3NH3PbI3 film on the paper to yellow color due to the decomposition of CH3NH3PbI3 to PbI2 when exposed to meager amount of NH3 gas ( 10 ppm) with a fast reaction time of approximately 10 s. The same group has later manufactured an electronic paper-based solid-state NH3 gas sensor with sub ppm sensitivity better than 1 ppm, using the same principles as the previous visual color change gas sensor80.

We also believe our approach helps expand the use of HP 3D assemblies not only for the HPs conventional applications but also for new usages such as biological and environmental applications. As proof of concept, we fabricated a disposable thin film device by simply casting HP nano/micro-structures on paper substrates to demonstrate the beneficial and practical capabilities of the as-prepared HPs 3D nano/micro-composites. Our approach for constructing the paper-based humidity sensor is outlined in Fig. 6a. To prepare the humidity sensing device, we applied the assembled 3D nano/microstructures with CH3NH3PbI3 composition on a paper substrate by simple drop casting method from the IPA solution at the last conversion step, followed by rinsing with IPA to wash it out. The fast IPA evaporation helps the deposited film quickly dry, and the porosity of the paper substrate assists appropriate attachment of CH3NH3PbI3 nano/microstructures. Finally, electrodes are created by applying silver paste on both ends of the device by hand.

Figure 6
figure 6

Fabrication of thin film humidity sensors using bio-templated MAPbI3. (a) Schematic illustration displaying the construction steps of a disposable paper-based sensor from the 3D shaped MAPbI3 nano/microstructures. (b) I–V characteristics of the fabricated paper based CH3NH3PbI3 device as a function of humidity in linear scale. The inset shows the top view of fabricated paper-based device with actual dimensions. (c) Logarithmic representation of the I–V data over different humidity conditions. (d) Multiple cycles of sensing ability of the fabricated device for humidity range between 20 and 90%. (e) Device current as a function of humidity levels and reversible adsorption–desorption behavior, showing high linearity with R2 = 0.9965.

As depicted in Fig. 6b,c, the conductivity of the CH3NH3PbI3 paper sensor continuously increases as a function of humidity rise in the wide range of 11–95%, which is reasonably comparable with other HP based humidity sensors (Table S1). The considerable increase of more than 5 orders of magnitude of the current when the humidity increases from 11 to 95% implies promising moisture adsorption capability as well as strong moisture-induced effect on the charge transport characteristics of the sensor. The stability and reproducibility of the device are shown in Fig. 6d by cyclic measurement of the film current upon exposure to humidity conditions between 20 and 90%. Figure 6e shows the variation of current values on a logarithmic scale at a potential bias of 5 V with a linear performance (coefficient of determination R2 = 0.996) throughout the studied range, offering a viable humidity-sensing range. In addition, the current values are measured during the desorption process, which demonstrates the formation of a small hysteresis between adsorption and desorption steps. This is due to the binding of adsorbed water molecules with the HP particles as well as pores and capillaries, which require a longer time for dehydration processes to take place. The excellent long-term stability of the sensor is determined by relatively steady current values over two months at 35% ambient humidity (Fig. S15), indicative of a daily life sensing application.

According to previously reported papers, different hypotheses are proposed to explain how water adsorption causes conductivity enhancement of HPs. For instance, it has been suggested that water molecules on the surface act as electron acceptors and improve the HPs conductivity or introduce new states in the HPs band gap by triggering lattice distortion that boosts the conductivity81,82. However, most recently, Ilin and coauthors83 explained that both ionic and electronic modes of conductivity are concurrently possible at room temperature. At low humidity conditions (water vapor pressure below 10 mbar), electronic conductivity is dominant by passivating dangling bonds on the surface of HPs. At higher humidity, more than one monolayer of water molecules may be adsorbed in the pores, helping protons mobility, resulting in domination of ionic conductivity83,84,85,86,87,88.

There is strong evidence that sensing and catalytic performances of several types of materials can be strongly dependent on particles morphology. Desirable morphologies to provide high sensitivity are required to have high purity, good crystallinity, and preferably porous microstructure, which are advantageous for electron transfer. Besides, nano/microfeatures of the desired shapes have significant influence on the surface area, active sites, and charge carrier kinetics of materials, which can efficiently impact on sensing performance. A large specific surface area is often essential to provide more active sites, absorb more analytes, and permit the electrons to transit inside the pore cavities, hereafter accelerating the sensing activities. For example, the nanoscale morphologies of the CH3NH3PbI3 perovskite films can strongly affect the device sensitivity to O2 gas89. Recent report showed that the dimensionality of CsPbBr3 perovskite films have also large impact on sensing ability to common explosive vapors as external stimuli. Response of the films made of nanocrystals was larger and faster than their 2D and 3D counterparts because of less dense film, easier pathways for the vapor to percolate into the film, much larger surface area, and increased exciton binding energy90. Humidity is a physiochemical phenomenon and the capability of an active material to sense the presence of moisture mostly depends on the reactivity of its surface, i.e., the accessibility of adsorption sites and the interaction strength between the adsorbate and the water molecules. The reactivity of the surface relies on the surface chemistry (cation/anion distribution) and morphology. Different morphologies like rods, rod-flowers, flakes, and flake-flowers were revealed to alter the electrical, optical, and sensing properties of nanostructured SnSe samples91. The rod morphology had the best humidity sensing performance with high sensitivity, good repeatability, low hysteresis in the absorption–desorption process, and good reproducibility. Hexagonal morphology of CoFe2O4 nanoparticles demonstrated higher sensitivity and faster response/recovery time for humidity sensing in comparison with spherical, and cubic nanoparticles92. Likewise, the performance and response time of our humidity sensor is improved in the order of branched-porous > elongated rod > cubic morphologies, conceivably due to their active surface area, accumulation ability for humidity, and better charge transfer rates (Fig. S16a). However, all morphologies eventually reach the same sensitivity range. Furthermore, the stability of the built humidity sensor strongly depends on the morphology of the particles used to create the perovskite film. Figure S16b demonstrates that the film composed of more hierarchical porous nano/microstructures exhibits the greatest stability over a period of two months, while the film formed from large cubic particles (i.e., no template used for the synthesis) shows the least stability, with significant performance fluctuations after about two weeks.

Our homemade device dimensions (1.5 × 2.5 cm) are much bigger than similar ones reported previously83,87, demonstrating the straightforward scalability of our approach (Fig. 6b). To show the versatility of our device, we deposit CH3NH3PbBr3 HPs on paper, and the I–V curve is presented in Fig. S17. Furthermore, we subjected our paper-based sensor to ammonia gas to authenticate its power for biological usages. It shows conductivity increases more than 2 orders of magnitude upon exposure to ammonia gas on par with previously reported sensors (Fig. S18)93,94,95.

Overall, this prototype design already proves its potential for real-life optoelectronic applications. Our device performance may be further improved by providing better attachment between the HP particles themselves together with the electrodes. Intriguingly, our paper-based nano/microstructured gas sensor can be introduced to the next-generation smart biosensors with several advantages: rapid and selective detection, high sensitivity and instant response to biological molecules, large linear range of detection, simple construction, low cost, simple operation, disposability, to name a few. Also, complex 3D assembled morphologies provide high surface area, maximizing detection and improving charge transport for higher sensitivity and performance. Last but not least, most conventional sensors require operating at high temperatures, having low selectivity, slow response/recovery rate, and poor detection limit96,97, but our device can work at room temperature with no need for an external power supply.

Conclusion

In summary, we combine versatile bio-template and biomineralization techniques with morphology controlled IER approach to assemble naturally inspired complicated HP 3D geometries with nano/micrometer accuracy. Structural and elemental analyses confirm the chemical transformations with conservation of the nano/microscopic morphologies and nanocomposites layout. We showed the reaction time is critical on conversion and structural evolutions during both cation and anion IER steps, which has not been investigated before for HPs. We find that the nanocomposite layout also supports the formation and shape preservation of intermediate phases (e.g., PbCO3 and PbX2) and final HP products. Despite the control over the 3D structures, we also tuned the chemical composition of the naturally inspired HPs and constructed a paper-based thin film prototype device for environmental applications such as humidity and gas sensing. Therefore, this approach bestows biologically inspired materials with desirable combinations of characteristics and eventually enables applications ranging from potent catalysts and sensors to high-performance optoelectrical devices.

Materials and methods

Precursors

All precursors were directly used as received without further modifications or purifications. BaCl2 (99%, ACP Chemicals), CaCl2 (99%, ACP Chemicals), Na2CO3 (99%, ACP Chemicals), Pb(NO3)2 (99%, Acros Organics), HI (48%, ACP Chemicals), HBr (48%, Sigma-Aldrich), HCl (36–38%, Sigma-Aldrich), Methylamine solution (CH3NH2, 40 wt.% in water, Sigma-Aldrich), Distilled water, isopropanol (IPA, 99%, Bio-Basic), BSA (98%, BioShop), starch (98%, Sigma-Aldrich).

Synthesis of CaCO3

To prepare for the CaCO3 synthesis using spontaneous precipitation method, aqueous solution of CaCl2·2H2O (20, 50 and 125 mM), Na2CO3 (20, 50, and 125 mM), soluble starch (0.25 wt%), and dispersed curli fibers (expressed from Escherichia coli bacteria and isolated from previously reported method54,63) suspension were first prepared as stock solution (0.25 wt%). Next, 40 ml of both CaCl2·2H2O and Na2CO3 solutions with the same concentration were taken from the respective stock solution and injected into two separate beakers. The same amount (40 ml) of bio-template solution was then injected to the beaker containing CaCl2·2H2O and kept under moderate stirring for 10 min. Hot plate and ice bath were used for carrying out synthesis under different temperatures (0, 25, 50, and 75 °C). To initiate the precipitation, Na2CO3 solution was quickly injected to the solution mixture while being stirred vigorously for another 1 min. Quickly after, the product solution was transferred into a conical tube to perform repetitive washing and centrifugation steps for removing soluble by products from the solution and collecting the CaCO3 particles formed. The white precipitates of CaCO3 were then dried in air and followed by calcination step in furnace at 450 °C for 30 min to fully crystalize the samples and remove the bio-templates.

Synthesis of BaCO3

Despite some small alterations, the same procedure was employed for the fabrication of BaCO3 nanostructures under different temperatures (0, 25, 50, 75, and 100 °C) and by using soluble starch (0.25 wt%), M13 bacteriophage (1.66 × 1013 phages/ml, obtained from previously reported method52,64), and bovine serum albumin (BSA, 0.25 wt%) as bio-templates. For BaCO3 synthesis using M13 bacteriophage, the concentrations of both reactant solutions (CaCl2·2H2O and Na2CO3) were diluted to 2 mM, and 500 μl of M13 bacteriophage solution was used along with 200 ml of each reactant.

Conversion of MCO3 to CH3NH3PbX3

Before converting CaCO3 and BaCO3 into the corresponding halide perovskites, they must be first converted into PbCO3 through cationic exchange. To do so, Pb(NO3)2 was first dissolved in water to form a Pb(NO3)2 solution with a concentration of 0.9M. The Pb(NO3)2 solution was then added to the MCO3 samples and incubated from 1 to 10 min at room temperature before washing the PbCO3 sample produced with water and acetone. Appropriate amount of CH3NH3X (500 mg) was dissolved in isopropanol (IPA) to obtain a CH3NH3X/IPA mixture with a concentration of 0.13 M. 50 ml of this mixture was then applied onto the converted PbCO3 from the previous step to produce final CH3NH3PbX3 by performing anion exchange reaction in liquid phase at different reaction times (up to 24 h).

Characterization

X-ray diffraction (XRD) analysis was performed with a Bruker D8 Discovery X-ray Diffractometer (VANTEC Detector, Cu-Ka (alpha)). Scanning electron microscopy (SEM) imaging was carried out using a FEI Quanta 450 ESEM at 10 kV. SEM X-ray spectrometer (EDS) was used for the determination of elemental chemical composition. UV–Vis absorption and photoluminescence (PL) spectra were recorded with Thermo Scientific Evolution 300 UV–Vis and Horiba Flouromax-4 spectrophotometers, respectively. The I–V measurements we conducted using an Agilent B1500A Semiconductor Device Analyzer in a humidity-controlled chamber at ambient temperature (Fig. S19).