@jim-p there's no any adjustment point on sensor body, how I'll do that?
@jim-p I want sensor to detect object and send signal to LCD to count it. and when there's no object, sensor should not detect and LCD should not count.
But in my scenario, the red indicator beeps when no object and LCD counts, and as soon as object comes, red indicator disappears and LCD stops counting. @jim-p what should I do now?
You've understood that a led needs a current limiting resistor (say 300R to 1k ) if you are powering it with 5 volts DC .
What, incidentally, is the source of the 5v DC that you have been applying to the sensor? I'm beginning to suspect that a plausible explanation for the symptoms you have described (continuous counting when the relay is in a specific state) is a failure to understand that the GND connection in the diagram in post #4 must (also) be connected to the GND of the ESP32.
EDIT
That is, I'd guess that since the counter code looks OK (although the results may be inverted) and the module relay could not cause the unwanted "counts", at least not at the frequency you have reported, then the cause is probably a floating ESP32 pin. This may not have been visible in the sketch in post #22 because of the 200ms delay. Also, since you appear to have made a voltage divider by chaining a number of resistors in series, a break somewhere in that chain could also lead to floating ESP32 pin.
@6v6gt I have tested it.
When hand/object comes infront of sensor, LED stays ON, and when there's nothing, sensor and LED both blink with frequency of mili seconds and sometimes 1 second delay, both not properly stay OFF.
Dear All,
It is counting now with respect to required condition.
The position of sensor was horizontal, which was creating problem, I placed sensor vertically and now it's OK.
Now I want this real time counting on PC through serial communication (WiFi connectivity), what to do for this.
Do you want the data collected by the sensor to be visible only in the internal network somehow (say through web browsers etc.) or do you want the data to be visible on the entire internet ?
You've talked about real time but, in reality, how up to date must the data be when viewed from external systems ? That is, how much latency can be tolerated.
Can you explain a bit about how the data, which looks something like the count of objects on a production line, is going to be processed and especially why that processing can't be done on the same device that is doing the counting. That is the ESP32.
Internal network only (like within my factory/office)
@6v6gt I require immediate, real-time transmission of count data that matches exactly what's displaying on my LCD screen. When a box/carton passes through the sensor and increments the counter, I need that same count reflected instantly in the monitoring system.
Additionally, I need the system to:
Maintain an hourly record of boxes counted
Show the current counting rate as boxes pass through
Store historical data of previous counts for reference
For example, if 100 boxes passed through between 9:00-10:00 AM, I should be able to see this historical count while also monitoring the current count happening at 11:00 AM.
The latency should be minimal (milliseconds) to ensure accurate tracking of fast-moving products on my production line. Any significant delay between the physical count and the data transmission could lead to discrepancies in my production records.
Surely you can use digitalRead() in the loop() to detect if a button is being pressed. If the button is being pressed then set the value of the variable count to 0. There is no need for debouncing of the button or any other complexities. You need only two connections to the button but you must choose two diagonally opposite pins.
jim, push button connection is not difficult thing for me at all,
I want help in serial communication to system, that I mentioned below:
I require immediate, real-time transmission of count data that matches exactly what's displaying on my LCD screen. When a box/carton passes through the sensor and increments the counter, I need that same count reflected instantly in the monitoring system.
Additionally, I need the system to:
Maintain an hourly record of boxes counted
Show the current counting rate as boxes pass through
Store historical data of previous counts for reference
For example, if 100 boxes passed through between 9:00-10:00 AM, I should be able to see this historical count while also monitoring the current count happening at 11:00 AM.
The latency should be minimal (milliseconds) to ensure accurate tracking of fast-moving products on my production line. Any significant delay between the physical count and the data transmission could lead to discrepancies in my production records.