Arduino UNO + shielding Ethernet + ultrasonic sensor = failed


With my Arduino Uno I measure the distance using HC-SR04 ultrasonic sensor with no problems at all using the wiring below. When I attach ethernet shield, my ultrasonic sensor does not measure distance any more, it constantly says 0cm no matter what. I have tried different digital pin pairs such as 5-7, 6-8, 5-9, 3-5, 2-8 but no luck.

I suspect that HC-SR04 is not compatible with my Ethernet shield but I haven't seen such warning anywhere on the net.

  • There are no components attached to arduino besides ethernet shield and the ultrasonic sensor itself.
  • There is no SD Card in SD Card slot.
  • My ethernet shield works fine while running a web server or web client script.
  • Digital pins of ethernet shield works fine with all other components such as temperature sensor, motion sensor etc.

Here is the ethernet shield I have;

Here is my actual circuit;

Here is my code;

#define trigPin 6
#define echoPin 7

void setup() {
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);

void loop() {
  int duration, distance;
  digitalWrite(trigPin, HIGH);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH) / 2;
  distance = duration / 29.1;
  Serial.println(" cm");

Today I bought a multimeter and tested my circuit. Here are the results;

When my circuit directly attached to Arduino itself;

4.80V & 5.7mA

When my circuit attached to ethernet shield;

3.06V & 3.8mA

I think the problem is that 3.06V is not enough for my HC-SR04 to operate.