The detection of the oxygen molecule is of particular interest due to various applications in chemical, biological, and environmental areas, and the typical materials of detecting O2 such as Clark-type electodes and optical oxygen sensors suffer from disadvantages such as insensitivity or usage of expensive instrument. In this paper, we present a nonporous two-dimensional viologen-based metal–organic frameworks consisting of pseudo-left- and right-handed helical chains [Cd(CPBPY)(o-BDC)(H2O)]·H2O (CPBPY = N-(3-carboxyphenyl)-4,4′-bipyridinium, o-BDC = o-benzenedicarboxylate) (1) that exhibits a slow photochromism under a vacuum, inert atmosphere, and even exposure to oxygen, and a three-dimensional porous 6-connected pcu topological metal–organic framework [Cd3(CPBPY)2(BDC)3]·DMF·H2O (BDC = 1,4-benzenedicarboxylate) (2), which displays rapid photochromism only under a vacuum or inert atmosphere. The photochromic product 2′ can quickly and conveniently detect O2 by naked eye recognition of color change. Th...