Go Down

Topic: DYP-ME007 Ultrasound range finder - display distance on a I2C 2x16 LCD (Read 12681 times) previous topic - next topic


I have read pretty confusing (at least to me) descriptions on how to connect a DYP-ME007 Ultrasound Range finder, and it's really dead simple. Ditto the I2C LCD. I use a DFRobot LCD. No resistors, pull-up, -down or any other direction are needed  :smiley-mr-green: . You do need the LiquidCrystal_I2C on your path (get it from http://hmario.home.xs4all.nl/arduino/LiquidCrystal_I2C/LiquidCrystal_I2C.zip here and unzip it to the libraries subfolder of your arduino development environment folder (the subfolder of the one that contains the arduino.exe). The DYP-ME007 has 5 pins, and you'll need only four: Vin, GND, TRIG and ECHO. Vin and GND are obvious and for teh script here, TRIG goes on digital 2 and ECHO to digital 3, but you choose. The LCD I2C is really simple too. Just connect Vin and GND, the SCL clock line goes on analog 5 and the SDA data line on analog 4. Hook it all up, connect your board to USB, upload this script and enjoy  8)


/* This Arduino script uses the DYP-ME007 Ultrasound Range finder to
 * measure distance in cm and displays the distance on a DFRobot
 * I2C LCD Module 508040.
 * Hardware: Connect the DYP-ME007 to +5V and Ground, and
 * the dypOutputPin to the DYP_ME007 "Trig" pin and the 
 * the dypInputPin to the DYP-ME007 "Echo" pin. 
 * By default I2C chips use analog pin A4 for data SDA and A5 
 * for the clock SCL. Of course 5V and GND need to be connected too.
 * Credits to DFRobot and Bexilino on http://arduino.cc/forum/index.php?topic=60973.0
 * from which I have copied parts.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display

int dypOutputPin = 2; // TRIG
int dypInputPin = 3;  // ECHO
long distance;
long cm;

void setup(){
  pinMode(dypOutputPin, OUTPUT);
  lcd.init();                      // initialize the lcd

void loop()
  // The DYP-ME007 pings on the low-high flank...
  digitalWrite(dypOutputPin, LOW);
  digitalWrite(dypOutputPin, HIGH);
  digitalWrite(dypOutputPin, LOW);   
  // the distance is proportional to the time interval
  // between HIGH and LOW
  distance = pulseIn(dypInputPin, HIGH);
  cm= distance/58;                        
  delay(100); // avoids LCD flicker



Sorry to bump such an old thread, but I just wanted to say thanks for the easy solution to use this sensor. Great work!  XD

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131