yesterday I got my ultrasonic sensor HC-SR04 (from eBay, see here). But I couldn't get it work till now. There is a library from ITead Studios for this 4 pin model (there you find the datasheet, too). Because that one didn't deliver anything else than zeros, I wrote my own sketch for debugging:

It still doesn't work. The board is a Duemilanove, the triggerPin wired to digital pin 5, the echoPin to 6. Vcc comes from the board, but the board is connected to a 5V power supply (e.g. my LAN breakout board works fine with this solution). I measured 5V stable at the sensor, but there seems to be no current.Is there something I might have missed? Or is it a malfunction of the sensor?

I think you just looked at the timing diagram, which is kind of confusing. Look at the photo on the first page, it's the 4 pin type.Besides, my sketch does the same as the one provided by ITead studio - or actually, I think it does. :-D

That's what I mentioned above. The timing of two pins is drawn in one line. But you can be sure my hardware is of 4 pin type and the library (have a look at the "documentation" here) is written for that type. If you analyze the lib (I did so) you see this, too.

Quote

What do the manufacturers suggest the problem is?

My sensor comes from Hong Kong, I don't believe there is a possibility to contact the manufacturer. I read several forum posts about sensors being defectiv and being replaced by seller - but as I'm a fair buyer, I try to be sure the part is really defectiv and it's not me handling it wrong.

Ok, there may have been 2 problems. I removed the debugging statements and now it works fine. Wonder why it did not with the library provided, because that one, of course, didn't include these lines.

So far so good. I made a little test series, using a book holding about 5cm away from the sensor. What I got was a bit sobering: The middle value of all measurements is 4.4cm (see attached pdf). And when nothing in front (it's about 2m to the wall), I get values round 360ms, what means 6 meters.Edit: As the 360 are microseconds, the distance is 6cm (some additional mistake by 10 ).

Does anyone know how precise the Ping sensor is? It should be better as it costs 10 times as much as mine!?