Car counter

I would like to put an ESP32 out by my mailbox and use some sort of beam sensors to count cars going by. I would want to record the number, speed, and direction of the cars and put it into a report. How would everyone recommend going about this?

I can only think of one safe way to do something like that and that’s to use something like a TOF (time of flight) sensor or ultrasonic distance sensor.

You definitely don’t want to use any type of laser device that would shine across a public road. the potential for injury, and therefore legal liability, would be pretty high.

I’m not sure how far away the cars would be so range might be an issue for those types of sensors.

you can count cards like that but to get speed and direction you would need two at a known distance apart.

Otherwise a pre-built radar gun would work best. But I doubt they have any way to send any signal to HA or if so then they are likely going to be way expensive.

Where is the potential for injury? I was thinking of using something like the takeout shops use on their doorways. I think it sends an IR beam across to a reflector.

Yes I have IR beam across my gate. Sensor on both sides; one to make the beam and the other to detect the beam and act as the reporting node.

This is not “intelligent”; it just detects when the beam is broken. It does not know the direction, speed or what the object is.

If you had a second pair at a measured distance away; then you could know the direction of the object, speed (because you know the distance) and start a count.

If you had Frigate installed with a camera, then object detection would be able to identify the cars, count the cars and record the number plate.

In my country, all this would be illegal on a public highway.

This doesn’t solve your question but you might find this interesting.

My community has this device installed. It measures speed and shows a smiley face if people are not speeding through the kindergarden area… :slight_smile:

viasis-geschwindigkeitsanzeigetafel

I was surprised to find out that with a bit of hackery you can retrieve data from these. You get speed per passing car, with datetime. Quite a lot one can do with that. Here is our Grafana dashboard:

Speed limit is 50km/h, max speed captured so far was 104 km/h at 2:00am :upside_down_face:

Seriously? Have you never seen any warning sign on a laser device? Even laser pointers have a warning to not look directly at the beam or to not point it directly at someone’s eyes.

IR beams are different. they aren’t in the human visible spectrum and are way less likely to cause injury to someones eyes.

You already know what what types of sensors you want to track so, the next step is go to the search box or Google and start looking and learning about those types of sensors and then find ones that will suit your needs. Its pretty simple really

I’m more asking about how the code would work. The sensor inputs can be whatever, spaced out a know distance. But how do you actually do the counting, direction, and speed? I am very weak on programming

No one can really answer that untill you choose the sensors. Esphome has a whole website dedicated to documentation, examples, and user submitted projects, you just gotta go on there and look, read, and learn. Thats how you get past having weak skills. People can only help you so much because part of it only you can do.