Attiny85, hc-sr04 noise problems, 12v to 5v

Hello! How are you? I hope you can help me with a little noise problem I am having, I tell you about my project.

I am trying to build a small safety system for small electric cars for children through ultrasonic sensors (hc-sr04), a relay and a micro attiny85, the operation of this security system is simple, when the hc-sr04 detect something at 75 cm send a signal to the attiny and this triggers the relay cutting the motor current ... In theory it is simple, but I am having many stability problems, the hc-sr04 give me readings with a lot of noise and this causes false highs in the attiny, the car is powered by a 12v battery, to reduce the voltage I use a lm7805 to leave it in 5v, I read that with a pair of capacitors can clean the signal, but I have not achieved anything, as I say I continue Having many noise problems, could someone help me? Throw some light on me please

THANKS!!

I leave you a schematic of the circuit

Wow, you impress me. That schematic is even less readable than your run-of-the-mill Fritzing, which at least comes with annotations at the connections!

All I can say about this is that I expect to see more capacitors, and smaller ones than the single 1mF.

Another thing to be aware of: those ultrasound sensors are pretty bad at detecting people. Especially if those people are wearing clothing, even more so of that clothing is soft and fluffy. Bare skin reflects ultrasound OK, clothing not.

You schematic is unconventional, but, if I understand it correctly the diode and 1000 uF capacitor arrangement makes good sense. The transistor Q1 is shown incorrectly as the emitter should go to ground, the collector to the relay coil, and the base to the microcontroller through a resistor. You don't show power to the relay, but that should come from the 12 volt source not the regulated 5V.

While it may be that you still have a power issue, HC-SR04 sensors in a moving environment may occasionally give bad readings. You might want to add code to trigger the relay only when you've had several successive detections within your threshold range of 75 cm.

Even I am having the same issue. Using JSN and HCSR04 when I power with 5V I am able to read correct readings. But when I power with 12V and LM2596 the errors occur. Can anyone help to solve this problem?