A Raspberry Pi is a single board computer with multiple ports (USB, HDMI, microSD, WiFi, Ethernet) and a 40 pin general purpose input output interface. This GPIO interface can handle a variety of (and multiple) connections. An operating system is usually installed on the RPi and applications (like OctoPrint) run on it.
An ESP32 is a "single-purpose" microprocessor with a GPIO interface like the RPi. It does not have an operating system. One application at a time is flashed into its memory.
What you haven't told us is anything about your project. What sensors are you considering?
I have multiple RPi (and similar) systems which I use for my 3D printing (LulzBot TAZ 6), an automated Telephone Call Attendant, and other projects. I also have some ESP32 systems with different displays. One runs a weather application, another is a "key-chain" Bluetooth scanner used to check for credit card scanners.
Don't be dissuade from your project. I and at least a few others think the combination of a PC(with an OS) and a microcontroller(with Firmware) is a good idea and can make for some powerful stable projects.
Note that there are industrial PC that include embedded ATmega/other controllers on the board to be programed and used as one system on the same board. If they are making them in mass, there must be something to it. Well in some industry anyway.
For an example of something that is likely similar to what you are thinking about, take a look at my PlugIn SIOControl.
Klipper provides a good example of a similar setup. Its developers despite its IO capabilities, didn't use the Pi as the main controller for a 3D printer, likely because PCs with operating systems aren't suited for time-sensitive tasks. Even boards with a Pi like compute module rely on a secondary microcontroller to handle the heavy lifting needed to focus on the "single-purpose" of running the printer.
@b-morgan makes a point, if you are going to use the Pi, you might want to think about how it could be used considering it has built in IO that might do what you want. Can it actually do what you want? Maybe not, but give it a few milliseconds of brain time.
I was suggested to use the DHT11 sensor, but it was not that suitable with the core idea. Now, I am using the touch sensor at the moment. The user touches the sensor, the ESP32 recognizes the thumb prints and prints the required output.