**1. Introduction**

Developments in society have brought about renewed focus on environmental problems, and a growing need for simple and accurate sensors that can respond to environmental changes has emerged. In nature, there are various creatures that can smartly change color with the environment [1]. Chameleons, for example, can adjust the color of their skin to the color of their surroundings [2]. Zebrafish can change their appearance under light [3]. Some beetles respond to humidity. Inspired by this phenomenon, researchers have synthesized a series of materials that can respond to the surrounding environment by color.

Among various materials, responsive polymer gels are good candidates for mimicking the responsive colors in natures because they are able to change their volume by swelling or deswelling under the stimulation of external conditions and such change can be elaborately converted into optical signals to achieve a visual response to the analyte [4–6]. Based on this mechanism, several colorimetric

sensors using polymer gels have been fabricated that respond to pH, temperature, humidity, glucose, macromolecules, and metal ions, among others [7–9].

Photonic crystals, a class of most interesting optical materials, are usually constructed by two or more media with different refractive indices arranged periodically in one, two, or three dimensions (1D, 2D or 3D, respectively) [10]. Because photonic crystals can produce band gaps for photons of a certain frequency, various film colors can be generated. Considering the unique advantages of photonic crystals in optical sensing, researchers have combined them with polymer gels to form advanced response materials. In a pioneer work, Asher's group synthesized a polymer colloid array (PCCA) to quantitatively detect glucose by embedding polymer gel into 3D colloid crystals [11–14]; they also fabricated a 2D hydrogel sensor by attaching a 2D colloid array to hydrogel, and this sensor could change its lattice spacing by swelling of the gel to achieve a visual response to the analyte [15–19]. Polymeric 1D photonic crystals or so-called Bragg stacks have been fabricated by spin-coating of block copolymer solutions [20,21]. Despite their many benefits, however, the problem of slow responses greatly limits the development and application of these sensors. For example, the PCCA glucose sensor requires over 90 min to respond to the analyte [13].

To improve the response speed of sensors, a reverse opal polymer gel was developed using SiO2 or polystyrene (PS) microspheres as a template [20–28]. The presence of macropores in the film structure enhanced not only the responsiveness of the resulting sensor by increasing its specific surface area but also the transport of the analyte; the resulting response speeds were improved to a certain extent. However, 3D hydrogel pH sensors with an inverse opal structure still require a response time of 20 min to achieve equilibrium [23]. The response speed is proportional to the rate of volume change of polymer gels, and the change rate of gel volume is inversely proportional to the size of the gel [29]. An interfering gel film with a sub-micron size was synthesized by Zhang et al., and the complete response of this film to glucose was achieved within 2 min [30]. Li et al. fabricated reverse opal polymer gel thin films with sub-micron thickness by using MCCs as the template and achieved a fast response to pH within 1 min [31]. However, the stability of these films was weak and the linear relationship between the dip shift of the films and pH could not be maintained under the condition of strong acidity. Recently, we fabricated ultrathin polymer gel films that are infiltrated into MCCs, which show excellent stability in strongly acidic solution [32].

Besides response time, a good linear relationship between the stimulus and the response is of grea<sup>t</sup> significance to a sensor. An ideal sensor has not only a simple calibration process but also constant sensitivity and accuracy over the entire measurement range to enable reliable responses to the environment. However, research on the linear relationships of polymeric gel-based sensors is limited. 2D-PCCA films could respond to the analyte by changing the spacing of colloidal crystals, but a poor linear relationship among pH [15], antibiotics [16], and serum was found because the 2D structure of the colloidal array limited lateral swelling to some extent [17]. Although the interfering gel film shows a good linear relationship between the response and glucose concentration, it has very weak optical signals. Thus, the visual response could not be achieved [30].

Hysteresis is another common issue for polymeric gel-based optical sensors. The Donnan potential presents in low-ionic strength solutions and hinders protonation of gels by diffusion and thermodynamic exchange limit elimination of swelling, thus most polymer gel sensors show hysteresis [14]. Serpe's group synthesized a PNIPAm-*co*-AAc microgel that could respond to pH and temperature [33]. The hysteresis loop size of this sensor could be adjusted by using solutions of various ionic strength and changing the concentration of AAc. Although the hysteresis was improved, the phenomenon remained; in theory, however, hysteresis may be completely eliminated after a long period. This problem seriously affects the practical applications of the film for continuous testing.

