Hi there,I'm having a problem with the 3 pin solution. I'm using the same sketch that you have in your bitbucket, and also the same code but the sensor doesn't work properly, it just prints 0 cm always. I prove the sensor with 4 pin connection and works fine. I don't understand why it doesn't work.I'm using Arduino UNO rev 3 and a HC-SR04 sensor.ThanksDaniel
I believe you mean the 1 pin method (the other two pins are just power/ground which can be shared with multiple devices. Anyway, the 1 pin method is a bit of a hack, and as stated, not all sensors or microcontrollers will work. As the HC-SR04 is made by 500 different companies in China for $0.50 a piece, many are different and some cut corners to make a slight profit.Because of this, I would suggest trying to install the cap as instructed if you have problems. If that doesn't work, you probably just have a sensor that's not compatible, which I know exists as I have one as well. Best of luck!
Yes, I meant the 1 pin method (I said the 3 pin method because I have to connect just three pins counting gnd and vcc). It seems that I'm a bit unlucky and my sensors cannot be hacked. I'm doing a project with lots of connections and I would have like to be able to optimize some of them. Thanks for your fast answer.
Tim, Thanks for the excellent improvements to the ultrasonic rangefinder capabilities!I recently got a couple US-100s to replace my HC-SR04s for use with Particle Photon.1. Will you put the latest New_Ping up on Particle.build.io? The one there is 1.8.02. I want to use the US-100s digital means for communicating, instead of the standard analog pulse length your library does so well. This puts the computation onto the microprocessor of the US-100, including temperature compensation (important for my outdoor installation in an oil tank). Do you have any plans for adding the US-100 to the list of compatible ultrasonic transceivers? 3. If you have used the US-100, how do you feel about its claims of mm accuracy?Thanks again!Steve Potter
Hi thereI am trying to use the newping library with my Particle Photon and I am running into the following compile error when compiling NewPing.cpp:in line 22:15_triggerMode = (uint8_t *) portModeRegister(digitalPinToPort(trigger_pin)); // Get the port mode register for the trigger pin.The error relates to assigning a unit8_t* to a volatile unint32_t*. I'm not sure if the error relates to possible misalignment, the volatile attribute or something else such as missing option selected in my code or a compiler option that needs changing.I am using Particle dev on a Windows 10 machine to prepare my code which is compiled in the Particle.io cloud.Any guidance or suggestions how to resolve this issue would be appreciated.Update:I just realized that the NewPing library is available through the Particle built in libraries, except the version available that way is 1.8, versus the latest version (that I was using is 1.9). Also the line throwing the error is different in v1.8 and does not cast the device register as uint_8t*. I have a way ahead now, using the v1.8 library. I'll see how that goes.
What are the hardware / software requirements for this library? I'm using an older mac laptop running OS X 10.6.8 (the newest OS this computer will run). I'm running Arduino 1.0.5 which I believe is the newest software version this computer will run. The development board I'm using is a Arduino Mega -- not that that matters in this case. -- not yet anyway.That being said, when I try to import the NewPing library I get a slew of java errors in the Arduino Error Console.They start:java.lang.NullPointerExceptionat sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:36)at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:18)at java.lang.reflect.Field.get(Field.java:358)at apple.awt.CAccessibility.getAccessibleRoleFor(CAccessibility.java:200) And continue on for many lines.However the library appears to be installed. That is to say the folder appears in the third party libraries folder.But, the library is not usable. When the compiler comes to the line instantiating a NewPing object, it throws an error that NewPing is not a type.Is there an older version that might work for me? Or java upgrades? Any ideas would be appreciated.
Ok I'll start looking into other possible problems. Not that I've used a lot of third party libraries, but this is the only one I've had any trouble with. Thank you for your quick response,Ralph
Hi Tim,i need some support in my current project. I would like to trigger and read the data of 64 HCSR04 Ultrasonic distance sensors. I want to build an array of 8x8 sensors with a distance of 6cm to a vibrating wall. Through the distance variations (Amplitude is big enough) I hope to get enough information to analyse the wall. The echo of the sensors will not effect each other. I have a big distance betweeneach sensor and a special foam behind the sensors which will hopefully absorb the signals. I read on your website that your sketch can handle 15 sensors on a 33ms intervall. When I change the Maximum_Distance even smaller intervalls should be possible, correct?Do you know a possibility to ping as many sensors as possible at the same time?I know that it will never be possible to trigger 64 sensors at the same time, becauseeven with Port Manipulation it is just possible to to activate 7 Pins at the same time.Do you have any suggestions or do you know if somebody has done something similar before?Lars
hi Tim,I would like to use the timer methods for the NewPing library on an ATTiny841.In the documentation you mention that the ATTinies do not have "a suitable timer". What do you mean by that ?As far as I can see you are using a 8-bit timer on the atmega328, and there is an 8 bit timer on the ATTiny84 and ATTiny841 as well.As I use the ATTiny841, which has two 16 bit timers and one 8 bit timer, I'm a bit confused why it would not be possible to use any of the 16 bit timers ?kind regards,Gert