I'm using an STM32F103 to measure water flow through a pipe using Hall flow sensors. My power supply is 12V DC to 5V/3.3V DC. STM works with 3.3V and Hall sensors with 5V levels. I've configured the TIM4 as Input Capture and connected it directly to the flow sensor output and I'm counting the number of ticks per second to determine the flow.
What I've noticed is that even when there is no flow, the sensor gives out random values. To the same PS I also have connected an LCD display, 2x Hall flow sensors, a 555 timer, and 2x STM32s. What I want to know is will this issue be solved by just using optocouplers on every input from Hall sensor to the GPIO pin? I'm thinking since all of these devices have a common ground there is a lot of noise in the system, but maybe the issue is something else?