Targeted at above-mentioned issues, we present herein the fabrication of ultrathin photonic polymer gel films (UPPGF) by using non-close-packed monolayer colloidal crystals (ncp MCCs) as the template. Poly-(2-vinyl pyridine) (P2VP), a weak electrolyte, was chosen for this study because of its pH-dependent swelling ability. Swelling of the polymer gel led to changes in film thickness and shifts in reflection peak. The responsiveness of the proposed sensor was directly related to the volume change of the polymer gel. The filling fraction and total volume of P2VP in the film could be adjusted by controlling the packing density of the ncp MCCs by varying the time of O2 plasma etching, which was proven to play an important role in improving the responsiveness and linearity of the pH sensor. The film had an overall sub-micron thickness, which promoted ion diffusion and swelling of the gel, leading to fast response speed and small hysteresis loops. The good adhesion between the ncp MCC and the substrate enabled the ordered structure of the film to be maintained, ensuring good cycling stability of the sensor even after repeated testing. The well-designed UPPGF is simple and reliable for visualized monitoring of analytes and their concentrations, and can be easily combined in sensor arrays for more accurate detection by cross-sensing.

#### **2. Materials and Methods**

#### *2.1. Raw Material and Reactants*

Poly-(2-vinyl pyridine) (P2VP) (*M*w: 159 kg mol−1, Fluka), 1,4-diiodobutane (DIB) (99%, Alfa Aesar, UK), nitromethane (NM) (99%, Sinopharm, Shanghai, China), tetrahydrofuran (THF) (99.0%, Guangcheng, Tianjin, China), diethyl ether (DE) (99.5% Fuyu), styrene (95%, Beijing Chemical Co., Beijing, China, washed in NaOH before use), potassium persulfate (99.5%, Beijing Chemical Co., Beijing, China), sodium dodecyl sulfate (SDS) (*M*w: 288.38 kg mol−1, Kermel, Tianjin, China), ethanol (99.7%, Sinopharm, Shanghai, China), and ultrapure water (≥18.2 MΩ, Milli-Q Reference, Beijing, China) were used in this work.

#### *2.2. Preparation of Close-Packed Monolayer Colloidal Crystals*

First, polystyrene (PS) spheres (438 nm in diameter; standard deviation < 10%) were synthesized by standard emulsion-free polymerization [34]. Si wafers (one side polished) were cut into 1 cm × 1 cm squares, treated with piranha solution, rinsed with copious amounts of water, and dried under a N2 flow. The cp MCCs were then formed on the silicon wafer by the gas–liquid interface self-assembly method [35]. The adhesive force between the colloidal crystals on the silicon wafers was strengthened by annealing at 80 ◦C for 24 h. The cp MCCs were etched for different times (2, 4, 6, or 8 min) by O2 plasma etching with a 150 W power plasma cleaner (Beijing Huiguang Co., Beijing, China) to form ncp MCCs. The oxygen flow rate was maintained at 200 mL/min and 20 ◦C.

#### *2.3. Preparation of UPPGF*

Quaternization of P2VP was carried out following the procedure reported by Tokarev et al. [36]. With some modifications. Briefly, 0.1 g of P2VP and 0.1 mL of DIB were dissolved in a mixture of NM (4 mL) and THF (1 mL) under stirring at room temperature. Then, the solution was heated at 60 ◦C with stirring for 80 h to accelerate the quarternization reaction between P2VP and DIB. An excess amount of DE was added to the mixture, and centrifugation was performed to eliminate THF and the residual DIB. Then, qP2VP was dissolved in 5 mL of NM to form a 3.25 wt % solution for subsequent spin-coating. The qP2VP solution was spin-coated onto ncp MCCs at a speed of 1000 rpm for 1 min using a spin coater (Laurell-WS650). Finally, UPPGF was obtained after thermal crosslinking at 120 ◦C for 48 h.
