Use an ESP32 PWM and A/D for a vehicle loop detect.

User avatar
penright
Posts: 2
Joined: Thu Jan 20, 2022 2:09 pm

Use an ESP32 PWM and A/D for a vehicle loop detect.

Postby penright » Fri Jan 19, 2024 2:33 pm

Like the saying, Know enough to be dangerous, but not enough to do anything. That is how I am about this question. :-)

I have seen many circuits using a 555 to generate a square wave to connect to an in-ground loop for vehicle detection. Then use a voltage comparison to determine a voltage drop because a car is over the loop and changes the voltage. Seems like the ESP32 PWM could generate the square wave and the A/D senses the voltage change. If so, what would that look like?

Update: 1/22/2024
I did generate a PWM and looped it back into the ESP32. Then using 'FreqCountESP', I was able to count the frequency. Maybe now I am getting into circuit design rather than programming, but are there any ideas?

ESP_Sprite
Posts: 9757
Joined: Thu Nov 26, 2015 4:08 am

Re: Use an ESP32 PWM and A/D for a vehicle loop detect.

Postby ESP_Sprite » Tue Jan 23, 2024 3:01 am

Note that the frequency won't change if you put it into an inductor: the frequency is set by the ESP32 and as such isn't something the inductor would change. (For reference: a fair few of the 555-based circuits use the loop as part of the circuit that sets the frequency, and as such the frequency would change there.

One way I can think of doing things is to use the inductance as part of a filter. You use the inductor (=the vehicle loop) combined with a capacitor to filter the signal generated by the ESP32, then have some kind of peak detector to detect the amplitude of the resulting signal. If the inductor value changes because a car passes over it, the filter de-tunes and you should see a change in amplitude at the peak detector.

If you want to play around with that idea, I built a simulation here. Change the inductance value by a little bit (e.g. from 100uH to 99uH) and the output of the peak detector changes by a lot. Note that this circuit may actually be *too* sensitive; you may need to work around this in software by writing some code to detect at what frequency the maximum output is and use that frequency as an indication of the loop inductance. (Also note that this is entirely theoretical; I have no experience with loop detectors and have no clue if this setup would work in practice.)

Who is online

Users browsing this forum: markkuk and 313 guests