Weird solution to HC-SR04 problem?

I have built a robot-car with obstruction sensing using the HC-SR04. I had problems with it when the motor of the car would draw a lot of power it would mess up the distance measurement. (Using L293D H-Bridge from the starter kit) I tried all sorts of things with capacitors and separating the power supply and grounds as much as possible (due to using only one breadboard I did not completely separate the power).

To my big surprise, the one thing that solves the problem for me and have a good distance measuring performance at all times, is to put a capacitor over the power and ground of the HC-SR04, but not connect the ground to the Arduino or motor-battery ground - i.e. not ground it at all, just connect it to the - of the capacitor..... Is this explainable?

Could you draw a schematic of that. I can't picture how it's getting any power at all.

Thanks for responding. I did a quick sketch in Fritzing. Note that the GND of the HC-SR04 goes to the capacitor, but its not grounded... If I ground it, but also when I don't connect HCSR04-GND it to the capacitor, or not use a capacitor at all, I constantly get bad object detections.

Hi Klinkekuler,
Are you really using those tiny 9V batteries, there useless for anything that needs more then a few mA of current.

Your servo could well use 1A+ and the motor similar at start up or if stalled... Get some proper power in the form of at lest 4-6 AA's Nimh rated at 2500mA+

Also could we see your code, there might be a problem there or we can say it's OK??

Hope it helps, Regards.

Mel.

It looks like you are trying to power a servo from the Arduino -- if so, don't do that. It will always cause problems.

You might be accidentally powering or grounding the HC-SR04 through one of the inputs, which will damage it and the Arduino.

Hint: Fritzing diagrams are very confusing, hard to read and often misleading. They are only for complete beginners. If you are interested in this hobby, forget Fritzing exists and learn to read and draw schematic diagrams. Even a hand-drawn schematic is better than a Fritzing diagram.

Hi,

It looks like you are trying to power a servo from the Arduino -- if so, don't do that. It will always cause problems.

And what JR says, powering servos and motors from the Arduino is not done... and can only lead to problems in the long term.

Regards

Mel.

Thanks for your responses!

Cactusface:
And what JR says, powering servos and motors from the Arduino is not done... and can only lead to problems in the long term

But I'm not doing that for the motor which is what is giving me the problem. The motor has a separate 2x9v battery supply.

Look, I am the first one to agree that this is not a professional setup or anything and brakes all kinds of good-electronics-practices, but its just for fun. I was just wondering why the HC-SR04 is working fine without grounding it to anything other than to the capacitor...

Cactusface:
Are you really using those tiny 9V batteries, there useless for anything that needs more then a few mA of current.

Yes, and I put 2 in parallel for the motor as you can see to get enough current to it. It's slow but ok for now...

But this got me thinking.. maybe the 2x9v batteries don't supply enough current and therefore it draws current from the arduino power through the H-bridge somehow which causes the problems on the arduino powered circuits...
Will try to upgrade the motor-power!

Hi,
Even 2 of these batteries will not give you the power you need, which is why your motor is so slow!!

Quote from: Cactusface on Dec 31, 2014, 04:42 pm

Are you really using those tiny 9V batteries, there useless for anything that needs more then a few mA of current.

Yes, and I put 2 in parallel for the motor as you can see to get enough current to it. It's slow but ok for now...

And you're still driving the servo from the Arduino! In some strange way perhaps the HC-SR04 gets grounded via one of the signal pins (When LOW).

Like many I don't find fitz... images very easy or clear, try using a pencil to make things clear, and we need to see your code, if only to say yes it's OK.

Regards

Mel.

I replaced the 2x9v batteries with a battery-pack of 8x1.5v 2300mah. I also power now everything from that source except the Arduino. - solved!
Thank you.

Hi Klinkekuler,
Glad to hear you solved the problem, so hopefully you will use good batteries next time, it's amazing how many try to drive motors, etc, from those tiny batteries.

Regards

Mel.