NewPing library porting for DYP-ME007Y Ultrasonic Sensor

Hello,

I was wondering if anyone has had success with porting NewPing library on a Particle device? I am looking to interface to a DYP-ME007Y Ultrasonic Sensor.

I have had good success using the NewPing library with the DYP-ME007Y with the Arduino family of boards. I am familiar with the HC-SR04 library for Particle devices, however I would like to use DYP-ME007Y sensor because the ultrasonic transmitter/receiver element is waterproof and can mounted away from the board.

Below is a link for the NewPing libiray developed by Tim Eckel.
http://playground.arduino.cc/Code/NewPing

Thanks for the help!

Adam

1 Like

What exact feature do you want to see ported?
This lib does have several conditional compile instructions that would allow to build for Particle already (with minor include updates).

On first glance that’s the biggest change I could see required in NewPing.h

#if defined (PARTICLE)
	#include "Particle.h"
#elif defined (ARDUINO) && ARDUINO >= 100
	#include <Arduino.h>
#else
	#include <WProgram.h>
	#include <pins_arduino.h>
#endif

and where you find #if defined (__arm__) && defined (TEENSYDUINO) you could go with #if defined (__arm__) && (defined (TEENSYDUINO) || defined (PARTICLE))

Thank you for the uber fast response!

I am basically just looking to port the library to so it works with the DYP-ME007Y sensor. I will implement the changes you suggested above this evening and report back my results.

Thanks again.

I’ve also seen this bit here

#if (defined (__arm__) && (defined (TEENSYDUINO) || defined (PARTICLE)))
	#undef  PING_OVERHEAD
	#define PING_OVERHEAD 1
	#undef  PING_TIMER_OVERHEAD
	#define PING_TIMER_OVERHEAD 1
  #if defined (PARTICLE)                       // add this
	#define DO_BITWISE false
  #else
	#define DO_BITWISE true
  #endif
#elif !defined (__AVR__)
	#undef  PING_OVERHEAD
	#define PING_OVERHEAD 1
	#undef  PING_TIMER_OVERHEAD
	#define PING_TIMER_OVERHEAD 1
	#undef  TIMER_ENABLED
	#define TIMER_ENABLED false
	#define DO_BITWISE false
#else
	#define DO_BITWISE true
#endif
1 Like

OK,

So I implemented the changes your outlined and the NewPing library with the DYP-ME007Y sensor works great. I will continue to tinker with it to check the performance and try the multiple sensor performance.

Thanks again for the help

1 Like