Moteino + HC-SR04 not working / responding

Started by lilpint97, September 04, 2015, 10:33:04 AM

lilpint97

OK, I am looking for any thoughts. I have a setup, very standard with the Ultrasonic sensor. I have ECHO on pin 7, TRIG on pin 6, and tired power from both the 3.3v, and pin 5 same results. The sketch is down to the bare minimum. I have also tried 3 different sensors, and 3 different motenio's all R4, assuming bad parts, or some other error. To verify my issue I broke out my old Ardunio Uno, used the same sketch, wires, sensors, etc, and it works perfect. I am confused, appreciate any thoughts. Attached an image as well.



#define TRIG 6
#define ECHO 7
#define EN   5

long cm;
long duration, distance;
void setup(){
  Serial.begin(115200); 
  pinMode (TRIG,OUTPUT);//attach pin 6
  pinMode (ECHO,INPUT);//attach pin 7
  pinMode (EN,OUTPUT);//attach pin 5
  digitalWrite(EN, HIGH); // Turn power on PWM pin 5
}
void loop(){
  Serial.println("Test");
  digitalWrite(TRIG, LOW);
  delayMicroseconds(2);
  digitalWrite(TRIG, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIG, LOW);
  duration = pulseIn(ECHO, HIGH);
  Serial.print(duration); Serial.println("..Duration");
  cm = (duration/2) / 29;
  Serial.println(cm);
  delay(250);
}


Felix

You need 5V power to the sensor, not 3.3V.

lilpint97

Thanks for that, ugh it's what I get for having to taking an extended break, to build a new home :)

vax

Quote from: Felix on September 04, 2015, 11:24:41 AM
You need 5V power to the sensor, not 3.3V.

Don't you need a level shifter or at least a divider on the ECHO pin? Aren't you feeding a 5V signal into the moteino?

Felix

Quote from: vax on May 12, 2016, 07:09:33 AM
Don't you need a level shifter or at least a divider on the ECHO pin? Aren't you feeding a 5V signal into the moteino?
No, just 5vdd into the sensor.